Skip to content

Commit

Permalink
[#3229] Dispose of the SQLAlchemy session after each request
Browse files Browse the repository at this point in the history
This was also done on the Pylons BaseController, and it's necessary to
avoid the dreaded DetachedInstanceError during tests
  • Loading branch information
amercader committed Sep 6, 2016
1 parent 53c4a2d commit 9cdbca6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ckan/config/middleware/flask_app.py
Expand Up @@ -20,6 +20,7 @@
from paste.deploy.converters import asbool
from fanstatic import Fanstatic

import ckan.model as model
from ckan.lib import helpers
from ckan.lib import jinja_extensions
from ckan.common import config, g, request, ungettext
Expand Down Expand Up @@ -127,6 +128,10 @@ def ckan_before_request():

@app.after_request
def ckan_after_request(response):

# Dispose of the SQLALchemy session
model.Session.remove()

# Check session cookie
response = check_session_cookie(response)

Expand Down

0 comments on commit 9cdbca6

Please sign in to comment.