• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python memobject.MemObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: syncDB

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


示例17: updateMulti

    def updateMulti(self, updateData):
        if not updateData:
            return False

        data = self.getData()
        fkName = self._mAdmin.getFk()
        pkName = self._mAdmin.getPk()
        if fkName and fkName in updateData.keys():
            fk = data.get(fkName, "")
            new_fk = updateData.get(fkName, fk)
            if new_fk != fk:
                pk = data.get(pkName)
                self._updateFk(pk, fk, new_fk)

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


示例18: update

 def update(self, key, values):
     data = self.getData()
     if self._fk and self._fk==key:
         fk = data.get(self._fk,"")
         tb_name = self._name.split(":")[0]
         old_name = '%s_fk:%s'%(tb_name,fk)
         pk = data.get(self._pk)
         old_fkmm = MFKMode(old_name)
         old_pklist = old_fkmm.get('pklist')
         if old_pklist and pk in old_pklist:
             old_pklist.remove(pk)
             old_fkmm.update('pklist', old_pklist)
         new_name = '%s_fk:%s'%(tb_name,values)
         new_fkmm = MFKMode(new_name)
         new_pklist = new_fkmm.get('pklist')
         if new_pklist and pk not in new_pklist:
             new_pklist.append(pk)
             new_fkmm.update('pklist', new_pklist)
     data.update({key:values})
     result = MemObject.update(self, 'data',data)
     self.syncDB()
     return result
开发者ID:cautonwong,项目名称:G-Firefly,代码行数:22,代码来源:mmode.py


示例19: insert

 def insert(self):
     if self._incrkey and not self.get("_incrvalue"):
         self._incrvalue = util.GetTableIncrValue(self._name)
     MemObject.insert(self)
开发者ID:9miao,项目名称:Firefly,代码行数:4,代码来源:mmode.py


示例20: delete

 def delete(self):
     '''删除对象
     '''
     return MemObject.update(self,'_state',3)
开发者ID:ChandleWEi,项目名称:firefly,代码行数:4,代码来源:mmode.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python memory.make_object函数代码示例发布时间:2022-05-27
下一篇:
Python memcacheify.memcacheify函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap