Package twisted :: Package popsicle :: Module repos :: Class Repository
[show private | hide private]
[frames | no frames]

Class Repository

Known Subclasses:
DirectoryRepository

A data storage that can be loaded from. A repository of objects.

I am an abstract class. Subclass me and implement 'loadOID' and 'saveOID'

Note that 'Repository' implementations are really open-ended. This implementation strategy is suggested, though, and it is strongly suggested that authors of new repositories implement at least the caching shown here.

However, facilities such as ad-hoc querying are omitted from this interface, and should be provided by e.g. an SQL Repository implementation.

A repository is both a saver and a collection of PersistentReferences.
Method Summary
  __init__(self)
Initialize me (set up cache).
  __getstate__(self)
  __setstate__(self, dct)
  cache(self, oid, obj, finished)
Weakly cache an object for the given OID.
  cleaned(self)
The freezer finished cleaning, and some of my objects were cleaned.
  createOID(self, oid, klass)
Create an instance with an oid and cache it.
  generateOID(self, obj)
Generate an OID synchronously.
  getOID(self, obj)
  load(self, oid)
Load an object from cache or by OID.
  loadNow(self, oid)
External API for synchronously loading stuff.
  loadOID(self, oid)
Implement me to return a Deferred if you want to implement asynchronous loading.
  loadOIDNow(self, oid)
Implement me if you want to implement synchronous loading.
  loadRef(self, pRef)
Synonymous with ref.__call__().
  save(self, obj)
Save an object...
  saveOID(self, oid, obj)
Return a Deferred which will fire True when the object is saved.

Class Variable Summary
class ISaver

Method Details

__init__(self)
(Constructor)

Initialize me (set up cache).

cache(self, oid, obj, finished=1)

Weakly cache an object for the given OID.

This means I own it, so also register it with the Freezer as such.

cleaned(self)

The freezer finished cleaning, and some of my objects were cleaned.

createOID(self, oid, klass)

Create an instance with an oid and cache it. This is useful during loading.

generateOID(self, obj)

Generate an OID synchronously.

Necessary for some types of persistence, but

load(self, oid)

Load an object from cache or by OID. Return a Deferred.

This method should be called by external objects looking for a 'starting point' into the repository.

loadNow(self, oid)

External API for synchronously loading stuff.

This should ONLY BE USED by code that is doing the actual loading/saving of structured objects. Application code should always make calls through PersistentReference.__call__, otherwise it will not work on some back-ends.

loadOID(self, oid)

Implement me to return a Deferred if you want to implement asynchronous loading.

loadOIDNow(self, oid)

Implement me if you want to implement synchronous loading.

loadRef(self, pRef)

Synonymous with ref.__call__().

save(self, obj)

Save an object...

If this is the first time I am saving this particular object, I need to locate a new unique ID for it.

saveOID(self, oid, obj)

Return a Deferred which will fire True when the object is saved.

Class Variable Details

ISaver

ISaver = twisted.popsicle.freezer.ISaver

Generated by Epydoc 1.1 on Fri Jun 27 03:45:39 2003 http://epydoc.sf.net