1
0
Fork 0
mirror of https://github.com/veekun/pokedex.git synced 2024-08-20 18:16:34 +00:00

Added a test for the i18n dynamic table generation.

It fails spectacularly, but hopefully documents what I'm ultimately
going for.
This commit is contained in:
Eevee 2011-03-18 18:22:18 -07:00
parent 4645349133
commit 542aa670ae
2 changed files with 112 additions and 4 deletions
pokedex/db

View file

@ -1862,7 +1862,7 @@ VersionGroup.pokedex = relation(Pokedex, back_populates='version_groups')
default_lang = u'en'
def makeTextTable(foreign_table_class, table_suffix_plural, table_suffix_singular, columns, lazy):
def makeTextTable(foreign_table_class, table_suffix_plural, table_suffix_singular, columns, lazy, Language=Language):
# With "Language", we'd have two language_id. So, rename one to 'lang'
foreign_key_name = foreign_table_class.__singlename__
if foreign_key_name == 'language':
@ -1882,7 +1882,7 @@ def makeTextTable(foreign_table_class, table_suffix_plural, table_suffix_singula
# one by one without the DB complaining about missing values
column.default = ColumnDefault(u'')
table = Table(table_name, metadata,
table = Table(table_name, foreign_table_class.__table__.metadata,
Column(foreign_key_name + '_id', Integer, ForeignKey(foreign_table_class.id),
primary_key=True, nullable=False),
Column('language_id', Integer, ForeignKey(Language.id),
@ -1899,7 +1899,7 @@ def makeTextTable(foreign_table_class, table_suffix_plural, table_suffix_singula
foreign_key_name: relation(foreign_table_class,
primaryjoin=(foreign_table_class.id == table.c[foreign_key_name + "_id"]),
backref=backref(table_suffix_plural,
collection_class=attribute_mapped_collection('language'),
collection_class=attribute_mapped_collection('_language_identifier'),
lazy=lazy,
),
),