GHZ wrote: > Hi, > > I have a Subscriber and an Address table. Subscriber can have many > Addresses > > > mapper(Subscriber, subscriber_table, properties={ > 'addresses' : relation(Address, collection_class=Addresses, > backref='customer')}) > > From the a Subscriber object, I want to inspect all loaded objects in > any collections, but do it quietly - without causing any more to load. > > > class MyBase(object): > > @reconstructor > def __my_init__(self): > self.rules = [] > > def get_all_rules_on_all_loaded_related_objects(self): > for collection in (p for p in object_mapper > (self).iterate_properties if type(p) is RelationProperty): > # How to access this collection without causing it to > load? > # I want to look at the 'rules' property on all loaded > objects
The collection will be present in the instance's __dict__ if it has been loaded. So something like if 'addresses' in self.__dict__: # loaded, can access self.addresses without triggering db access -j --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---