def document_etag(value, ignore_fields=None):
 if ignore_fields:
  def filter_ignore_fields(d, fields):
   for field in fields:
    (key, _, value) = field.partition('.')
    if value:
     filter_ignore_fields(d[key], [value])
    elif (field in d):
     d.pop(field)
    else:
     pass
  value_ = copy(value)
  filter_ignore_fields(value_, ignore_fields)
 else:
  value_ = value
 h = hashlib.sha1()
 json_encoder = app.data.json_encoder_class()
 h.update(dumps(value_, sort_keys=True, default=json_encoder.default).encode('utf-8'))
 return h.hexdigest()

def document_etag ( value , ignore_fields = None ) : if ignore_fields : def filter_ignore_fields ( d , fields ) : for field in fields : ( key , _ , value ) = field . partition ( '.' ) if value : filter_ignore_fields ( d [ key ] , [ value ] ) elif ( field in d ) : d . pop ( field ) else : pass value_ = copy ( value ) filter_ignore_fields ( value_ , ignore_fields ) else : value_ = value h = hashlib . sha1 ( ) json_encoder = app . data . json_encoder_class ( ) h . update ( dumps ( value_ , sort_keys = True , default = json_encoder . default ) . encode ( 'utf-8' ) ) return h . hexdigest ( )
computes and returns a valid etag for the input value .