diff options
| author | Matt Robenolt <matt@ydekproductions.com> | 2013-06-29 23:26:10 -0700 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-06-30 09:43:02 +0200 |
| commit | 5ff2ffa3304b2e49e17257575327f9fc08ce227e (patch) | |
| tree | 05f1660222665a861368b2de789db74eec52d572 | |
| parent | 64cdea68e71829905da6374a066d1700375255ec (diff) | |
Define the SessionStore inside __init__ instead of process_request
It's unnecessary to run this on every request, since technically, settings *should be* immutable.
| -rw-r--r-- | django/contrib/sessions/middleware.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/django/contrib/sessions/middleware.py b/django/contrib/sessions/middleware.py index 9f65255f47..8bc2d37dd3 100644 --- a/django/contrib/sessions/middleware.py +++ b/django/contrib/sessions/middleware.py @@ -6,10 +6,13 @@ from django.utils.http import cookie_date 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): """ |
