Permalink
Browse files

Fixed #4338 -- Added pop() method to SessionWrapper. Thanks, Gary Wil…

…son.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5306 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent fd21702 commit 4c5311614471869dc7e820978c77a7d9c3b36afc @malcolmt malcolmt committed May 21, 2007
Showing with 22 additions and 0 deletions.
  1. +3 −0 django/contrib/sessions/middleware.py
  2. +19 −0 django/contrib/sessions/tests.py
View
3 django/contrib/sessions/middleware.py
@@ -36,6 +36,9 @@ def items(self):
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
19 django/contrib/sessions/tests.py
@@ -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()

0 comments on commit 4c53116

Please sign in to comment.