Example #1
0
    def __init__(self, user, notification_system, notification_id):
        self.user = user
        self.notification_system = notification_system
        self.notification_id = notification_id

    def __repr__(self):
        return "<%s (%s, %r, %r)>" % (
            self.__class__.__name__,
            self.user,
            self.notification_system,
            self.notification_id
        )


# connect the tables.
db.mapper(SchemaVersion, schema_versions)
db.mapper(User, users, properties={
    'id':               users.c.user_id,
    'display_name':     db.synonym('_display_name', map_column=True),
    'posts':            db.dynamic_loader(Post,
                                          backref=db.backref('author', lazy=True),
                                          query_class=PostQuery,
                                          cascade='all, delete, delete-orphan'),
    'comments':         db.dynamic_loader(Comment,
                                          backref=db.backref('user', lazy=False),
                                          cascade='all, delete'),
    '_own_privileges':  db.relation(_Privilege, lazy=True,
                                    secondary=user_privileges,
                                    collection_class=set,
                                    cascade='all, delete')
})
Example #2
0
        return u'<%s %r>' % (self.__class__.__name__, self.name)


# connect the tables.
db.mapper(User,
          users,
          properties={
              'id':
              users.c.user_id,
              'display_name':
              db.synonym('_display_name', map_column=True),
              'posts':
              db.dynamic_loader(Post,
                                backref=db.backref('author', lazy=False),
                                query_class=PostQuery,
                                cascade='all, delete, delete-orphan'),
              'comments':
              db.dynamic_loader(Comment,
                                backref=db.backref('user', lazy=False),
                                cascade='all, delete'),
              '_own_privileges':
              db.relation(_Privilege,
                          lazy=True,
                          secondary=user_privileges,
                          collection_class=set,
                          cascade='all, delete')
          })
db.mapper(Group,
          groups,
          properties={
              'id':
Example #3
0
# -*- coding: utf-8 -*-
"""
    zine.plugins.eric_the_fish.databse
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Database tables and objects for the "Annoying fish for the admin panel".

    :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details.
    :license: BSD, see LICENSE for more details.
"""

from zine.database import db, metadata

fortunes = db.Table('eric_the_fish_fortunes', metadata,
    db.Column('id', db.Integer, primary_key=True),
    db.Column('text', db.Text, nullable=False)
)

class Fortune(object):
    query = db.query_property(db.Query)
    def __init__(self, text):
        self.text = text

db.mapper(Fortune, fortunes)