On Friday 13 April 2007 21:20:18 Michael Bayer wrote: > On Apr 13, 2007, at 12:51 PM, [EMAIL PROTECTED] wrote: > > haven't thought yet of where/how to hack this... > > i may have to abandon *-to-many-relations() alltogether, as i > > don't want/need them loaded - only filtered at view-time. > > or can i make some super- (or sub-) relation thing > > (propertyLoader?) that does the above? > > I currently do it using a property that returns a Query object, > which works very well. the extra method "with_parent()" i want to > add to Query would make it easier to implement also. > > > class MyClass(object): > def _get_children(self): > return object_session(self).query > (SomeChildClass).with_parent(self) > children = property(_get_children) > > > then: > > m = session.query(MyClass).get(1) > somechildren = m.children[3:5] > someotherchildren = m.children.filter_by(foo='bar').filter_by > (x==y).list() > hm, that seems like a way... more or less what i've done so far, on a different level though - i have done it completely separate.
how to avoid loading the whole thing at any time? or there is no relation() as such? with_parent assumes some relation. and how to add new links - manualy? or append to the otherside? then how to re-sync the list - items can be added on other machines/ threads...? i want to somehow bundle these (read/write aspects) in one thing, e.g. called "specialized_relation", and not having to separately think about intermediate objects/queries etc. It's like a more specialized "instance" of current (class-wide) relation() definition. e.g. something that is created off obj.class.some_relation, and it's obj.id (and other subfilters). The whole-relation thing is like a "class", and the subfiltered thing is like an "instance". --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---