Пример #1
0
    def createByBiz(cls, **kwargs):
        '''
        创建实体并自己注册到工作单元内
        @param cls: 实体类型
        '''

        unitofwork = UnitOfWork.inst()
        entity = cls(**kwargs)
        unitofwork.register(entity)
        return entity
Пример #2
0
 def createByBiz(cls, **kwargs):
     '''
     创建实体并自己注册到工作单元内
     @param cls: 实体类型
     '''
     
     unitofwork = UnitOfWork.inst()
     entity = cls(**kwargs)
     unitofwork.register(entity)
     return entity
Пример #3
0
 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)
Пример #4
0
    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)
Пример #5
0
 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
Пример #6
0
    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
Пример #7
0
 def getUnitOfWork(self):
     if not self._unitofwork:
         self._unitofwork = UnitOfWork.inst()
     return self._unitofwork
Пример #8
0
 def getListByCond(cls, condition, *args, **kwargs):
     return UnitOfWork.inst().getListByCond2(cls, condition, args, **kwargs)
Пример #9
0
 def get(cls, **kwargs):
     return UnitOfWork.inst().get(cls, tuple([kwargs.get(key) for key in cls._primary_key]))
Пример #10
0
 def getListByCond(cls, condition='', *args):
     return UnitOfWork.inst().getListByCond(cls, condition, args)
Пример #11
0
 def getList(cls, entity_ids):
     return UnitOfWork.inst().getList(cls, entity_ids)
Пример #12
0
 def getUnitOfWork(self):
     if not self._unitofwork:
         self._unitofwork = UnitOfWork.inst()
     return self._unitofwork
Пример #13
0
 def getListByCond(cls, condition, *args, **kwargs):
     return UnitOfWork.inst().getListByCond2(cls, condition, args, **kwargs)
Пример #14
0
 def get(cls, **kwargs):
     return UnitOfWork.inst().get(
         cls, tuple([kwargs.get(key) for key in cls._primary_key]))
Пример #15
0
 def getListByCond(cls, condition='', *args):
     return UnitOfWork.inst().getListByCond(cls, condition, args)
Пример #16
0
 def getList(cls, entity_ids):
     return UnitOfWork.inst().getList(cls, entity_ids)