Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #4729 -- Restored functionality to the Session class so that po…

…pping a

value marks it as modified. This was accidentally lost in the changes in
[6333]. Thanks, __hawkeye__.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6558 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4c0d8d882d1796b08c51eb6930de1327311a0f1d 1 parent 4362d15
Malcolm Tredinnick malcolmt authored
1  django/contrib/sessions/backends/base.py
View
@@ -48,6 +48,7 @@ def get(self, key, default=None):
return self._session.get(key, default)
def pop(self, key, *args):
+ self.modified = self.modified or key in self._session
return self._session.pop(key, *args)
def set_test_cookie(self):
23 django/contrib/sessions/tests.py
View
@@ -3,6 +3,7 @@
>>> from django.contrib.sessions.backends.db import SessionStore as DatabaseSession
>>> from django.contrib.sessions.backends.cache import SessionStore as CacheSession
>>> from django.contrib.sessions.backends.file import SessionStore as FileSession
+>>> from django.contrib.sessions.backends.base import SessionBase
>>> db_session = DatabaseSession()
>>> db_session.modified
@@ -52,6 +53,28 @@
>>> cache_session.delete(cache_session.session_key)
>>> cache_session.exists(cache_session.session_key)
False
+
+>>> s = SessionBase()
+>>> s._session['some key'] = 'exists' # Pre-populate the session with some data
+>>> s.accessed = False # Reset to pretend this wasn't accessed previously
+
+>>> s.accessed, s.modified
+(False, False)
+
+>>> s.pop('non existant key', 'does not exist')
+'does not exist'
+>>> s.accessed, s.modified
+(True, False)
+
+>>> s.accessed = False # Reset the accessed flag
+
+>>> s.pop('some key')
+'exists'
+>>> s.accessed, s.modified
+(True, True)
+
+>>> s.pop('some key', 'does not exist')
+'does not exist'
"""
if __name__ == '__main__':
Please sign in to comment.
Something went wrong with that request. Please try again.