PageRenderTime 52ms CodeModel.GetById 30ms app.highlight 2ms RepoModel.GetById 18ms app.codeStats 0ms

/tests/regressiontests/test_client_regress/session.py

https://code.google.com/p/mango-py/
Python | 30 lines | 18 code | 6 blank | 6 comment | 0 complexity | 013affa23508c7038c158c249c079d3d MD5 | raw file
 1from django.contrib.sessions.backends.base import SessionBase
 2
 3class 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 {}