Beispiel #1
0
    def create_entity(uid='', path='', desc='', kind='1'):
        '''
        create entity record in the database.
        '''

        if path:
            pass
        else:
            return False

        if uid:
            pass
        else:
            uid = get_uuid()
        try:
            TabEntity.create(
                uid=uid,
                path=path,
                desc=desc,
                time_create=time.time(),
                kind=kind
            )
            return True
        except:
            return False
Beispiel #2
0
    def delete_by_path(path, kind='f'):
        '''
        '''
        delete = TabEntity.delete().where((TabEntity.path == path)
                                          & (TabEntity.kind == kind))

        delete.execute()
Beispiel #3
0
 def get_by_kind(kind=1, current_page_num=1):
     return TabEntity.select().where(
         TabEntity.kind == kind
     ).paginate(
         current_page_num,
         CMS_CFG['list_num']
     )
Beispiel #4
0
    def create_entity(signature, impath, kind='1'):
        '''
        create entity record in the database.
        :param signature:
        :param impath:
        :param kind:
        :return:
        '''
        if len(impath) == 0:
            return False

        try:
            TabEntity.create(
                uid=signature,
                path=impath,
                time_create=time.time(),
                kind=kind
            )
            return True
        except:
            return False
Beispiel #5
0
    def get_id_by_impath(path):
        logger.info('Get Entiry, Path: {0}'.format(path))

        entity_list = TabEntity.select().where(TabEntity.path == path)
        if entity_list.count() == 1:
            return entity_list.get().uid
        elif entity_list.count() > 1:
            for rec in entity_list:
                MEntity.delete(rec.uid)
            return False
        else:
            return False
Beispiel #6
0
    def get_id_by_impath(path):
        '''
        The the entity id by the path.
        '''
        logger.info('Get Entiry, Path: {0}'.format(path))

        entity_list = TabEntity.select().where(TabEntity.path == path)
        out_val = None
        if entity_list.count() == 1:
            out_val = entity_list.get()
        elif entity_list.count() > 1:
            for rec in entity_list:
                MEntity.delete(rec.uid)
            out_val = None
        else:
            pass
        return out_val
Beispiel #7
0
 def total_number():
     '''
     Total number.
     '''
     # adding ``None`` to hide ``No value for argument 'database' in method call``
     return TabEntity.select().count(None)
Beispiel #8
0
 def get_all_pager(current_page_num=1):
     return TabEntity.select().paginate(current_page_num,
                                        CMS_CFG['list_num'])
Beispiel #9
0
 def query_all(limit=20):
     '''
     Return the entities list.
     '''
     return TabEntity.select().limit(limit)
Beispiel #10
0
 def total_number():
     return TabEntity.select().count()
Beispiel #11
0
 def query_all(limit=20):
     return TabEntity.select().limit(limit)