On Jan 24, 2010, at 8:02 AM, werner wrote: > I am nearly there, at least I think so. > > 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', > backref=sao.backref('countries_b', lazy='dynamic')) > > ct = session.query(db.Country_B) > > for x in ct: > try: > xy = > x.country.filter(db.Country_T.lang_code5==db.getCurrentUserLang()).one() > print 'pref: %s' % xy > print xy.name > except db.sao.exc.NoResultFound: > try: > print 'def: %s' % > x.country.filter(db.Country_T.lang_code5==db.getDefaultUserLang()).one() > except db.sao.exc.NoResultFound: > print 'no translation found' > > Now, if I could put this try/except block into the mapper that would be just > perfect. > > Is this possible? If not what else could be done?
have you considered http://www.sqlalchemy.org/docs/mappers.html#building-query-enabled-properties ? > > 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. > -- 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.