X-Git-Url: http://git.veekun.com/zzz-pokedex.git/blobdiff_plain/4d6dcb7d51de6582aea821e5bb2e438fa8f0376c..e61d2b2c191e590a4d60c529eca0b717be9b1a33:/pokedex/db/tables.py diff --git a/pokedex/db/tables.py b/pokedex/db/tables.py index d1404ca..2278cb0 100644 --- a/pokedex/db/tables.py +++ b/pokedex/db/tables.py @@ -25,7 +25,7 @@ import collections from functools import partial from sqlalchemy import Column, ForeignKey, MetaData, PrimaryKeyConstraint, Table, UniqueConstraint -from sqlalchemy.ext.declarative import declarative_base +from sqlalchemy.ext.declarative import declarative_base, DeclarativeMeta from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.orm import backref, relation from sqlalchemy.orm.session import Session @@ -60,8 +60,16 @@ class TableSuperclass(object): def __str__(self): return unicode(self).encode('utf8') +mapped_classes = [] +class TableMetaclass(DeclarativeMeta): + def __init__(cls, name, bases, attrs): + super(TableMetaclass, cls).__init__(name, bases, attrs) + if hasattr(cls, '__tablename__'): + mapped_classes.append(cls) + cls.translation_classes = [] + metadata = MetaData() -TableBase = declarative_base(metadata=metadata, cls=TableSuperclass) +TableBase = declarative_base(metadata=metadata, cls=TableSuperclass, metaclass=TableMetaclass) ### Need Language first, to create the partial() below @@ -871,7 +879,7 @@ class MoveMetaCategory(TableBase): create_translation_table('move_meta_category_prose', MoveMetaCategory, 'prose', relation_lazy='joined', description = Column(Unicode(64), nullable=False, - info=dict(description="A description of the category")), + info=dict(description="A description of the category", format="plaintext", official=False)), ) class MoveMetaStatChange(TableBase):