Ticket #7515: session_clear-with_docs.diff
File session_clear-with_docs.diff, 1.5 KB (added by , 16 years ago) |
---|
-
django/contrib/sessions/tests.py
147 147 >>> list(i) 148 148 [('x', 1)] 149 149 150 # test .clear() 151 >>> s.modified = s.accessed = False 152 >>> s.items() 153 [('x', 1)] 154 >>> s.clear() 155 >>> s.items() 156 [] 157 >>> s.accessed, s.modified 158 (True, True) 150 159 151 160 152 161 ######################### -
django/contrib/sessions/backends/base.py
52 52 self.modified = self.modified or key in self._session 53 53 return self._session.pop(key, *args) 54 54 55 def clear(self): 56 self._session.clear() 57 self.modified = True 58 55 59 def setdefault(self, key, value): 56 60 if key in self._session: 57 61 return self._session[key] -
docs/sessions.txt
106 106 107 107 * ``setdefault()`` (**New in Django development version**) 108 108 109 * ``clear()`` (**New in Django development version**) 110 111 This reliably clears all session data, in result an empty session is 112 saved to the session store. 113 109 114 It also has these methods: 110 115 111 116 * ``set_test_cookie()``