def resource_data_set(context, resource_id, key, value, redact=False):
 if redact:
  (method, value) = crypt.encrypt(value)
 else:
  method = ''
 try:
  current = resource_data_get_by_key(context, resource_id, key)
 except exception.NotFound:
  current = models.ResourceData()
  current.key = key
  current.resource_id = resource_id
 current.redact = redact
 current.value = value
 current.decrypt_method = method
 current.save(session=context.session)
 return current

def resource_data_set ( context , resource_id , key , value , redact = False ) : if redact : ( method , value ) = crypt . encrypt ( value ) else : method = '' try : current = resource_data_get_by_key ( context , resource_id , key ) except exception . NotFound : current = models . ResourceData ( ) current . key = key current . resource_id = resource_id current . redact = redact current . value = value current . decrypt_method = method current . save ( session = context . session ) return current
save resources key/value pair to database .