A simple problem. Multi-language support.
Say I have content which can have a title in different languages. So I have a
content = Table('content', engine,
Column('id', Integer, Sequence('content_seq'), primary_key=True))
so I also have a
lang = Table('lang', engine,
Column('id', Integer, Sequence('lang_seq'), primary_key=True),
Column('name', String(255))
this contains things like VALUES('de') etc.
lang_str = Table('lang_str', engine,
Column('lang_id', Integer, ForeignKey('lang.id')),
Column('content_id', Integer, ForeignKey('content.id')),
Column('value', String(2048)))
The problem is with the mapper and the relation to the title.
class Content(object): pass
contents = mapper(Content, content)
contents.add_property('title', ...?
etc. now the two questions.
a) How do I make a relation that gives me the lang_str.value as it's value so
I do not have to write somecontent.title.value
b) How do I make the relation "customizable", i.e. I do not have to do many
relations for each language I want support for (no mycontent.title_de.value,
mycontent.title_en.value etc.?
I do know how to customize for a fixed value via the secondaryjoin of relation,
but I'm uncliear how I can parametrize this. (for that matter, I could of
course write a member to my class who does this, but then I loose eager-loading
for titles...)
Cheers,
Florian
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users