Ticket #3586: automatic_vary.diff
File automatic_vary.diff, 1.4 KB (added by , 18 years ago) |
---|
-
contrib/sessions/middleware.py
10 10 class SessionWrapper(object): 11 11 def __init__(self, session_key): 12 12 self.session_key = session_key 13 self.accessed = False 13 14 self.modified = False 14 15 15 16 def __contains__(self, key): … … 46 47 47 48 def _get_session(self): 48 49 # Lazily loads session from storage. 50 self.accessed = True 49 51 try: 50 52 return self._session_cache 51 53 except AttributeError: … … 72 74 def process_response(self, request, response): 73 75 # If request.session was modified, or if response.session was set, save 74 76 # those changes and set a session cookie. 75 patch_vary_headers(response, ('Cookie',))76 77 try: 78 accessed = request.session.accessed 77 79 modified = request.session.modified 78 80 except AttributeError: 79 81 pass 80 82 else: 83 if accessed: 84 patch_vary_headers(response, ('Cookie',)) 81 85 if modified or settings.SESSION_SAVE_EVERY_REQUEST: 82 86 session_key = request.session.session_key or Session.objects.get_new_session_key() 83 87 if settings.SESSION_EXPIRE_AT_BROWSER_CLOSE: