Session

Implementation of client sessions.

class Session.Session(trans, identifier=None)

Bases: object

Implementation of client sessions.

All methods that deal with time stamps, such as creationTime(), treat time as the number of seconds since January 1, 1970.

Session identifiers are stored in cookies. Therefore, clients must have cookies enabled.

Note that the session id should be a string that is valid as part of a filename. This is currently true, and should be maintained if the session id generation technique is modified. Session ids can be used in filenames.

__init__(trans, identifier=None)
awake(_trans)

Let the session awake.

Invoked during the beginning of a transaction, giving a Session an opportunity to perform any required setup. The default implementation updates the ‘lastAccessTime’.

creationTime()

Return the time when this session was created.

delValue(name)
expiring()

Let the session expire.

Called when session is expired by the application. Subclasses should invoke super. Session store __delitem__()s should invoke if not isExpired().

hasValue(name)
identifier()

Return a string that uniquely identifies the session.

This method will create the identifier if needed.

invalidate()

Invalidate the session.

It will be discarded the next time it is accessed.

isDirty()

Check whether the session is dirty (has unsaved changes).

isExpired()

Check whether the session has been previously expired.

See also: expiring()

isNew()

Check whether the session is new.

lastAccessTime()

Get last access time.

Returns the last time the user accessed the session through interaction. This attribute is updated in awake(), which is invoked at the beginning of a transaction.

numTransactions()

Get number of transactions.

Returns the number of transactions in which the session has been used.

respond(trans)

Let the session respond to a request.

The default implementation does nothing, but could do something in the future. Subclasses should invoke super.

sessionEncode(url)

Encode the session ID as a parameter to a url.

setDirty(dirty=True)

Set the dirty status of the session.

setTimeout(timeout)

Set the timeout on this session in seconds.

setValue(name, value)
sleep(trans)

Let the session sleep again.

Invoked during the ending of a transaction, giving a Session an opportunity to perform any required shutdown. The default implementation does nothing, but could do something in the future. Subclasses should invoke super.

timeout()

Return the timeout for this session in seconds.

value(name, default=<class 'MiscUtils.NoDefault'>)
values()
writeExceptionReport(handler)
exception Session.SessionError

Bases: Exception

Client session error

__init__(*args, **kwargs)
args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.