def set_datastore_value_for_config_key(pack_name, key_name, value, secret=False, user=None):
 if user:
  scope = FULL_USER_SCOPE
 else:
  scope = FULL_SYSTEM_SCOPE
 name = get_key_reference(scope=scope, name=key_name, user=user)
 kvp_api = KeyValuePairAPI(name=name, value=value, scope=scope, secret=secret)
 kvp_db = KeyValuePairAPI.to_model(kvp_api)
 existing_kvp_db = KeyValuePair.get_by_scope_and_name(scope=scope, name=name)
 if existing_kvp_db:
  kvp_db.id = existing_kvp_db.id
 kvp_db = KeyValuePair.add_or_update(kvp_db)
 return kvp_db

def set_datastore_value_for_config_key ( pack_name , key_name , value , secret = False , user = None ) : if user : scope = FULL_USER_SCOPE else : scope = FULL_SYSTEM_SCOPE name = get_key_reference ( scope = scope , name = key_name , user = user ) kvp_api = KeyValuePairAPI ( name = name , value = value , scope = scope , secret = secret ) kvp_db = KeyValuePairAPI . to_model ( kvp_api ) existing_kvp_db = KeyValuePair . get_by_scope_and_name ( scope = scope , name = name ) if existing_kvp_db : kvp_db . id = existing_kvp_db . id kvp_db = KeyValuePair . add_or_update ( kvp_db ) return kvp_db
set config value in the datastore .