Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Define the SessionStore inside __init__ instead of process_request

It's unnecessary to run this on every request, since technically, settings *should be* immutable.
  • Loading branch information...
commit 5ff2ffa3304b2e49e17257575327f9fc08ce227e 1 parent 64cdea6
@mattrobenolt mattrobenolt authored aaugustin committed
Showing with 5 additions and 2 deletions.
  1. +5 −2 django/contrib/sessions/middleware.py
View
7 django/contrib/sessions/middleware.py
@@ -6,10 +6,13 @@
from django.utils.importlib import import_module
class SessionMiddleware(object):
- def process_request(self, request):
+ def __init__(self):
engine = import_module(settings.SESSION_ENGINE)
+ self.SessionStore = engine.SessionStore
+
+ def process_request(self, request):
session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)
- request.session = engine.SessionStore(session_key)
+ request.session = self.SessionStore(session_key)
def process_response(self, request, response):
"""
Please sign in to comment.
Something went wrong with that request. Please try again.