Fixed #4338 -- Added pop() method to SessionWrapper. Thanks, Gary Wilson.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5306 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
fd21702b2e
commit
4c53116144
|
@ -36,6 +36,9 @@ class SessionWrapper(object):
|
||||||
def get(self, key, default=None):
|
def get(self, key, default=None):
|
||||||
return self._session.get(key, default)
|
return self._session.get(key, default)
|
||||||
|
|
||||||
|
def pop(self, key, *args):
|
||||||
|
return self._session.pop(key, *args)
|
||||||
|
|
||||||
def set_test_cookie(self):
|
def set_test_cookie(self):
|
||||||
self[TEST_COOKIE_NAME] = TEST_COOKIE_VALUE
|
self[TEST_COOKIE_NAME] = TEST_COOKIE_VALUE
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
r"""
|
||||||
|
>>> s = SessionWrapper(None)
|
||||||
|
|
||||||
|
Inject data into the session cache.
|
||||||
|
>>> s._session_cache = {}
|
||||||
|
>>> s._session_cache['some key'] = 'exists'
|
||||||
|
|
||||||
|
>>> s.pop('some key')
|
||||||
|
'exists'
|
||||||
|
|
||||||
|
>>> s.pop('some key', 'does not exist')
|
||||||
|
'does not exist'
|
||||||
|
"""
|
||||||
|
|
||||||
|
from django.contrib.sessions.middleware import SessionWrapper
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import doctest
|
||||||
|
doctest.testmod()
|
Loading…
Reference in New Issue