Package Modeling :: Module Database :: Class Database
[show private | hide private]
[frames | no frames]

Type Database

object --+
         |
        Database


Key features:

Snapshots and timestamps

While a Database object holds the snapshots and their timestamp, it is not the Database object's responsability to make decisions on whether a snapshot should be updated in a particular situation, or whatever decisions of that kind. Instead, other methods, such as AdaptorChannel.fetcObject() (refer to the documentation), make such decisions and then inform the Database (e.g. by actually recording snapshots)

Snapshots and referenceCounting:

__TBD

Snapshots related methods


Method Summary
  __init__(self, anAdaptor, aModel)
Initializer for Database.
  __unimplemented__(self)
Raises Unimplemented...
  adaptor(self)
Returns the underlying 'Adaptor' object
  addModel(self, aModel)
Shortcut for 'addModelIfCompatible'
  addModelIfCompatible(self, aModel)
Before adding the model to the Database object, checks whether:
  databaseForAdaptor(anAdaptor)
Database factory -- Equivalent to 'Database(anAdaptor=anAdaptor)' (Static method)
  databaseForModel(aModel)
Database factory -- Equivalent to 'Database(aModel=aModel)' (Static method)
  decrementSnapshotCountForGlobalID(self, aGlobalID)
Decrement the corresponding snapshot's refCount ; if the refCount reaches 0 (zero) after decrementation, the corresponding snapshot is deleted.
  disableSnapshotRefCounting()
Disables the snapshot refcounting in 'Databases' instances. (Static method)
  entityForObject(self, aDatabaseObject)
  entityNamed(self, entityName)
Searches for the corresponding 'Entity' in the registered models and returns it, or 'None' if it cannot be found.
  forgetAllSnapshots(self)
  forgetSnapshotForGlobalID(self, aGlobalID)
Removes the snapshot registered for 'aGlobalID'.
  forgetSnapshotsForGlobalIDs(self, globalIDs)
Removes the snapshots registered for 'globalIDs'.
  handleDroppedConnection(self)
  incrementSnapshotCountForGlobalID(self, aGlobalID)
Increment the refCount for the corresponding snapshot by one.
  invalidateResultCache(self)
Entity Caching is not supported yet
  invalidateResultCacheForEntityNamed(self, aName)
Entity Caching is not supported yet
  isSnapshotRefCountingEnabled()
Tells whether snapshot refCounting is enabled in 'Databases' instances. (Static method)
  lock(self)
Releases the lock for this Database object
  models(self)
Returns the list of models managed by this 'Database' object
  recordSnapshotForGlobalID(self, snapshot, aGlobalID)
Records 'snapshot' for 'aGlobalID' ; the snapshot is time-stamped using the so-called current timestamp (see setTimestampToNow(), which is called by this method, as a side-effect)
  recordSnapshotForSourceGlobalID(self, gids, aGlobalID, aName)
  recordSnapshots(self, snapshots)
Records the supplied snapshots.
  recordToManySnapshots(self, snapshots)
Records the snapshots for a toMany relationship.
  registerContext(self, aDBContext)
Registers the supplied 'DatabaseContext' in the receiver.
  registeredContexts(self)
Returns the registered 'DatabaseContext' objects
  removeModel(self, aModel)
Remove 'aModel' from the list of models this Database object services.
  resultCacheForEntityNamed(self, aName)
Entity Caching is not supported yet
  setResultCache(self, cache, aName)
Entity Caching is not supported yet
  setTimestampToNow(self)
Sets the current timestamp to 'time.time()', so that snapshots subsequently recorded are tagged with that current timestamp.
  snapshotCountForGlobalID(self, aGlobalID)
decrementSnapshotCountForGlobalID()
  snapshotForGlobalID(self, aGlobalID, timestamp)
Returns the registered snapshot for the supplied GlobalID, if any.
  snapshotForSourceGlobalID(self, aGlobalID, aName, timestamp)
  snapshots(self)
Returns a dictionary containing all registered snapshots, where keys are 'GlobalIDs' and values=the corresponding snapshot.
  timestampForGlobalID(self, aGlobalID)
Returns the current timestamp assigned to the snapshot for 'aGlobalID', or 'DistantPastTimeInterval' if no snapshot exists for 'aGlobalID'.
  timestampForSourceGlobalID(self, aGlobalID, aName)
Returns the current timestamp assigned to the snapshot for 'aGlobalID', or 'DistantPastTimeInterval' if no snapshot exists for 'aGlobalID'.
  unlock(self)
Releases the lock for this Database object
  unregisterContext(self, aDBContext)
Unregisters the supplied DatabaseContext from the receiver.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Class Variable Summary
type SnapshotsTable = Modeling.Database.SnapshotsTable

Instance Method Details

__init__(self, anAdaptor=None, aModel=None)
(Constructor)

Initializer for Database. Parameters 'anAdaptor' and 'aModel' are mutually exclusive: one, and only one, must be supplied at initialization time. If this condition is not fulfilled 'AttributeError' is raised.
Overrides:
__builtin__.object.__init__

__unimplemented__(self)

Raises Unimplemented...

adaptor(self)

Returns the underlying 'Adaptor' object

addModel(self, aModel)

Shortcut for 'addModelIfCompatible'

addModelIfCompatible(self, aModel)

Before adding the model to the Database object, checks whether:

  • 'aModel' 's adaptorName is the same than previously registered models'
  • the underlying adaptor answers positively to message 'canServiceModel' for 'aModel'

If one of these checks fails, 'aModel' is not added and the method returns '0' (zero, i.e. false). Otherwise returns '1' (true) and adds 'aModel' to the list of registered models (if 'aModel' was already registered, it is not re-inserted but still, '1' is returned).

decrementSnapshotCountForGlobalID(self, aGlobalID)

Decrement the corresponding snapshot's refCount ; if the refCount reaches 0 (zero) after decrementation, the corresponding snapshot is deleted. If snapshot refcounting is disabled, this method does nothing.

This method gets automatically called (see DatabaseContext.editingContextDidForgetObjectWithGlobalID())

entityNamed(self, entityName)

Searches for the corresponding 'Entity' in the registered models and returns it, or 'None' if it cannot be found.

forgetSnapshotForGlobalID(self, aGlobalID)

Removes the snapshot registered for 'aGlobalID'. Raises 'ValueError' if no snapshots were registered for 'aGlobalID'

forgetSnapshotsForGlobalIDs(self, globalIDs)

Removes the snapshots registered for 'globalIDs'. Raises 'ValueError' if no snapshots were registered for at least one of GlobalID among 'globalIDs' ; WARNING: in that case, it is possible that some snapshots get actually forgotten before the exception is raised.

incrementSnapshotCountForGlobalID(self, aGlobalID)

Increment the refCount for the corresponding snapshot by one. If snapshot refcounting is disabled, this method does nothing.

invalidateResultCache(self)

Entity Caching is not supported yet

invalidateResultCacheForEntityNamed(self, aName)

Entity Caching is not supported yet

lock(self)

Releases the lock for this Database object

models(self)

Returns the list of models managed by this 'Database' object

recordSnapshotForGlobalID(self, snapshot, aGlobalID)

Records 'snapshot' for 'aGlobalID' ; the snapshot is time-stamped using the so-called current timestamp (see setTimestampToNow(), which is called by this method, as a side-effect)

recordSnapshots(self, snapshots)

Records the supplied snapshots.

The snapshots are time-stamped using the current timestamp (calls setTimestampToNow())

Parameter:

snapshots -- a dictionary whose keys are 'GlobalID' and values=corresponding snapshots

recordToManySnapshots(self, snapshots)

Records the snapshots for a toMany relationship.

Parameter:

snapshots -- a dictionary with GlobalIDs as keys and dictionary as values, the latter dictionary having relationships' names as keys and a list of GlobalIDs as values.

registerContext(self, aDBContext)

Registers the supplied 'DatabaseContext' in the receiver. Silently returns if 'aDBContext' was already registered.

registeredContexts(self)

Returns the registered 'DatabaseContext' objects

removeModel(self, aModel)

Remove 'aModel' from the list of models this Database object services.

resultCacheForEntityNamed(self, aName)

Entity Caching is not supported yet

setResultCache(self, cache, aName)

Entity Caching is not supported yet

setTimestampToNow(self)

Sets the current timestamp to 'time.time()', so that snapshots subsequently recorded are tagged with that current timestamp.

snapshotCountForGlobalID(self, aGlobalID)

See also: incrementSnapshotCountForGlobalID,
decrementSnapshotCountForGlobalID()

snapshotForGlobalID(self, aGlobalID, timestamp=0)

Returns the registered snapshot for the supplied GlobalID, if any. Returns 'None' if none can be found, or if the registered snapshot's timestamp is lower than the supplied one.

snapshots(self)

Returns a dictionary containing all registered snapshots, where keys are 'GlobalIDs' and values=the corresponding snapshot.

timestampForGlobalID(self, aGlobalID)

Returns the current timestamp assigned to the snapshot for 'aGlobalID', or 'DistantPastTimeInterval' if no snapshot exists for 'aGlobalID'.

timestampForSourceGlobalID(self, aGlobalID, aName)

Returns the current timestamp assigned to the snapshot for 'aGlobalID', or 'DistantPastTimeInterval' if no snapshot exists for 'aGlobalID'.

unlock(self)

Releases the lock for this Database object

unregisterContext(self, aDBContext)

Unregisters the supplied DatabaseContext from the receiver. Raises 'ValueError'

Static Method Details

databaseForAdaptor(anAdaptor)

Database factory -- Equivalent to 'Database(anAdaptor=anAdaptor)'

databaseForModel(aModel)

Database factory -- Equivalent to 'Database(aModel=aModel)'

disableSnapshotRefCounting()

Disables the snapshot refcounting in 'Databases' instances. Note that once it has been disabled, the snapshot refcounting cannot be re-enabled.

isSnapshotRefCountingEnabled()

Tells whether snapshot refCounting is enabled in 'Databases' instances. Note that once it has been disabled, the snapshot refcounting cannot be re-enabled.

Generated by Epydoc 2.1 on Sat Mar 4 13:36:22 2006 http://epydoc.sf.net