class gc3libs.persistence.store.Persistable(*args, **kwargs)

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.

class gc3libs.persistence.store.Store

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.

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.


Delete a given object from persistent storage, given its ID.

replace(id_, obj)

Replace the object already saved with the given ID with a copy of obj.


Save an object, and return an ID.

gc3libs.persistence.store.make_store(uri, *args, **extra_args)

Factory producing concrete Store instances.

Given a URL and (optionally) initialization arguments, return a fully-constructed Store instance.

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__

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__
gc3libs.persistence.store.register(scheme, constructor)

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 Store

instance. Typically, a class constructor.

Previous topic


Next topic