WebKit.SessionStore | index /usr/local/share/webware/WebKit/SessionStore.py

`A general session store.`

Classes
`` |  | __builtin__.object SessionStore
class SessionStore(__builtin__.object)
`` | `A general session store. SessionStores are dictionary-like objects used by Application to store session state. This class is abstract and it's up to the concrete subclass to implement several key methods that determine how sessions are stored (such as in memory, on disk or in a database). We assume that session keys are always strings. Subclasses often encode sessions for storage somewhere. In light of that, this class also defines methods encoder(), decoder() and setEncoderDecoder(). The encoder and decoder default to the load() and dump() functions of the cPickle or pickle module. However, using the setEncoderDecoder() method, you can use the functions from marshal (if appropriate) or your own encoding scheme. Subclasses should use encoder() and decoder() (and not pickle.load() and pickle.dump()). Subclasses may rely on the attribute self._app to point to the application. Subclasses should be named SessionFooStore since Application expects "Foo" to appear for the "SessionStore" setting and automatically prepends Session and appends Store. Currently, you will also need to add another import statement in Application.py. Search for SessionStore and you'll find the place. TO DO * Should there be a check-in/check-out strategy for sessions to prevent concurrent requests on the same session? If so, that can probably be done at this level (as opposed to pushing the burden on various subclasses).`
| Methods defined here: __contains__(self, key) `Check whether the session store has a given key. Subclasses must implement this method.` __delitem__(self, key) `Delete a session item from the store. Subclasses are responsible for expiring the session as well. Something along the lines of: session = self[key] if not session.isExpired(): session.expiring()` __getitem__(self, key) `Get a session item from the store. Subclasses must implement this method.` __init__(self, app) `Initialize the session store. Subclasses must invoke super.` __iter__(self) `Return an iterator over the stored session keys. Subclasses must implement this method.` __len__(self) `Return the number of sessions in the store. Subclasses must implement this method.` __repr__(self) `Return string representation of the store like a dictionary.` __setitem__(self, key, value) `Set a session item, saving it to the store. Subclasses must implement this method.` application(self) `Return the application owning the session store.` cleanStaleSessions(self, task=None) `Clean stale sessions. Called by the Application to tell this store to clean out all sessions that have exceeded their lifetime.` clear(self) `Clear the session store, removing all of its items. Subclasses must implement this method.` decoder(self) `Return the value deserializer for the store.` encoder(self) `Return the value serializer for the store.` get(self, key, default=None) `Return value if key available, else return the default.` has_key(self, key) `Check whether the session store has a given key.` items(self) `Return a list with the (key, value) pairs for all sessions.` iteritems(self) `Return an iterator over the (key, value) pairs for all sessions.` iterkeys(self) `Return an iterator over the stored session keys.` itervalues(self) `Return an iterator over the stored values of all sessions.` keys(self) `Return a list with the keys of all the stored sessions. Subclasses must implement this method.` pop(self, key, default=None) `Return value if key available, else default (also remove key). Subclasses must implement this method.` setEncoderDecoder(self, encoder, decoder) `Set the serializer and deserializer for the store.` setdefault(self, key, default=None) `Return value if key available, else default (also setting it). Subclasses must implement this method.` storeAllSessions(self) `Permanently save all sessions in the store. Used when the application server is shut down. Subclasses must implement this method.` storeSession(self, session) `Save potentially changed session in the store. Used at the end of transactions. Subclasses must implement this method.` values(self) `Return a list with the values of all stored sessions.` Data descriptors defined here: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)`

Functions
`` |  | dump(...) `dump(obj, file, protocol=0) -- Write an object in pickle format to the given file. See the Pickler docstring for the meaning of optional argument proto.` dumpWithHighestProtocol(obj, f) `Same as pickle.dump, but by default with the highest protocol.` load(...) `load(file) -- Load a pickle from the given file` time(...) `time() -> floating point number Return the current time in seconds since the Epoch. Fractions of a second may be present if the system clock provides them.`

Data
`` |  | maxPickleProtocol = 2