def createByBiz(cls, **kwargs): ''' 创建实体并自己注册到工作单元内 @param cls: 实体类型 ''' unitofwork = UnitOfWork.inst() entity = cls(**kwargs) unitofwork.register(entity) return entity
def getListByCond(cls, *args, **kws): cr = QueryCriteria(cls).filter(*args) if kws.has_key('limit'): cr.limit(int(kws['limit'])) if kws.has_key('offset'): cr.offset(int(kws['offset'])) return UnitOfWork.inst().getListByCond(cr)
def createByBiz(cls, **kwargs): ''' 创建实体并自己注册到工作单元内 @param cls: 实体类型 ''' if not kwargs.get('use_autoincrement_id'): primaryKey = cls.primaryKey() unitofwork = UnitOfWork.inst() if not kwargs.has_key(primaryKey): kwargs[primaryKey] = unitofwork.idgenerator().get() entity = cls(**kwargs) unitofwork.register(entity) return entity
def getUnitOfWork(self): if not self._unitofwork: self._unitofwork = UnitOfWork.inst() return self._unitofwork
def getListByCond(cls, condition, *args, **kwargs): return UnitOfWork.inst().getListByCond2(cls, condition, args, **kwargs)
def get(cls, **kwargs): return UnitOfWork.inst().get(cls, tuple([kwargs.get(key) for key in cls._primary_key]))
def getListByCond(cls, condition='', *args): return UnitOfWork.inst().getListByCond(cls, condition, args)
def getList(cls, entity_ids): return UnitOfWork.inst().getList(cls, entity_ids)
def get(cls, **kwargs): return UnitOfWork.inst().get( cls, tuple([kwargs.get(key) for key in cls._primary_key]))