def update_sysprop(key, value, modifier_id): if strutil.is_empty(key): raise CoreError("key can't be empty.") if strutil.is_empty(value): raise CoreError("p_value can't be empty.") if has_sysprop(key) is None: raise CoreError("the key %s of sysprop does not existed.", key) value = strutil.to_str(value) conn = __get_conn() conn.update(SYSPROP_TABLENAME, where="p_key = '%s'" % key , p_value=value, modified_time=dtutil.utcnow(), modifier_id=modifier_id) cache.put(CACHESPACE_SYSPROP, key, value)
def add_sysprop(key, value, modifier_id): if strutil.is_empty(key): raise CoreError("key can't be empty.") if strutil.is_empty(value): raise CoreError("value can't be empty.") conn = __get_conn() value1 = strutil.to_str(value) if not has_sysprop(key): conn.insert(SYSPROP_TABLENAME, p_key=key, p_value=value1, created_time=dtutil.utcnow(), modified_time=dtutil.utcnow(), modifier_id=modifier_id) else: conn.update(SYSPROP_TABLENAME, where="p_key = '%s'" % key, p_value=value1, modified_time=dtutil.utcnow(), modifier_id=modifier_id) cache.put(CACHESPACE_SYSPROP, key, value) return key