linesman.backends

class linesman.backends.base.Backend(*args, **kwargs)[source]

Base class for all backends. Methods that raise a NotImplementedError exception are required to be overriden by children, while functions that pass are optional.

add(session)[source]

Store a new session in history.

Raises a NotImplementedError exception.

delete(session_uuid)[source]

Removes a specific stored session from the history.

This should return the number of rows removed (0 or 1).

Raises a NotImplementedError exception.

delete_all()[source]

Removes all stored sessions from the history.

This should return the number of rows removed.

Raises a NotImplementedError exception.

delete_many(session_uuids)[source]

Removes a list of stored sessions from the history.

This should return the number of rows removed.

Raises a NotImplementedError exception.

get(session_uuid)[source]

Returns the data associated with session_uuid. Should return None if no session can be found with the specified uuid.

Raises a NotImplementedError exception.

get_all()[source]

Return a dictionary-like object of ALL sessions, where the key is the session uuid.

Raises a NotImplementedError exception.

setup()[source]

Responsible for initializing the backend. for usage. This is run once on middleware startup.

Raises a NotImplementedError exception.

class linesman.backends.pickle.PickleBackend(filename='sessions.dat')[source]

Stores entire session as a pickled object. This can be extremely slow when using even smaller sets of sessions–on the order of 30mb, or around 200 requests.

add(session)[source]

Adds a session to this dictionary and flushes it to disk.

delete(session_uuid)[source]

Remove a session from the dictionary and flush it to disk.

delete_all()[source]

Clear the entire session history and flush it to disk.

delete_many(session_uuids)[source]

Remove the sessions from the dictionary and flush it to disk.

get(session_uuid)[source]
get_all()[source]
setup()[source]

Reads in pickled data from filename.

class linesman.backends.sqlite.SqliteBackend(filename='sessions.db')[source]

Stores sessions in a SQLite database.

add(session)[source]

Insert a new session into the database.

conn[source]
delete(session_uuid)[source]

Remove the session.

delete_all()[source]

Truncate the database.

delete_many(session_uuids)[source]

Remove the sessions.

get(session_uuid)[source]

Retrieves the session from the database.

get_all()[source]

Generates a dictionary of the data based on the contents of the DB.

setup()[source]

Creates table for Linesman, if it doesn’t already exist.

Previous topic

linesman

Next topic

linesman.middleware

This Page