Ticket #5513: sessions_speedup_6364.2.diff
File sessions_speedup_6364.2.diff, 1.6 KB (added by , 17 years ago) |
---|
-
django/contrib/sessions/middleware.py
4 4 import datetime 5 5 import time 6 6 7 engine = __import__(settings.SESSION_ENGINE, {}, {}, ['']) 8 7 9 TEST_COOKIE_NAME = 'testcookie' 8 10 TEST_COOKIE_VALUE = 'worked' 9 11 10 12 class SessionMiddleware(object): 11 13 12 14 def process_request(self, request): 13 engine = __import__(settings.SESSION_ENGINE, {}, {}, [''])15 global engine 14 16 request.session = engine.SessionStore(request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)) 15 17 16 18 def process_response(self, request, response): -
django/contrib/sessions/backends/base.py
104 104 def _get_session(self): 105 105 # Lazily loads session from storage. 106 106 self.accessed = True 107 try:107 if hasattr(self, '_session_cache'): 108 108 return self._session_cache 109 except AttributeError: 110 if self.session_key is None: 111 self._session_cache = {} 112 else: 113 self._session_cache = self.load() 109 if self._session_key is None: 110 self._session_cache = {} 111 else: 112 self._session_cache = self.load() 114 113 return self._session_cache 115 114 116 115 _session = property(_get_session)