Ticket #5513: sessions_speedup_6364.3.diff

File sessions_speedup_6364.3.diff, 1.7 KB (added by Manuel Saelices, 17 years ago)

Same patch than before but with correct indentation in process_request function

  • django/contrib/sessions/middleware.py

     
    44import datetime
    55import time
    66
     7engine = __import__(settings.SESSION_ENGINE, {}, {}, [''])
     8
    79TEST_COOKIE_NAME = 'testcookie'
    810TEST_COOKIE_VALUE = 'worked'
    911
    1012class SessionMiddleware(object):
    1113
    1214    def process_request(self, request):
    13       engine = __import__(settings.SESSION_ENGINE, {}, {}, [''])
    14       request.session = engine.SessionStore(request.COOKIES.get(settings.SESSION_COOKIE_NAME, None))
     15        global engine
     16        request.session = engine.SessionStore(request.COOKIES.get(settings.SESSION_COOKIE_NAME, None))
    1517
    1618    def process_response(self, request, response):
    1719        # If request.session was modified, or if response.session was set, save
  • django/contrib/sessions/backends/base.py

     
    104104    def _get_session(self):
    105105        # Lazily loads session from storage.
    106106        self.accessed = True
    107         try:
     107        if hasattr(self, '_session_cache'):
    108108            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()
    114113        return self._session_cache
    115114
    116115    _session = property(_get_session)
Back to Top