class documentation

class DirectorySessionStore(SessionStore):

Constructor: DirectorySessionStore(sessions_directory, create_directory)

View In Hierarchy

Store sessions in individual files within a directory. The noqa in the definitions are because 'id' is a Python keyword (blame Quixote, not me!)

Method __init__ `__init__` takes a directory name, with an option to create it if it's not already there.
Method __iter__ Return an iterator of all session IDs in the storage. In our case, the session id is just the file-name
Method delete_old_sessions Delete all sessions that have not been modified for N minutes.
Method delete_session Delete the session file.
Method has_session Return true if the session exists in the store, else false.
Method load_session Load the pickled session from a file if it exists, otherwise return None
Method save_session Pickle the session and save it into a file.
Method setup Nothing to do here: but a directory could be created, etc.
Method transaction_abort Called near the end of a failed request (i.e. a exception that was not a PublisherError was raised.
Method transaction_commit Called near the end of each successful request. Not called if there were any errors processing the request.
Method transaction_start Called near the beginning of each request: after the HTTPRequest object has been built, but before we traverse the URL or call the callable object found by URL traversal.
Constant SLEEPY_TIME Undocumented
Class Variable is_multiprocess_safe Undocumented
Class Variable is_thread_safe Undocumented
Instance Variable directory Undocumented
Method _make_filename Build the filename from the session ID.
def __init__(self, sessions_directory: str, create_directory: bool = False):

`__init__` takes a directory name, with an option to create it if it's not already there.

def __iter__(self) -> Iterator[str]:

Return an iterator of all session IDs in the storage. In our case, the session id is just the file-name

def delete_old_sessions(self, minutes: int | float) -> tuple[int, int]:

Delete all sessions that have not been modified for N minutes. This method is never called by the session manager. It's for your application maintenance program; e.g., a daily cron job. DirectorySessionStore.delete_old_sessions returns a tuple: (n_deleted, n_remaining)

def delete_session(self, session_id: str | None):

Delete the session file.

def has_session(self, id: str | None) -> bool:

Return true if the session exists in the store, else false.

def load_session(self, id: str | None) -> Session | None:

Load the pickled session from a file if it exists, otherwise return None

def save_session(self, session: Session):

Pickle the session and save it into a file.

def setup(self):

Nothing to do here: but a directory could be created, etc.

def transaction_abort(self, session: Session | None):

Called near the end of a failed request (i.e. a exception that was not a PublisherError was raised.

def transaction_commit(self, session: Session | None):

Called near the end of each successful request. Not called if there were any errors processing the request.

def transaction_start(self):

Called near the beginning of each request: after the HTTPRequest object has been built, but before we traverse the URL or call the callable object found by URL traversal.

SLEEPY_TIME: float =

Undocumented

Value
0.1
is_multiprocess_safe: bool =

Undocumented

is_thread_safe: bool =

Undocumented

directory =

Undocumented

def _make_filename(self, id: str) -> str:

Build the filename from the session ID.