1
0
mirror of https://github.com/django/django.git synced 2024-12-23 17:46:27 +00:00

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:
Malcolm Tredinnick 2007-05-21 04:03:53 +00:00
parent fd21702b2e
commit 4c53116144
2 changed files with 22 additions and 0 deletions

View File

@ -36,6 +36,9 @@ class SessionWrapper(object):
def get(self, key, default=None):
return self._session.get(key, default)
def pop(self, key, *args):
return self._session.pop(key, *args)
def set_test_cookie(self):
self[TEST_COOKIE_NAME] = TEST_COOKIE_VALUE

View File

@ -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()