Home | Trees | Index | Help |
|
---|
Package Modeling :: Module DatabaseContext :: Class DatabaseContext |
|
ObjectStore
--+ |CooperatingObjectStore
--+ | DatabaseContext
Method Summary | |
---|---|
Initialization also creates it own AdaptorContext to work with, by sending to aDatabase.adaptor() the message createAdaptorContext(). | |
__del__(self)
| |
Raises Unimplemented... | |
Returns the underlying AdaptorContext. | |
arrayFaultWithSourceGlobalID(self,
gID,
aRelationshipName,
anEditingContext)
| |
Returns an available DatabaseChannel, i.e. | |
batchFetchRelationship(self,
aRelationship,
objects,
anEditingContext)
| |
Commits the transaction in progress --that transaction was opened when the ObjectStore got one of the two message 'saveChangesInEditingContext()' or 'performChanges()'. | |
Returns the current ObjectStoreCoordinator which which the DatabaseContext cooperates during the process of saving changes. | |
returns Database object bound to this databaseContext | |
Returns the delegate for this object. | |
Breaks the reference cycle that exists between 'self' and its 'Database' object. | |
editingContextDidForgetObjectWithGlobalID(self,
anEditingContext,
aGlobalID)
| |
Creates and registers a new Fault for the supplied globalID. | |
Turns a row (dictionary) into a real object. | |
Called by the ObjectStoreCoordinator to re-synchronize the local snapshots with the (application-wide) Database's snapshots and to clean everything up. | |
Unimplemented | |
Unimplemented | |
Deletes all references for aGlobalID in the local snapshot table. | |
Deletes all references for each GlobalID in gIDs in the local snapshot table. | |
Unimplemented | |
Tells whether the DatabaseContext is responsible for the fetch specification. | |
Simply invokes ownsObject() on itself. | |
Returns 1 (true) if any of the channels() answers true to the message 'isFetchInProgress()', false otherwise. | |
Parameters: | |
Unimplemented yet | |
Unimplemented yet. | |
Locking is not supported yet: raises 'Unimplemented' | |
Tells whether the DatabaseContext is currently saving changes. | |
Returns the snapshot locally registered for the supplied GlobalID. | |
Returns the toMany snapshot locally registered for the supplied GlobalID and name. | |
Acquire the (reentrant) lock of the instance. | |
Locking is not supported yet: raises 'Unimplemented' | |
Unimplemented yet | |
Returns the approximate number of objects that would be returned by objectsWithFetchSpecification() if called with the very same parameters. | |
This method is dedicated for use by a toMany fault handler. | |
Fetches and returns a sequence of objects corresponding to the supplied fetch specification 'aFetchSpec'. | |
Tells whether the DatabaseContext is responsible for the objects of the supplied entity. | |
Tells whether the DatabaseContext is responsible for the object. | |
Tells whether the DatabaseContext is responsible for the object. | |
This is the third and last step (apart from commitChanges() or rollbackChanges()) being triggered by the ObjectStoreCoordinator when the latter was instructed to save the changes made in an EditingContext. | |
This is the first step being triggered by the ObjectStoreCoordinator when it is instructed to save the changes made in an EditingContext. | |
Second step being triggered by the ObjectStoreCoordinator when the latter was instructed to save the changes made in an EditingContext. | |
See SnapshotsHandling/recordSnapshotForGlobalID() | |
See SnapshotsHandling.recordSnapshotForSourceGlobalID() | |
See SnapshotsHandling.recordSnapshots() | |
See SnapshotsHandling.recordToManySnapshots() | |
Called by the ObjectStoreCoordinator when an other DatabaseContext (including self) needs to forward changes on a given object --this can happen, for example, when a toMany relationship that has no inverse to-one relationship is modified in a given object 'obj1', because in this case the modification implies the modification of a foreign key stored in one or more objects 'obj<i>!=obj1'. | |
refaultObject(self,
aDatabaseObject,
aGlobalID,
anEditingContext)
| |
Adds the supplied DatabaseChannel to the list of registeredChannels(). | |
Return the list of registered DatabaseChannels. | |
Unimplemented | |
Rollbacks any changes sent at the previous step (cf. | |
Raises RuntimeError unconditionally: a DatabaseContext is not (yet) designed to be the 'rootObjectStore()' of an 'ObjectStore' hierarchy. | |
Unimplemented: a DatabaseContext is not (yet) designed to be the 'rootObjectStore()' of an 'ObjectStore' hierarchy. | |
Sets the object's delegate (not enabled yet) | |
Sets the DatabaseContext's update strategy | |
Returns the snapshot for 'aGlobalID'. | |
Returns the snapshot for 'aGlobalID' and the toMany relationship 'relationshipName'. | |
Releases the (reentrant) lock of the instance. | |
Unregister 'aDBChannel' from the list of registered DatabaseChannels. | |
Returns the DatabaseContext's updateStrategy | |
Unimplemented: see recordUpdateForObject() for details | |
Inherited from CooperatingObjectStore | |
See interfaces.CooperatingObjectStore for details | |
Inherited from ObjectStore | |
See interfaces.ObjectStore for details |
Class Variable Summary | |
---|---|
type |
SnapshotsTable = Modeling.DatabaseContext.SnapshotsTable |
Inherited from CooperatingObjectStore | |
tuple |
__implements__ = (<class Modeling.interfaces.Cooperating...
|
str |
__raise_exception__ = 'AbstractMethod'
|
str |
__raise_msg__ = 'CooperatingObjectStore is an abstract c...
|
Method Details |
---|
__init__(self,
aDatabase)
|
__unimplemented__(self)Raises Unimplemented... |
adaptorContext(self)Returns the underlying AdaptorContext. It is determined at initialization time and cannot change since then. |
availableChannel(self)Returns an available DatabaseChannel, i.e. one in its registeredChannels() which is not busy (==has no fetch in progress). If all registeredChannels are busy or if the DatabaseContext has no registered channels, it posts the notification 'DatabaseChannelNeededNotification' ; if it can find an available channel afterwards, it simply returns it. Otherwise, a new DatabaseChannel is created, registered and returned.
|
commitChanges(self)Commits the transaction in progress --that transaction was opened when the ObjectStore got one of the two message 'saveChangesInEditingContext()' or 'performChanges()'. This is the penultimate step of save changes. Raises 'RuntimeError' if the DatabaseContext is not saving changes.
|
coordinator(self)Returns the current ObjectStoreCoordinator which which the DatabaseContext cooperates during the process of saving changes. The coordinator is set when prepareForSaveWithCoordinator() is called, and it is reset whenever the process aborts --either with commitChanges() or rollbackChanges(). Outside a process of save changes, this returns None.
|
database(self)returns Database object bound to this databaseContext |
delegate(self)Returns the delegate for this object. |
dispose(self)Breaks the reference cycle that exists between 'self' and its 'Database' object. |
faultForGlobalID(self, keyGlobalID, anEditingContext)Creates and registers a new Fault for the supplied globalID. Raises 'ValueError' if keyGlobalID is invalid (i.e. it does not responds to message 'entityName()' --typically, if it is not a 'KeyGlobalID') Parameters:
|
faultForRawRow(self, row, entityName, anEditingContext)Turns a row (dictionary) into a real object. Any row, such as the one returned by a fetch when raw rows is activated, can be turned into a real object given that it contains the primary keys. Parameters:
See also: EditingContext.fetch(), FetchSpecification.setFetchesRawRows |
finalizeCommitChanges(self)Called by the ObjectStoreCoordinator to re-synchronize the local snapshots with the (application-wide) Database's snapshots and to clean everything up. This is the last step of saving changes. DatabaseContext's implementation forwards all changes made to its Database then empties/invalidates the internal state used during the process of saving changes. Last, it forwards the new KeyGlobalIDs (which replace the TemporaryGlobalIDs initially assigned to inserted objects) to the EditingContext. You should never called this by yourself, it is automatically called by the framework. |
forgetAllLocks(self)Unimplemented |
forgetLocksForObjectsWithGlobalIDs(self, gIDs)Unimplemented |
forgetSnapshotForGlobalID(self, aGlobalID)Deletes all references for aGlobalID in the local snapshot table. Parameter: aGlobalID -- a GlobalID instance Raises KeyError is aGlobalID is not registered, or RuntimeError if no process of saving changes is in progress |
forgetSnapshotsForGlobalIDs(self, gIDs)Deletes all references for each GlobalID in gIDs in the local snapshot table. Parameter: gIDs -- a sequence of GlobalID instances Raises KeyError is one GlobalID in 'gIDs' is not registered, or RuntimeError if no process of saving changes is in progress |
handleDroppedConnection(self)Unimplemented |
handlesFetchSpecification(self, aFetchSpecification)Tells whether the DatabaseContext is responsible for the fetch specification. A DatabaseContext is responsible for a fetch specification if the fetchSpec's entity is registered in the entities set managed by the dbContext.database() |
handlesObject(self, anObject)Simply invokes ownsObject() on itself. Conformance to the ObjectStore API. |
hasBusyChannels(self)Returns 1 (true) if any of the channels() answers true to the message 'isFetchInProgress()', false otherwise. See also: DatabaseChannel.isFetchInProgress() |
initializeObject(self, aDatabaseObject, aGlobalID, anEditingContext)Parameters: aGlobalID -- KeyGlobalID (non temporary) |
invalidateAllObjects(self)Unimplemented yet |
invalidateObjectsWithGlobalIDs(self, gIDs)Unimplemented yet. |
isObjectLockedWithGlobalID(self, aGlobalID, anEditingContext)Locking is not supported yet: raises 'Unimplemented' |
isSavingChanges(self)Tells whether the DatabaseContext is currently saving changes.
|
localSnapshotForGlobalID(self, aGlobalID)Returns the snapshot locally registered for the supplied GlobalID. If no snapshot was registered for that name and GlobalID, or if no process of saving changes is in progress, simply returns None. |
localSnapshotForSourceGlobalID(self, aGlobalID, aName)Returns the toMany snapshot locally registered for the supplied GlobalID and name. Parameters:
If no toMany snapshot was registered for that name and GlobalID, or if no process of saving changes is in progress, simply returns None. |
lock(self)Acquire the (reentrant) lock of the instance. Each call to 'lock()' must be balanced with a call to 'unlock()'. See also: unlock() |
lockObjectWithGlobalID(self, aGlobalID, anEditingContext)Locking is not supported yet: raises 'Unimplemented' |
missingObjectGlobalIDs(self)Unimplemented yet |
objectsCountWithFetchSpecification(self, aFetchSpec, anEditingContext)Returns the approximate number of objects that would be returned by objectsWithFetchSpecification() if called with the very same parameters. About ``approximate'': the number returned is in fact the upper bound ; as the objects are not actually fetched against the database, it is not possible to determine whether some have already been deleted within anEditingContext (see objectsWithFetchSpecification() as well). Parameters:
See also: DatabaseChannel.selectCountObjectsWithFetchSpecification() |
objectsForSourceGlobalID(self, srcGlobalID, aRelationshipName, anEditingContext)This method is dedicated for use by a toMany fault handler. See also: AccessArrayFaultHandler |
objectsWithFetchSpecification(self, aFetchSpec, anEditingContext)Fetches and returns a sequence of objects corresponding to the supplied fetch specification 'aFetchSpec'. These objects are also recorded within 'anEditingContext' 's uniquing table. If an object is already in the EditingContext, that object is returned, not the one that was fetched --unless the FetchSpecification 'aFetchSpec' is refreshing objects (not tested yet). It does NOT discard any objects that might be deleted in the 'anEditingContext', neither does it returns the objects that were inserted in anEditingContext but not saved yet ; it is the responsability of EditingContext.objectsWithFetchSpecification() to do this. Parameters:
Returns: the fetched objects, all of which are registered within anEditingContext.
|
ownsEntityName(self, entityName)Tells whether the DatabaseContext is responsible for the objects of the supplied entity. Namely: if the entity is registered in the entities set managed by the dbContext.database() |
ownsGlobalID(self, aGlobalID)Tells whether the DatabaseContext is responsible for the object. A DatabaseContext is responsible for an object if the global id's entity is registered in the entities set managed by the dbContext.database() |
ownsObject(self, anObject)Tells whether the DatabaseContext is responsible for the object. A DatabaseContext is responsible for an object if the object's entity is registered in the entities set managed by the dbContext.database() |
performChanges(self)This is the third and last step (apart from commitChanges() or rollbackChanges()) being triggered by the ObjectStoreCoordinator when the latter was instructed to save the changes made in an EditingContext. The 'EditingContext' instance this method works with is the one supplied when 'prepareForSaveWithCoordinator()' was called. It depends on prepareForSaveWithCoordinator() and recordChangesInEditingContext() having been called before ; you should never need to call this method by hand. What we do here is derive AdaptorOperations from the DatabaseOperations built on the previous step [recordChangesInEditingContext()]. These AdaptorOperations are ordered and sent to an available AdaptorChannel as the parameter for message performAdaptorOperation() Raises 'RuntimeError' if the DatabaseContext is not saving changes. |
prepareForSaveWithCoordinator(self, aCoordinator, anEditingContext)This is the first step being triggered by the ObjectStoreCoordinator when it is instructed to save the changes made in an EditingContext.
(Copied from CooperatingObjectStore interface) DatabaseContext's implementation examines objects in 'anEditingContext' ; all inserted, updated or deleted objects that are under its control (cf. ownsGlobalID()) are kept internally --until the process ends with either commitChanges() or rollbackChanges(). The DatabaseContext afterwards cooperates with an available AdaptorChannel to generate primary keys for newly inserted objects. Raises 'RuntimeError' if the DatabaseContext is not saving changes. Parameters:
Conformance to the CooperatingObjectStore interface. See also: coordinator() |
recordChangesInEditingContext(self)Second step being triggered by the ObjectStoreCoordinator when the latter was instructed to save the changes made in an EditingContext. The 'EditingContext' instance this method works with is the one supplied when 'prepareForSaveWithCoordinator()' was called. This method has two distinct tasks:
You should never need to call this method by yourself, it is automatically called by the ObjectStoreCoordinator in charge.
Raises 'RuntimeError' if the DatabaseContext is not saving changes. (Copied from CooperatingObjectStore interface) DatabaseContext implementation builds all necessary DatabaseOperation objects for the observed changes. These DatabaseOperations are then examined to check whether they do not imply changes to other objects in relation with the one they were build for, and if it is the case, the DatabaseContext forwards these changes to the ObjectStoreCoordinator. You can also refer to DatabaseOperation 's documentation for a more complete discussion on this topic. This method also always add a fake DatabaseOperation to its own set, whose operator is DATABASE_NOTHING_OPERATOR and whose globalID, object and entity all equals to the string 'fake' --this is used by recordUpdateForObject(), see this method for a complete discussion on this.
|
recordSnapshotForGlobalID(self, snapshot, aGlobalID)See SnapshotsHandling/recordSnapshotForGlobalID() |
recordSnapshotForSourceGlobalID(self, gids, aGlobalID, aName)See SnapshotsHandling.recordSnapshotForSourceGlobalID() |
recordSnapshots(self, snapshots)See SnapshotsHandling.recordSnapshots() |
recordToManySnapshots(self, snapshots)See SnapshotsHandling.recordToManySnapshots() |
recordUpdateForObject(self, aDatabaseObject, changes)Called by the ObjectStoreCoordinator when an other DatabaseContext (including self) needs to forward changes on a given object --this can happen, for example, when a toMany relationship that has no inverse to-one relationship is modified in a given object 'obj1', because in this case the modification implies the modification of a foreign key stored in one or more objects 'obj<i>!=obj1'. This method is for internal use, you should not need to call it by hand. The following explanations are implementation details. DatabaseContexts are designed in such a way that it can receive such messages before or after recordChangesInEditingContext() has processed its own changes. More precisely, when calling this method on self, recordChangesInEditingContext() takes care to process all its changes (inserted, updated or deleted objects) before it may call this method. As a consequence:
Parameters:
|
registerChannel(self, aDBchannel)Adds the supplied DatabaseChannel to the list of registeredChannels(). Raises ValueError if aDBchannel.databaseContext() is not self. If aDBChannel is already registered it silently returns. See also: registeredChannels(), unregisterChannel() |
registeredChannels(self)Return the list of registered DatabaseChannels. See also: registerChannels(), unregisterChannel() |
registerLockedObjectWithGlobalID(self, aGlobalID)Unimplemented |
rollbackChanges(self)Rollbacks any changes sent at the previous step (cf. performChanges()) and cleans up the DatabaseContext's internal variables which support the process of saving changes. Tou should not call this method by yourself, it is automatically triggered by the framework, when appropriate. Raises 'RuntimeError' if the DatabaseContext is not saving changes. See also: commitChanges() |
rootObjectStore(self)Raises RuntimeError unconditionally: a DatabaseContext is not (yet) designed to be the 'rootObjectStore()' of an 'ObjectStore' hierarchy. The only possible root for an hierarchy of ObjectStores is an 'ObjectStoreCoordinator'. See also: saveChangesInEditingContext() |
saveChangesInEditingContext(self, anEditingContext)Unimplemented: a DatabaseContext is not (yet) designed to be the 'rootObjectStore()' of an 'ObjectStore' hierarchy. The only possible root for an hierarchy of ObjectStores is an 'ObjectStoreCoordinator'. See also: rootObjectStore() |
setDelegate(self, aDelegate)Sets the object's delegate (not enabled yet) |
setUpdateStrategy(self, aStrategy)Sets the DatabaseContext's update strategy Raise RuntimeError if the DatabaseContext is currently saving changes. |
snapshotForGlobalID(self, aGlobalID, timestamp=0)Returns the snapshot for 'aGlobalID'. Snapshots are searched within the local set of snapshots, then in the object's database. Returned value is 'None' if no snapshot was recorded for 'aGlobalID' or if a snapshot exists with a smaller timestamp than parameter 'timestamp' |
snapshotForSourceGlobalID(self, aGlobalID, relationshipName, timestamp=0)Returns the snapshot for 'aGlobalID' and the toMany relationship 'relationshipName'. Snapshots are searched within the local set of snapshots, then in the object's database. Returned value is 'None' if no snapshot was recorded for 'aGlobalID' and 'relationshipName' or if a snapshot exists with a smaller timestamp than parameter 'timestamp' |
unlock(self)Releases the (reentrant) lock of the instance. See also: lock() |
unregisterChannel(self, aDBChannel)Unregister 'aDBChannel' from the list of registered DatabaseChannels. See also: registerChannel(), registeredChannels() |
updateStrategy(self)Returns the DatabaseContext's updateStrategy Default is UPDATE_WITH_NO_LOCKING |
valuesForKeys(self, keys, aDatabaseObject)Unimplemented: see recordUpdateForObject() for details |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Sat Mar 4 13:36:24 2006 | http://epydoc.sf.net |