Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Malcolm Tredinnick authored May 21, 2007
3  django/contrib/sessions/middleware.py
@@ -36,6 +36,9 @@ def items(self):
36 36
     def get(self, key, default=None):
37 37
         return self._session.get(key, default)
38 38
 
  39
+    def pop(self, key, *args):
  40
+        return self._session.pop(key, *args)
  41
+
39 42
     def set_test_cookie(self):
40 43
         self[TEST_COOKIE_NAME] = TEST_COOKIE_VALUE
41 44
 
19  django/contrib/sessions/tests.py
... ...
@@ -0,0 +1,19 @@
  1
+r"""
  2
+>>> s = SessionWrapper(None)
  3
+
  4
+Inject data into the session cache.
  5
+>>> s._session_cache = {}
  6
+>>> s._session_cache['some key'] = 'exists'
  7
+
  8
+>>> s.pop('some key')
  9
+'exists'
  10
+
  11
+>>> s.pop('some key', 'does not exist')
  12
+'does not exist'
  13
+"""
  14
+
  15
+from django.contrib.sessions.middleware import SessionWrapper
  16
+
  17
+if __name__ == '__main__':
  18
+    import doctest
  19
+    doctest.testmod()

0 notes on commit 4c53116

Please sign in to comment.
Something went wrong with that request. Please try again.