Example #1
0
 def create(self, creator_id, conn=None):
     if creator_id is None or creator_id == EMPTY_UID:
         raise CoreError("modifier_id can't be empty when creating a model.")
     self.creator_id = creator_id
     self.modifier_id = creator_id
     self.created_time = dtutil.utcnow()
     self.modified_time = dtutil.utcnow()
     self.row_version = 1
     BaseModel.create(self, conn=conn)
Example #2
0
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
Example #3
0
 def emit(self, record):
     try:
         global LOG_TABLENAME
         message = self.format(record)
         self.conn.insert(LOG_TABLENAME, l_level=record.levelname, l_message=message, logged_time=dtutil.utcnow())
         
     except:
         self.handleError(record)
Example #4
0
 def update_timestamp(self, modifier_id):
     self.modifier_id = modifier_id
     self.modified_time = dtutil.utcnow()
     self.row_version += 1
Example #5
0
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)