Django

Code

Changeset 6558

Show
Ignore:
Timestamp:
10/20/07 05:12:59 (1 year ago)
Author:
mtredinnick
Message:

Fixed #4729 -- Restored functionality to the Session class so that popping a
value marks it as modified. This was accidentally lost in the changes in
[6333]. Thanks, hawkeye.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/sessions/backends/base.py

    r6388 r6558  
    4949 
    5050    def pop(self, key, *args): 
     51        self.modified = self.modified or key in self._session 
    5152        return self._session.pop(key, *args) 
    5253 
  • django/trunk/django/contrib/sessions/tests.py

    r6333 r6558  
    44>>> from django.contrib.sessions.backends.cache import SessionStore as CacheSession 
    55>>> from django.contrib.sessions.backends.file import SessionStore as FileSession 
     6>>> from django.contrib.sessions.backends.base import SessionBase 
    67 
    78>>> db_session = DatabaseSession() 
     
    5354>>> cache_session.exists(cache_session.session_key) 
    5455False 
     56 
     57>>> s = SessionBase() 
     58>>> s._session['some key'] = 'exists' # Pre-populate the session with some data 
     59>>> s.accessed = False   # Reset to pretend this wasn't accessed previously 
     60 
     61>>> s.accessed, s.modified 
     62(False, False) 
     63 
     64>>> s.pop('non existant key', 'does not exist') 
     65'does not exist' 
     66>>> s.accessed, s.modified 
     67(True, False) 
     68 
     69>>> s.accessed = False  # Reset the accessed flag 
     70 
     71>>> s.pop('some key') 
     72'exists' 
     73>>> s.accessed, s.modified 
     74(True, True) 
     75 
     76>>> s.pop('some key', 'does not exist') 
     77'does not exist' 
    5578""" 
    5679