[sqlalchemy] Reloading attributes on expired objects

2010-04-05 Thread John Huang
Hi, I recently upgraded my system from SA 0.3.11 to 0.5.8, and I found that the behaviour for expiring instances has changed in terms of how much data gets retrieved upon attribute access. For instance, # One User can have many groups mapper(User, user_tbl, properties={'groups':relation(Group,

Re: [sqlalchemy] Reloading attributes on expired objects

2010-04-05 Thread Michael Bayer
John Huang wrote: Hi, I recently upgraded my system from SA 0.3.11 to 0.5.8, and I found that the behaviour for expiring instances has changed in terms of how much data gets retrieved upon attribute access. For instance, # One User can have many groups mapper(User, user_tbl,

[sqlalchemy] Re: Reloading attributes on expired objects

2010-04-05 Thread John Huang
Michael, Thanks for the quick response. On Apr 5, 12:39 pm, Michael Bayer mike...@zzzcomputing.com wrote: you can certainly expire specific attributes by passing a list of their names to expire: sess.expire(inst, ['foo', 'bar', 'bat']) in modern versions of SQLAlchemy calling

Re: [sqlalchemy] Re: Reloading attributes on expired objects

2010-04-05 Thread Michael Bayer
John Huang wrote: Now I understand that refresh will cause a reload of all attributes based the primary mapper. However, the reason that I want to use expire instead of refresh is because there may be places in my code where the same object will be expired multiple times before an attribute

Re: [sqlalchemy] Re: Reloading attributes on expired objects

2010-04-05 Thread Michael Bayer
Michael Bayer wrote: John Huang wrote: Now I understand that refresh will cause a reload of all attributes based the primary mapper. However, the reason that I want to use expire instead of refresh is because there may be places in my code where the same object will be expired multiple times

[sqlalchemy] Re: Reloading attributes on expired objects

2010-04-05 Thread John Huang
Thanks for your help and insight, Michael! For now, since my program was using SA 0.3, it only deals with instance-wide expiration, so for now I have just wrapped the AttributeImpl.get method to do a full refresh of the instance if its state is expired. On Apr 5, 3:47 pm, Michael Bayer

[sqlalchemy] Can I log queries from where they're created?

2010-04-05 Thread Jason Baker
Here's what I'd like to do. Suppose I have some class Foo in some_module.py: class Foo(Entity): def all_foos(self): return self.session.query(Foo).all() ...sqlalchemy by default will log this to sqlalchemy.engine. However, this makes it a bit difficult to narrow down

Re: [sqlalchemy] Can I log queries from where they're created?

2010-04-05 Thread Michael Bayer
Jason Baker wrote: Here's what I'd like to do. Suppose I have some class Foo in some_module.py: class Foo(Entity): def all_foos(self): return self.session.query(Foo).all() ...sqlalchemy by default will log this to sqlalchemy.engine. However, this makes it a bit