root/software/session2/trunk/session2/store/VolatileSessionStore.py

Revision 9, 1.1 kB (checked in by t, 12 years ago)

transferred from

svn://cafepy.com:13690/

Line 
1 """
2 A simple in-memory volatile session store, mimicking the default
3 Quixote session management.  Here for example's sake only...
4 """
5
6 from SessionStore import SessionStore
7
8 class VolatileSessionStore(SessionStore):
9     """
10     A simple volatile (non-persistent) session store for session2.
11     """
12     is_multiprocess_safe = True
13     is_thread_safe = True
14
15     def __init__(self):
16         """Create the dictionary."""
17         self.sessions = {}
18    
19     def load_session(self, id, default=None):
20         """Return the session if it exists, else return 'default'."""
21         return self.sessions.get(id, default)
22
23     def save_session(self, session):
24         """Save the session in the dictionary.."""
25         self.sessions[session.id] = session
26
27     def delete_session(self, session):
28         """Delete the session in the dictionary."""
29         if self.sessions.has_key(session.id):
30             del self.sessions[session.id]
31
32     def has_session(self, id):
33         """Return true if the session exists in the dictionary, else false."""
34         return self.sessions.has_key(id)
Note: See TracBrowser for help on using the browser.