(self,state=MMODE_STATE_UPDATE)
return result
同步到数据库
同步到数据库
同步到数据库
def syncDB(self,state=MMODE_STATE_UPDATE):
        """同步到数据库
        """
        tablename = self._name.split(':')[0]
        if state==MMODE_STATE_NEW:
            props = self.getData()
            pk = self._pk
            result = util.InsertIntoDB(tablename, props)
        elif state==MMODE_STATE_UPDATE:
            props = self.getData()
            pk = self._pk
            prere = {pk:props.get(pk)}
            sql = util.UpdateWithDictSQL(tablename, props, prere)
            DBPub().send((tablename,sql))
            result = True
        else:
            pk = self._pk
            props = self.getData()
            prere = {pk:props.get(pk)}
            result = util.DeleteFromDB(tablename,prere)
        return result
def syncDB ( self , state = MMODE_STATE_UPDATE ) : tablename = self . _name . split ( ':' ) [ 0 ] if state == MMODE_STATE_NEW : props = self . getData ( ) pk = self . _pk result = util . InsertIntoDB ( tablename , props ) elif state == MMODE_STATE_UPDATE : props = self . getData ( ) pk = self . _pk prere = { pk : props . get ( pk ) } sql = util . UpdateWithDictSQL ( tablename , props , prere ) DBPub ( ) . send ( ( tablename , sql ) ) result = True else : pk = self . _pk props = self . getData ( ) prere = { pk : props . get ( pk ) } result = util . DeleteFromDB ( tablename , prere ) return result