Ticket #4729: ticket_4729__rev_6447.diff
File ticket_4729__rev_6447.diff, 1.7 KB (added by , 17 years ago) |
---|
-
django/contrib/sessions/tests.py
3 3 >>> from django.contrib.sessions.backends.db import SessionStore as DatabaseSession 4 4 >>> from django.contrib.sessions.backends.cache import SessionStore as CacheSession 5 5 >>> from django.contrib.sessions.backends.file import SessionStore as FileSession 6 >>> from django.contrib.sessions.backends.base import SessionBase 6 7 7 8 >>> db_session = DatabaseSession() 8 9 >>> db_session.modified … … 52 53 >>> cache_session.delete(cache_session.session_key) 53 54 >>> cache_session.exists(cache_session.session_key) 54 55 False 56 57 >>> s = SessionBase() 58 >>> s._session['some key'] = 'exists' # Pre-populate the session with some data 59 >>> s.accessed = False # Reset to pretend this wasn't accessed previously 60 61 >>> s.accessed, s.modified 62 (False, False) 63 64 >>> s.pop('non existant key', 'does not exist') 65 'does not exist' 66 >>> s.accessed, s.modified 67 (True, False) 68 69 >>> s.accessed = False # Reset the accessed flag 70 71 >>> s.pop('some key') 72 'exists' 73 >>> s.accessed, s.modified 74 (True, True) 75 76 >>> s.pop('some key', 'does not exist') 77 'does not exist' 55 78 """ 56 79 57 80 if __name__ == '__main__': -
django/contrib/sessions/backends/base.py
48 48 return self._session.get(key, default) 49 49 50 50 def pop(self, key, *args): 51 self.modified = self.modified or key in self._session 51 52 return self._session.pop(key, *args) 52 53 53 54 def set_test_cookie(self):