gc3libs.persistence.filesystem

class gc3libs.persistence.filesystem.FilesystemStore(directory='/home/rmurri/.gc3/jobs', idfactory=<gc3libs.persistence.idfactory.IdFactory object at 0x3028bd0>, protocol=2, **extra_args)

Save and load objects in a given directory. Uses Python’s standard pickle module to serialize objects onto files.

All objects are saved as files in the given directory (default: gc3libs.Default.JOBS_DIR). The file name is the object ID.

If an object contains references to other Persistable objects, these are saved in the file they would have been saved if the save method was called on them in the first place, and only an ‘external reference’ is saved in the pickled container. This ensures that: (1) only one copy of a shared object is ever saved, and (2) any shared reference to Persistable objects is correctly restored when restoring the container.

The default idfactory assigns object IDs by appending a sequential number to the class name; see class Id for details.

The protocol argument specifies the serialization protocol to use, if different from gc3libs.persistence.serialization.DEFAULT_PROTOCOL.

Any extra keyword arguments are ignored for compatibility with SqlStore.

list()

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(id_)

Load a saved object given its ID, and return it.

remove(id_)

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(obj)

Save an object, and return an ID.

gc3libs.persistence.filesystem.make_filesystemstore(url, *args, **extra_args)

Return a FilesystemStore instance, given a ‘file:///‘ URL and optional initialization arguments.

This function is a bridge between the generic factory functions provided by gc3libs.persistence.make_store() and gc3libs.persistence.register() and the class constructor FilesystemStore:class.

Examples:

>>> fs1 = make_filesystemstore(gc3libs.url.Url('file:///tmp'))
>>> fs1.__class__.__name__
'FilesystemStore'

Previous topic

gc3libs.persistence.accessors

Next topic

gc3libs.persistence.idfactory