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:
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
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
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
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
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