Skip to content

Commit

Permalink
django 2.0 compatibility in test project
Browse files Browse the repository at this point in the history
  • Loading branch information
miki725 committed Jul 26, 2018
1 parent 8769802 commit 6bf1a7e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions test_project/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@


class SQLAlchemySessionMiddleware(object):
def process_request(self, request):
request.alchemy_session = Session()
def __init__(self, get_response):
self.get_response = get_response

def process_response(self, request, response):
request.alchemy_session.close()
return response
def __call__(self, request):
request.alchemy_session = Session()
try:
return self.get_response(request)
finally:
request.alchemy_session.close()
2 changes: 1 addition & 1 deletion test_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
STATIC_URL = '/static/'
SECRET_KEY = 'foo'

MIDDLEWARE_CLASSES = [
MIDDLEWARE = [
'test_project.middleware.SQLAlchemySessionMiddleware',
]

Expand Down

0 comments on commit 6bf1a7e

Please sign in to comment.