Martijn Faassen wrote: > > Hey, > > Michael Bayer wrote: >> subclass RelationProperty fine, but don't get involved with overriding >> its >> internal _xxx methods. > > So: > > Override do_init() completely (not calling the super do_init()).
no, call do_init(). def do_init(self): self.primaryjoin = figure_out_my_primary_join() super(RelationProperty, self).do_init() > > Problem: the backref will already have been set up, and this will not > get the custom arguments. the backref you can roll without using backref(). set up your custom relation() on the other side and then establish the two-way communication using the "back_populates" argument on both relations. http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/test/orm/test_relationships.py#L803 is an example. > > It's pretty involved, ugly, and fragile. It'd be nicer if there was a > way to do this generically, as I just want to add a custom condition to > the automatically set up primary... I *really* try to avoid adding new arguments and flags as quick solutions to single-user use cases, unless there is truly no other way to accomplish the desired goal. the "back_populates" argument is an example of opening up the mechanics of "backref" in a more generalized way. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@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 -~----------~----~----~----~------~----~------~--~---