bridgedb.persistent

Module for functionality to persistently store state.

exception MissingState[source]

Bases: exceptions.Exception

Raised when the file or class storing global state is missing.

load(stateCls=None)[source]

Given a State, try to unpickle it’s statefile.

Parameters:stateCls (string) – An instance of State. If not given, try loading from _statefile if that file exists.
Return type:None or State
class State(config=None, **kwargs)[source]

Bases: twisted.spread.jelly.Jellyable

Pickled, jellied storage container for persistent state.

Create a persistent state storage mechanism.

Serialisation of certain classes in BridgeDB doesn’t work. Classes and modules which are known to be unjelliable/unpicklable so far are:

  • bridgedb.Dist
  • bridgedb.Bridges, and all “splitter” and “ring” classes contained within
Property statefile:
 The filename to retrieve a pickled, jellied State instance from. (default: bridgedb.persistent.State._statefile)
statefile

Filename property of a persisent.State.

load(statefile=None)[source]

Load a previously saved statefile.

Raises MissingState:
 If there was any error loading the statefile.
Return type:State or None
Returns:The state, loaded from State.STATEFILE, or None if an error occurred.
save(statefile=None)[source]

Save state as a pickled jelly to a file on disk.

useChangedSettings(config)[source]

Take a new config, compare it to the last one, and update settings.

Given a config object created from the configuration file, compare it to the last Conf that was stored, and apply any settings which were changed to be attributes of the State instance.