Package aquarium :: Package session :: Module DatabaseSessionContainer :: Class DatabaseSessionContainer
[show private | hide private]
[frames | no frames]

Class DatabaseSessionContainer

   AquariumClass --+
                   |
SessionContainer --+
                   |
                  DatabaseSessionContainer


This is the session container.

I won't bother with any locking. The database can take care of that.

Concerning aquarium.util.AquariumClass: unlike its parent class, this class does mixin aquarium.util.AquariumClass and does require a ctx parameter in its constructor. I need to do this in order to get access to the database connection.

The following class level constants are defined:

SESSION_CLEANUP_FREQUENCY
If you're using this module, you probably don't have an "application" scope. Hence, it'll be hard for you to create a thread to call cleanup. Hence, I'll call it for you, randomly, every SESSION_CLEANUP_FREQUENCY calls to open. Set this 0 to forgo this behavior.

Method Summary
  __init__(self, ctx)
Call AquariumClass.__init__.
  cleanup(self)
Delete all of the expired sessions.
  open(self, sid)
Create or open a session.
  _createSession(self, sid)
This is a session factory method.
  _exists(self, sid)
Does a session with the given sid exist?
  _isExpired(self, sid)
This is NotImplemented because it's not needed.
  _loadSession(self, sid)
Load an existing session.
    Inherited from SessionContainer
  adjustTime(self, deltaSeconds)
Adjust all of the lastModified keys.
  _acquire(self)
Acquire the global lock.
  _createSid(self)
Generate a new sid.
  _release(self)
Release the global lock.
  _unlink(self, sid)
Delete a session permanently.

Class Variable Summary
int SESSION_CLEANUP_FREQUENCY = 100                                                                   
    Inherited from SessionContainer
int SID_LENGTH = 20                                                                    
lock _lock = <thread.lock object at 0xb7df80a0>
dict _sessions = {}

Method Details

__init__(self, ctx)
(Constructor)

Call AquariumClass.__init__.

Also, instantiate the backend.

Overrides:
aquarium.util.AquariumClass.AquariumClass.__init__

cleanup(self)

Delete all of the expired sessions.

It's the application's responsibility to occasionally call this if you set SESSION_CLEANUP_FREQUENCY to 0.

Overrides:
aquarium.session.SessionContainer.SessionContainer.cleanup

open(self, sid=None)

Create or open a session.

Also, call cleanup per SESSION_CLEANUP_FREQUENCY.

Overrides:
aquarium.session.SessionContainer.SessionContainer.open

_createSession(self, sid)

This is a session factory method.

Overrides:
aquarium.session.SessionContainer.SessionContainer._createSession

_exists(self, sid)

Does a session with the given sid exist?

This implies that it is not expired.

Overrides:
aquarium.session.SessionContainer.SessionContainer._exists

_isExpired(self, sid)

This is NotImplemented because it's not needed.

If it _exists, then it's not expired.

Overrides:
aquarium.session.SessionContainer.SessionContainer._isExpired

_loadSession(self, sid)

Load an existing session.


Class Variable Details

SESSION_CLEANUP_FREQUENCY

Type:
int
Value:
100                                                                   

Generated by Epydoc 2.1 on Mon Jan 1 16:34:19 2007 http://epydoc.sf.net