On 8 Lis, 20:29, Michael Bayer <[email protected]> wrote: > On Nov 7, 2009, at 6:03 PM, Adam Dziendziel wrote: > > What I usually do when i want to ensure what gets cached (since im > usually serializing into memcached), and i dont want to worry what the > particular eager loading configuration is, is to make a method like > "full_load()" which ensures all the important attributes and > collections are present. this will issue lazy loads for anything that > wasn't already loaded: > > def full_load(self): > self.collection1 > self.some_reference > return self > > However, if you are truly eager loading all of those attributes then > this step is unnecessary.
By the way, is this possible to tell SQLAlchemy to load two lazy attributes together, using a single query i.e. like it does with eagerly-loaded attributes, but on demand? If collection1 and some_reference points to different rows in the database, the code: self.collection1 self.some_reference would issue two SELECTs, two round-trips to the database. When I know that I need these two, I would write instead something like: orm.attributes.load(self, ['collection1', 'some_reference']) Regards, Adam --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
