jason kirtland wrote: > On Wed, Apr 28, 2010 at 7:52 AM, Chris Withers <ch...@simplistix.co.uk> > wrote: >> Diana Clarke wrote: >>> >>> Finally, we're using pylons and are removing the contextual session in >>> the >>> finally clause of the base controller's __call__ method. >>> >>> class BaseController(WSGIController): >>> >>> def __call__(self, environ, start_response): >>> try: >>> ... >>> finally: >>> session.remove() >> >> Yeah, I'm trying to find out if this .remove() is actually necessary. > > .remove() as the final operation in a request ensures that no session > state leaks from one web request to another. The next request in that > thread or scoping context will get an entirely fresh session to work > with. > > If finishing with a .remove() is a big deal in your environment, which > it seems like it is, you could do a .remove() at the start of the > request instead.
You really don't need the "remove()" if you have definitely called commit() or rollback() last, and you have expire_on_commit=True. In most cases the session will be empty on the next request. > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.