(self,data)
return mm
创建一个新的对象
创建一个新的对象
创建一个新的对象
def new(self,data):
        """创建一个新的对象
        """
        incrkey = self.incrkey
        tablename = self.name
        if incrkey:
            result = util.InsertIntoDBAndReturnID(tablename, data)
            data[incrkey] = result
            pk = data.get(self.pk)
            if pk is None:
                raise PKValueError(data)
            mm = MemModel(self.name+':%s'%pk,self.pk,data=data,**self.kw)
            setattr(mm,incrkey,pk)
        else:
            pk = data.get(self.pk)
            result = util.InsertIntoDB(tablename, data)
            if not result:
                raise util.SQLError()
            mm = MemModel(self.name+':%s'%pk,self.pk,data=data,**self.kw)
        mm.insert()
        return mm
def new ( self , data ) : incrkey = self . incrkey tablename = self . name if incrkey : result = util . InsertIntoDBAndReturnID ( tablename , data ) data [ incrkey ] = result pk = data . get ( self . pk ) if pk is None : raise PKValueError ( data ) mm = MemModel ( self . name + ':%s' % pk , self . pk , data = data , * * self . kw ) setattr ( mm , incrkey , pk ) else : pk = data . get ( self . pk ) result = util . InsertIntoDB ( tablename , data ) if not result : raise util . SQLError ( ) mm = MemModel ( self . name + ':%s' % pk , self . pk , data = data , * * self . kw ) mm . insert ( ) return mm