Home | Trees | Index | Help |
|
---|
Package aquarium :: Package session :: Module SessionContainer :: Class SessionContainer |
|
DatabaseSessionContainer
This is a container for sessions.
A container class is needed because:
On the other hand, no instance state is kept, so one instance of this class is just as good as another. All state is kept in the class. I'd use a singleton, but the version of Python I'm stuck with doesn't have class methods.
Concerning locking: in general, a global lock (of some sort) should be used so that creating, deleting, reading, and writing sessions is serialized. However, it is not necessary to have a lock for each session. If a user wishes to use two browser windows at the same time, the last writer wins.
Concerning aquarium.util.AquariumClass: this class does not subclass aquarium.util.AquariumClass and does not require a ctx parameter in its constructor. Subclasses may choose to mixin aquarium.util.AquariumClass as necessary, but they will then require a ctx in their constructors. aquarium.util.Aquarium is aware of this.
This base class is useful for mutlithreaded environments. For other environments, such as CGI, it simply provides an API.
The following class level constants are defined:
These are needed since not all "mutexes" provide the same API, unfortunately:
The following protected class variables are used:
Method Summary | |
---|---|
Adjust all of the lastModified keys. | |
Delete all of the expired sessions. | |
Create or open a session. |
Class Variable Summary | |
---|---|
int |
SID_LENGTH = 20 |
Method Details |
---|
adjustTime(self, deltaSeconds)Adjust all of the lastModified keys. If you have to change the time, do this: sessionContainer._acquire() try: changeTime() sessionContainer.adjustTime(deltaSeconds) finally: sessionContainer._release() You have to manage the lock yourself, otherwise changing the time might cause some sessions to get deleted before we can update them. |
cleanup(self)Delete all of the expired sessions. It's the application's responsibility to occasionally call this. |
open(self, sid=None)Create or open a session.
Return the session. |
Class Variable Details |
---|
SID_LENGTH
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon Jan 1 16:34:19 2007 | http://epydoc.sf.net |