Session

class compas_session.session.Session(*, name, **kwargs)

Bases: object

Class representing a data session that can be identified by its name.

The class is implemented such that each named instance is a singleton. This means that during the lifetime of a program only one instance with a specific can exist, and that all sessions created with the same name, refer to the same session object instance.

Parameters:
namestr

The name of the unique object instance.

basedirstr or Path-like, optional

A “working” directory that serves as the root for storing (temporary) session data.

Raises:
SessionError

If no name is provided.

Methods

dump

Dump the data of the current session into a file.

get

Return the value for key if key is in the session, else return default or None.

load

Replace the session data with the data of a session stored in a file.

record

Record the current state of the session into session history.

redo

Move one step forward in recorded session history.

reset

Reset session history.

set

Insert key in the session, and assign value to it.

setdefault

Return the value of key in the session.

undo

Move one step backward in recorded session history.