s = Session.object_session(self) without model code should work with the caveat that it won't if the object isn't part of a session yet.
Also wanted to point out DanielHolth's implementation of this inside of stucco_auth. He stores the session in the environ, sharing it with a custom transaction manager, removing the need for a threadlocal transaction manager. Michael On Tue, Feb 1, 2011 at 10:02 AM, Chris McDonough <[email protected]> wrote: > On Mon, 2011-01-31 at 21:12 -0800, Michael Merickel wrote: > > I wanted to expand on the pyramid_cookbook entry (https://github.com/ > > Pylons/pyramid_cookbook/blob/master/sqla.rst) for using sqlalchemy > > without the scoped_session. > > > > So I created a gist that demonstrates more in-depth how it can be > > setup and used within a project. > > https://gist.github.com/805439 > > > > Any comments or corrections would be greatly appreciated. > > > > It would be useful to also show a sample view using request.db to > complete the picture. It's also necessary sometimes to get at the > session from a model instance sometimes (to perform another query). In > a world without a global way to get a session, rather than always pass > it in, I'm hoping folks can use > > http://www.sqlalchemy.org/docs/orm/session.html#sqlalchemy.orm.session.Session.object_session? > > - C > > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<pylons-discuss%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/pylons-discuss?hl=en. > > -- You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en.
