Re: [sqlalchemy] recommended declarative method design pattern for sessions

2010-03-27 Thread Daniel Robbins
On Mar 23, 2010, at 9:29 AM, King Simon-NFHD78 wrote: object_session does indeed return the session that the instance is already bound to (so you shouldn't close it). I didn't know what object_session would return if the original session had been closed, so I tried it: Thanks for looking into

RE: [sqlalchemy] recommended declarative method design pattern for sessions

2010-03-22 Thread King Simon-NFHD78
Daniel Robbins wrote: Hi All, One of the things that doesn't seem to be covered in the docs, and that I'm currently trying to figure out, is the recommended design pattern to use for managing sessions from declarative methods calls. Consider a declarative class User, where I want to

Re: [sqlalchemy] recommended declarative method design pattern for sessions

2010-03-22 Thread Daniel Robbins
On Mar 22, 2010, at 5:10 AM, King Simon-NFHD78 wrote: See the 'How can I get the Session for a certain object' question at http://www.sqlalchemy.org/docs/session.html#frequently-asked-questions Basically, in your FindFriends method, replace: session = Session() with: session =