Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 4c5311614471869dc7e820978c77a7d9c3b36afc 1 parent fd21702
@malcolmt malcolmt authored
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()
Please sign in to comment.
Something went wrong with that request. Please try again.