parts/django/tests/regressiontests/test_client_regress/session.py
changeset 307 c6bca38c1cbf
equal deleted inserted replaced
306:5ff1fc726848 307:c6bca38c1cbf
       
     1 from django.contrib.sessions.backends.base import SessionBase
       
     2 
       
     3 class SessionStore(SessionBase):
       
     4     """
       
     5     A simple cookie-based session storage implemenation.
       
     6 
       
     7     The session key is actually the session data, pickled and encoded.
       
     8     This means that saving the session will change the session key.
       
     9     """
       
    10     def __init__(self, session_key=None):
       
    11         super(SessionStore, self).__init__(session_key)
       
    12 
       
    13     def exists(self, session_key):
       
    14         return False
       
    15 
       
    16     def create(self):
       
    17         self.session_key = self.encode({})
       
    18 
       
    19     def save(self, must_create=False):
       
    20         self.session_key = self.encode(self._session)
       
    21 
       
    22     def delete(self, session_key=None):
       
    23         self.session_key = self.encode({})
       
    24 
       
    25     def load(self):
       
    26         try:
       
    27             return self.decode(self.session_key)
       
    28         except:
       
    29             self.modified = True
       
    30             return {}