Esempio n. 1
0
 def __init__(self, db, entity=Group):
     RecordStore.__init__(
         self,
         db,
         entity,
         name='groups',
         key='id'
         )
Esempio n. 2
0
 def __init__(self, db, entity=Member):
     RecordStore.__init__(
         self,
         db,
         entity,
         name='members',
         key='id'
         )
Esempio n. 3
0
 def __init__(self, db):
     RecordStore.__init__(
         self,
         db,
         UserRecord,
         name='dz_users',
         key='userid'
         )
Esempio n. 4
0
 def __init__(self, db, entity=User):
     RecordStore.__init__(
         self,
         db,
         entity,
         name='users',
         key='id'
         )
Esempio n. 5
0
 def __init__(self, db, entity=UserRecord):
     RecordStore.__init__(
         self,
         db,
         entity,
         name='dz_users',
         key='userid'
         )
Esempio n. 6
0
    def table(self, name, limit='6'):
        db = self.model.site.db
        items = RecordStore(db, MyModel, name=name)
        if len(items) == 1:
            footer_name = 'record'
        else:
            footer_name = 'records'
        footer = len(items) and '%s %s' % (len(items), footer_name) or ''

        # If there is an id column we will use it to select the last N items,
        # otherwise we'll just select the whole thing and then take what we
        # want from the list.
        columns = db.get_column_names(name)
        limit = int(limit)
        data = 'id' in columns and items[-limit:] or list(items)[-limit:]

        content = browse(data, footer=footer, title='Sample Data')

        if name in db.get_tables():
            content += browse(db('describe ' + name), title='Structure')

        if name in db.get_tables():
            content += browse(db('show index from ' + name), title='Index')

        database = db.database.name
        if database:
            content += browse(db(
                'show table status in {} where name=%s'.format(database),
                name),
                              title='Metadata')

        return page(content, title='Record: ' + name)
Esempio n. 7
0
    def table(self, name, limit='50'):
        db = self.model.site.db
        items = RecordStore(db, MyModel, name=name)
        if len(items) == 1:
            footer_name = 'record'
        else:
            footer_name = 'records'
        footer = len(items) and '%s %s' % (len(items), footer_name) or ''

        # If there is an id column we will use it to select the first N items,
        # otherwise we'll just select the whole thing and then take what we
        # want from the list.
        columns = db.get_column_names(name)
        limit = int(limit)
        data = 'id' in columns and items[:limit] or list(items)[:limit]

        return page(browse(data, footer=footer), title='Record: ' + name)
Esempio n. 8
0
 def __init__(self, db):
     RecordStore.__init__(self, db, User)
Esempio n. 9
0
 def get_record_store(self):
     return RecordStore(self.db, Person)
Esempio n. 10
0
 def get_record_store(self):
     return RecordStore(self.db, Person, name=self.name, key=self.key)
Esempio n. 11
0
 def test_kind(self):
     self.assertEqual(self.people.kind, 'person')
     self.assertEqual(RecordStore(self.db, TestPerson).kind, 'test_person')
Esempio n. 12
0
 def __init__(self, db):
     RecordStore.__init__(self, db, GroupStore, name='dz_groups', key='groupid')