X-Git-Url: http://git.veekun.com/zzz-pokedex.git/blobdiff_plain/c1ba23b0c45a0873cd27456c0950c7f4f3253fe4..06545f5b48416ba0507d26499db2d57d6d69e13b:/pokedex/db/multilang.py diff --git a/pokedex/db/multilang.py b/pokedex/db/multilang.py index f3438dd..b5f87e4 100644 --- a/pokedex/db/multilang.py +++ b/pokedex/db/multilang.py @@ -77,9 +77,11 @@ def create_translation_table(_table_name, foreign_class, relation_name, # Create the table object table = Table(_table_name, foreign_class.__table__.metadata, Column(foreign_key_name, Integer, ForeignKey(foreign_class.id), - primary_key=True, nullable=False), + primary_key=True, nullable=False, + info=dict(description="ID of the %s these texts relate to" % foreign_class.__singlename__)), Column('local_language_id', Integer, ForeignKey(language_class.id), - primary_key=True, nullable=False), + primary_key=True, nullable=False, + info=dict(description="Language these texts are in")), ) Translations.__table__ = table @@ -145,6 +147,9 @@ def create_translation_table(_table_name, foreign_class, relation_name, setattr(foreign_class, name + '_map', association_proxy(relation_name, name, creator=creator)) + # Add to the list of translation classes + foreign_class.translation_classes.append(Translations) + # Done return Translations @@ -154,12 +159,15 @@ class MultilangSession(Session): @property def default_language(self): - # XXX need to get the right mapped class for this to work - raise NotImplementedError + # Need to import tables here to avoid a circular dependency + from pokedex.db import tables + query = self.query(tables.Language) + query = query.filter_by(id=self._default_language_id) + return query.one() @default_language.setter def default_language(self, new): - self._default_language_id = new#.id + self._default_language_id = new.id @default_language.deleter def default_language(self):