mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fixed #4729 -- SessionWrapper.pop now sets modified flag if necessary. Thanks, Ben Slavin, SmileyChris and Collin Grady
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5592 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
179f478ffe
commit
f9a592d99d
@ -37,6 +37,7 @@ class SessionWrapper(object):
|
|||||||
return self._session.get(key, default)
|
return self._session.get(key, default)
|
||||||
|
|
||||||
def pop(self, key, *args):
|
def pop(self, key, *args):
|
||||||
|
self.modified = self.modified or key in self._session
|
||||||
return self._session.pop(key, *args)
|
return self._session.pop(key, *args)
|
||||||
|
|
||||||
def set_test_cookie(self):
|
def set_test_cookie(self):
|
||||||
|
@ -5,8 +5,24 @@ Inject data into the session cache.
|
|||||||
>>> s._session_cache = {}
|
>>> s._session_cache = {}
|
||||||
>>> s._session_cache['some key'] = 'exists'
|
>>> s._session_cache['some key'] = 'exists'
|
||||||
|
|
||||||
|
>>> s.accessed
|
||||||
|
False
|
||||||
|
>>> s.modified
|
||||||
|
False
|
||||||
|
|
||||||
|
>>> s.pop('non existant key', 'does not exist')
|
||||||
|
'does not exist'
|
||||||
|
>>> s.accessed
|
||||||
|
True
|
||||||
|
>>> s.modified
|
||||||
|
False
|
||||||
|
|
||||||
>>> s.pop('some key')
|
>>> s.pop('some key')
|
||||||
'exists'
|
'exists'
|
||||||
|
>>> s.accessed
|
||||||
|
True
|
||||||
|
>>> s.modified
|
||||||
|
True
|
||||||
|
|
||||||
>>> s.pop('some key', 'does not exist')
|
>>> s.pop('some key', 'does not exist')
|
||||||
'does not exist'
|
'does not exist'
|
||||||
|
Loading…
Reference in New Issue
Block a user