Re: SQLAlchemy sessions

2006-10-18 Thread Huy
Robert Ian Smit wrote: The session to which an object is attached can be acquired via the object_session() function, Thanks, that's just what I need. I put the following code on top of my model file: from sqlalchemy.orm.session import object_session in my methods I do:

Re: SQLAlchemy sessions

2006-10-18 Thread Robert Ian Smit
in my methods I do: def some_method(self): foo = object_session(self).query(Foo).get(1) You may run into problems if you have unattached objects though. eg. New objects you want to save. I tend to save objects to the session immediately after instantiating so I don't expect

SQLAlchemy sessions

2006-10-17 Thread Robert Ian Smit
I have a buch of controllers that define a __before__ method to attach a session as per the QuickWiki tutorial. Some methods on my mapped model classes require access to the database. I want to flush or discard all updates resulting from a request at the 'bottom' of the controller. I have found

Re: SQLAlchemy sessions

2006-10-17 Thread Shannon -jj Behrens
On 10/17/06, Robert Ian Smit [EMAIL PROTECTED] wrote: I have a buch of controllers that define a __before__ method to attach a session as per the QuickWiki tutorial. Some methods on my mapped model classes require access to the database. I want to flush or discard all updates resulting from

Re: SQLAlchemy sessions

2006-10-17 Thread Robert Ian Smit
How can I create a seperate, 'clean' session for each request? How can I get a reference to this same session from different places in my app? 1. Are you using bound or dynamic meta data? I'm guessing dynamic. DynamicMetaData 2. Can you show me the code you're using to create the

Re: SQLAlchemy sessions

2006-10-17 Thread bruno desthuilliers
Robert Ian Smit a écrit : (snip) Unless calling session.clear() is ill-advised, that leaves my other issue: acquiring the session object without passing it around explicitly as argument in method calls to my mapped models. Is it possible to get the session object from within a mapped