예제 #1
0
 def __init__(cls, classname, bases, dict_):
     if '__tablename__' in dict_:
         cls.id = sa.Column('id',
                            sa.Integer,
                            primary_key=True,
                            autoincrement=True)
         cls._created = sa.Column('_created',
                                  types.DateTime(True),
                                  default=sa.func.now())
         cls._last_updated = sa.Column('_last_updated',
                                       types.DateTime(True),
                                       default=sa.func.now(),
                                       onupdate=sa.func.now())
         cls.__mapper_args__ = {'extension': HistoryExtension()}
     super(MapperBase, cls).__init__(classname, bases, dict_)
예제 #2
0
파일: db.py 프로젝트: RoDuth/bauble.classic
    def __init__(cls, classname, bases, dict_):
        if '__tablename__' in dict_:
            cls.id = sa.Column('id',
                               sa.Integer,
                               primary_key=True,
                               autoincrement=True)
            cls._created = sa.Column('_created',
                                     types.DateTime(True),
                                     default=sa.func.now())
            cls._last_updated = sa.Column('_last_updated',
                                          types.DateTime(True),
                                          default=sa.func.now(),
                                          onupdate=sa.func.now())
            cls.__mapper_args__ = {'extension': HistoryExtension()}
        if 'top_level_count' not in dict_:
            cls.top_level_count = lambda x: {classname: 1}
        if 'search_view_markup_pair' not in dict_:
            cls.search_view_markup_pair = lambda x: (utils.xml_safe(str(x)),
                                                     '(%s)' % type(x).__name__)

        super(MapperBase, cls).__init__(classname, bases, dict_)