A mix-in class to mark that an object should be persisted by its ID.
Any instance of this class is saved as an ‘external reference’ when a container holding a reference to it is saved.
Interface for storing and retrieving objects on permanent storage.
Each save operation returns a unique “ID”; each ID is a Python string value, which is guaranteed to be temporally unique, i.e., no two save operations in the same persistent store can result in the same IDs being assigned to different objects. The “ID” is also stored in the instance attribute _id.
Any Python object can stored, provided it meets the following conditions:
- it can be pickled with Python’s standard module pickle.
- the instance attribute persistent_id is reserved for use by the Store class: it should not be set or altered by other parts of the code.
Clear the loaded objects cache (if any).
load()calls are guaranteed to re-load the data directly from the backing store.
Return list of IDs of saved Job objects.
This is an optional method; classes that do not implement it should raise a NotImplementedError exception.
Load a saved object given its ID, and return it.
Restore functionality that was suspended in
This method will be called after forking/daemonizing has been successfully accomplished.
The default implementation of this method does nothing.
Make preparations for fork()-ing the current process.
This should close open network connections or any other sockets or file descriptors that cannot be used by both the parent and child process.
The default implementation of this method does nothing; as of 2018-04-10, the only subclass making use of this functionality is
SqlStore, which needs to dispose the SQLAlchemy engine and re-create it after forking.
Delete a given object from persistent storage, given its ID.
Replace the object already saved with the given ID with a copy of obj.
Save an object, and return an ID.
make_store(uri, *args, **extra_args)¶
Factory producing concrete
Given a URL and (optionally) initialization arguments, return a fully-constructed
The only required argument is uri; if any other arguments are present in the function invocation, they are passed verbatim to the constructor associated with the scheme of the given uri.
>>> fs1 = make_store('file:///tmp') >>> fs1.__class__.__name__ 'FilesystemStore'
Argument uri can also consist of a path name, in which case a URL scheme ‘file:///’ is assumed:
>>> fs2 = make_store('/tmp') >>> fs2.__class__.__name__ 'FilesystemStore'
Register constructor as the factory corresponding to an URL scheme.
If a different constructor is already registered for the same scheme, it is silently overwritten.
The registry mapping schemes to constructors is used in the
make_store()to create concrete instances of gc3libs.persistence.Store, given a URI that identifies the kind and location of the storage.
- scheme (str) – URL scheme to associate with the given constructor.
- constructor (callable) – A callable returning a
Storeinstance. Typically, a class constructor.