Ticket #4729: sessionwrapper_pop_modified.3.patch

File sessionwrapper_pop_modified.3.patch, 1.1 KB (added by Chris Beaven, 17 years ago)

with tests

  • django/contrib/sessions/middleware.py

     
    3737        return self._session.get(key, default)
    3838
    3939    def pop(self, key, *args):
     40        self.modified = self.modified or key in self._session
    4041        return self._session.pop(key, *args)
    4142
    4243    def set_test_cookie(self):
  • django/contrib/sessions/tests.py

     
    55>>> s._session_cache = {}
    66>>> s._session_cache['some key'] = 'exists'
    77
     8>>> s.accessed
     9False
     10>>> s.modified
     11False
     12
     13>>> s.pop('non existant key', 'does not exist')
     14'does not exist'
     15>>> s.accessed
     16True
     17>>> s.modified
     18False
     19
    820>>> s.pop('some key')
    921'exists'
     22>>> s.accessed
     23True
     24>>> s.modified
     25True
    1026
    1127>>> s.pop('some key', 'does not exist')
    1228'does not exist'
Back to Top