Пример #1
0
 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)
Пример #2
0
    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')
            pk = self.get('_pk')
            util.InsertIntoDB(tablename, props)
        #             result = util.InsertIntoDB(tablename, props)
        elif state == MMODE_STATE_UPDATE:
            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')
            if props:
                prere = {pk: props.get(pk)}
                util.DeleteFromDB(tablename, prere)
                #             result = util.DeleteFromDB(tablename, prere)
                self.mdelete()
            else:
                logging.error('syncDB pk:%s is not data' % str(pk))

        #         logger.debug('syncDB,tbname:%s,%s:%s' %(tablename, pk, props.get(pk)))
        #         if result:  平台缺陷,2014-6-20修改 http://bbs.9miao.com/thread-49154-1-1.html
        if state != MMODE_STATE_DEL:
            MemObject.update(self, '_state', MMODE_STATE_ORI)
Пример #3
0
 def syncDB(self):
     """同步到数据库
     """
     tablename = self._name.split(':')[0]
     data_item = self.__dict__.get("data")
     data_item.setValue(data_item.value)
     if self._cas:
         self.release()
     props = self.data
     pk = self.pk
     prere = {pk:props.get(pk)}
     result = util.UpdateWithDict(tablename, props, prere)
     return result
Пример #4
0
 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)