I am reading up on 0.6 and came across dynamic_loader.
I wonder if the filter could be set within the model.
e.g. something along these lines
mapper(User, users_table, properties={
'posts': dynamic_loader(Post). filter(Post.headline=='this is a post')
})
I am actually still looking for a nice solution/recipe to handle I18N
content in the database, so was wondering if I could do something like this.
class Country_T(Base):
__table__ = sa.Table(u'countries_t', metadata,
sa.Column(u'id', sa.Integer(), sa.Sequence('countries_t_id'),
primary_key=True, nullable=False),
sa.Column(u'lang_code5', sa.String(length=5,
convert_unicode=False), sa.ForeignKey(u'languages.code5')),
sa.Column(u'name', sa.String(length=50, convert_unicode=False)),
sa.Column(u'countries_b_id', sa.Integer(),
sa.ForeignKey(u'countries_b.id')),
)
class Country_B(Base):
__table__ = sa.Table(u'countries_b', metadata,
sa.Column(u'id', sa.Integer(), sa.Sequence('countries_b_id'),
primary_key=True, nullable=False),
sa.Column(u'iso2', sa.String(length=2, convert_unicode=False)),
sa.Column(u'iso3', sa.String(length=3, convert_unicode=False)),
)
country = sao.dynamic_loader('Country_T',
filter('Country_T.lang_code5', getCurrentUserLang))
"country" relation above should return the row from country_t which
corresponds to the user requested language.
Ideally I like to have a way to have it "fall back" to a default language.
Has anyone a recipe on how to do something like this? I am aware of
Karsten Hilbert's solution which is "gettext" based using stored
procedures, I like to find a solution which does not require stored
procedures.
Thanks in advance for any hints, tips or sample code.
Werner
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.