On Friday, August 9, 2013 11:33:09 AM UTC-4, James Carroll wrote:
> I'm doing the typical > DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) First off -- i could be wrong about this... I'm not very familiar with how the ZopeTransactionExtension works with pyramid_tm and transaction. from what i've seen on the internals , i think it does do a session cleanup ( https://github.com/zopefoundation/zope.sqlalchemy/blob/master/src/zope/sqlalchemy/datamanager.py ) BUT if its not, and if you're just accessing `DBSession`, and not something like `localsession = DBSession()` + `localsession.remove()` , then everything is happening within a single scoped session ( you have no cleanup ) check out this subscriber idiom from the narrative docs : http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/database/sqlalchemy.html#using-a-non-global-session the key points would be: # memoize a new local sqlalchmey session for the request def main(global_config, **settings): config.add_request_method(db, reify=True) # the memoized session has a cleanup; `remove` is technically better than `close` (according to sqlalchemy docs) def db(request): session = models.DBSession() def cleanup(request): session.remove() request.add_finished_callback(cleanup) return session then just access `request.db` instead of the package endpoints -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/groups/opt_out.
