当前位置: 首页>>代码示例>>Python>>正文


Python memobject.MemObject类代码示例

本文整理汇总了Python中memobject.MemObject的典型用法代码示例。如果您正苦于以下问题:Python MemObject类的具体用法?Python MemObject怎么用?Python MemObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MemObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: syncDB

 def syncDB(self):
     """同步到数据库
     """
     state = self.get('_state')
     tablename = self._name.split(':')[0]
     if state == MMODE_STATE_ORI:
         return
     elif state == MMODE_STATE_NEW:
         props = self.get('data')
         props = self.dumps(props)
         pk = self.get('_pk')
         result = util.InsertIntoDB(tablename, props)
     elif state == MMODE_STATE_UPDATE:
         props = self.get('data')
         pk = self.get('_pk')
         props = self.dumps(props)
         prere = {pk: props.get(pk)}
         del(props[pk])
         util.UpdateWithDict(tablename, props, prere)
         result = True
     else:
         pk = self.get('_pk')
         props = self.get('data')
         props = self.dumps(props)
         prere = {pk: props.get(pk)}
         result = util.DeleteFromDB(tablename, prere)
     if result:
         MemObject.update(self, '_state', MMODE_STATE_ORI)
开发者ID:isphinx,项目名称:traversing,代码行数:28,代码来源:mmode.py

示例2: __init__

 def __init__(self, name,pk,data={},fk=None,**kw):
     """
     """
     MemObject.__init__(self, name,**kw)
     self._pk = pk
     self._fk = fk
     self.data = data
开发者ID:9miao,项目名称:G-Firefly,代码行数:7,代码来源:mmode.py

示例3: __init__

 def __init__(self, name,pk,timeout=TIMEOUT,**kw):
     MemObject.__init__(self, name, mclient)
     self._pk = pk
     self._fk = kw.get('fk','')
     self._incrkey = kw.get('incrkey','')
     self._incrvalue = kw.get('incrvalue',0)
     self._timeout = timeout
开发者ID:ChandleWEi,项目名称:firefly,代码行数:7,代码来源:mmode.py

示例4: __init__

 def __init__(self, name,pk,data={}):
     """
     """
     MemObject.__init__(self, name, mclient)
     self._state = MMODE_STATE_ORI#对象的状态 0未变更  1新建 2更新 3删除
     self._pk = pk
     self.data = data
     self._time = time.time()
开发者ID:9miao,项目名称:Firefly,代码行数:8,代码来源:mmode.py

示例5: __init__

    def __init__(self, pid, name, mc):
        """

        """
        MemObject.__init__(self, name, mc)
        self.id = pid
        self.level = 0
        self.profession = 0
        self.nickname = u""
        self.guanqia = 1000
开发者ID:haiya512,项目名称:firefly_study,代码行数:10,代码来源:mcharacter.py

示例6: __init__

 def __init__(self,pid,name,mc):
     """初始化城镇要塞对象
     @param territoryId: int 领地的ID
     @param guard: int 殖民者的ID
     @param guardname: str 殖民者的名称
     @param updateTime: int 领地被更新的时间
     """
     MemObject.__init__(self, name, mc)
     self.id = pid
     self.level = 0
     self.profession = 0
     self.nickname = u''
     self.guanqia = 1000
开发者ID:chenee,项目名称:firefly_study,代码行数:13,代码来源:mcharacter.py

示例7: checkSync

 def checkSync(self,timeout=TIMEOUT):
     """检测同步
     """
     ntime = time.time()
     objtime = MemObject.get(self, '_time')
     self.syncDB()
     if ntime  -objtime>=timeout and timeout:
         self.mdelete()
开发者ID:ChandleWEi,项目名称:firefly,代码行数:8,代码来源:mmode.py

示例8: update

 def update(self, key, values):
     data = self.get_multi(['data','_state'])
     ntime = time.time()
     data[key] = values
     if data.get('_state')==1:
         props = {'data':data.get('data'),'_time':ntime}
     else:
         props = {'_state':2,'data':data.get('data'),'_time':ntime}
     return MemObject.update_multi(self,props)
开发者ID:ChandleWEi,项目名称:firefly,代码行数:9,代码来源:mmode.py

示例9: checkSync

 def checkSync(self, timeout=TIMEOUT):
     """检测同步
     """
     ntime = time.time()
     objtime = MemObject.get(self, '_time')
     if ntime - objtime >= timeout and timeout:
         self.mdelete()
     else:
         reactor.callLater(0, self.syncDB)
开发者ID:isphinx,项目名称:traversing,代码行数:9,代码来源:mmode.py

示例10: update

 def update(self, key, values):
     data = self.get_multi(['data','_state'])
     ntime = time.time()
     data['data'].update({key:values})
     if data.get('_state')==MMODE_STATE_NEW:
         props = {'data':data.get('data'),'_time':ntime}
     else:
         props = {'_state':MMODE_STATE_UPDATE,'data':data.get('data'),'_time':ntime}
     return MemObject.update_multi(self, props)
开发者ID:9miao,项目名称:Firefly,代码行数:9,代码来源:mmode.py

示例11: update_multi

 def update_multi(self, mapping):
     ntime = time.time()
     data = self.get_multi(['data','_state'])
     data['data'].update(mapping)
     if data.get('_state')==1:
         props = {'data':data.get('data'),'_time':ntime}
     else:
         props = {'_state':2,'data':data.get('data'),'_time':ntime}
     return MemObject.update_multi(self, props)
开发者ID:ChandleWEi,项目名称:firefly,代码行数:9,代码来源:mmode.py

示例12: update_multi

 def update_multi(self, mapping):
     n_time = time.time()
     data = self.get_multi(['data', '_state'])
     data['data'].update(mapping)
     if data.get('_state') == MMODE_STATE_NEW:
         props = {'data': data.get('data'), '_time': n_time}
     else:
         props = {'_state': MMODE_STATE_UPDATE, 'data': data.get('data'), '_time': n_time}
     return MemObject.update_multi(self, props)
开发者ID:isphinx,项目名称:traversing,代码行数:9,代码来源:mmode.py

示例13: update

 def update(self, key, values):
     data = self.getData()
     if self._fk and self._fk==key:#判断外键是否更新
         fk = data.get(self._fk,"")
         pk = data.get(self._pk)
         self._update_fk(pk, fk, values)#更新外键
     data.update({key:values})
     result = MemObject.update(self, 'data',data)
     self.syncDB()
     return result
开发者ID:9miao,项目名称:G-Firefly,代码行数:10,代码来源:mmode.py

示例14: update

    def update(self, key, value):
        data = self.getData()
        fkName = self._mAdmin.getFk()
        pkName = self._mAdmin.getPk()
        if fkName and fkName == key:
            fk = data.get(fkName, "")
            pk = data.get(pkName)
            self._updateFk(pk, fk, value)

        data[key] = value
        return MemObject.update(self, 'data', data) and self._updateDB(data[pkName], {key:value})
开发者ID:heyilin416,项目名称:OMServer,代码行数:11,代码来源:mmode.py

示例15: update_multi

 def update_multi(self, mapping):
     data = self.getData()
     if self._fk and self._fk in mapping.keys():#查看外键是否在更新的map中
         fk = data.get(self._fk,"")
         new_fk = mapping.get(self._fk,fk)
         if new_fk!=fk:#查看外键的值是否发生了变化
             pk = data.get(self._pk)
             self._update_fk(pk, fk, new_fk)#更新外键
     data.update(mapping)
     result = MemObject.update(self, 'data',data)
     self.syncDB()
     return result
开发者ID:9miao,项目名称:G-Firefly,代码行数:12,代码来源:mmode.py


注:本文中的memobject.MemObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。