Home | Trees | Index | Help |
|
---|
Package Modeling :: Module DatabaseOperation :: Class DatabaseOperation |
|
A DatabaseOperation holds all the informations needed to make changes of an object persistent --this can be either the creation of that object, an update of its values, or the deletion of that object.
These informations are:
- the object itself, its GlobalID and its Entity,
- two kinds of snapshots: one which represent the object as it was last fetched or saved to the database, and one which represent its current state.
DatabaseOperations are created by a DatabaseContext when it is instructed to examine the changes in an EditingContext's graph of objects (see DatabaseContext.recordChangesInEditingContext()). After this, and normally under the control of an ObjectStoreCoordinator, the DatabaseContext builds specific AdaptorOperations for each DatabaseOperations ; the AdaptorOperations are then forwarded to the appropriate AdaptorChannel which is responsible for passing them to the database.
Method Summary | |
---|---|
Initializer for a DatabaseOperation. | |
__repr__(self)
| |
__str__(self)
| |
Returns the set of AdaptorOperations bound to this DatabaseOperation. | |
Binds a new AdaptorOperation to the DatabaseOperation(). | |
Returns the database operator. | |
Returns the snapshot that represents the object as it was last fetched from/saved to the database. | |
Returns the 'Entity' of the 'object()' this DatabaseOperation handles. | |
Returns the 'GlobalID' of the 'object()' this DatabaseOperation handles. | |
Returns a snapshot (dictionary) representing the object's current state that should be made persistent. | |
Returns the object the DatabaseOperation is responsible for | |
Returns a dictionary made of changes observed for the primary key(s) of the object -- for a full description of this dictionary, see rowDiffsForAttributes(). | |
Registers the array of GlobalIDs corresponding to the objects that are in relation with self.object(), for the supplied relationship. | |
Registers the toMany snapshots corresponding to the objects that are in relation with self.object(). | |
Removes an AdaptorOperation from the bound adaptorOperations() | |
Returns the set of value that are different between the database napshot and the newRow. | |
Same as rowDiffs(), but the returned dictionary is restricted to the names of the supplied attributes. | |
Sets the DatabaseOperation's operator. | |
Sets the DatabaseOperation's DB snaphost | |
Sets the rows which reflects the state of the object about to be saved. | |
See also: recordToManySnapshot() |
Method Details |
---|
__init__(self,
aGlobalID,
anObject,
anEntity)
|
adaptorOperations(self)Returns the set of AdaptorOperations bound to this DatabaseOperation. This set is built by a DatabaseContext.
|
addAdaptorOperation(self, anAdaptorOperation)Binds a new AdaptorOperation to the DatabaseOperation().
|
databaseOperator(self)Returns the database operator. See also: DATABASE_OPERATORS, setDatabaseOperator() |
dbSnapshot(self)Returns the snapshot that represents the object as it was last fetched from/saved to the database. DatabaseOperations whose operator is DATABASE_INSERT_OPERATOR have obviously no such snapshot. See also: setDBSnapshot() for a complete description of what a snapshot is. |
entity(self)Returns the 'Entity' of the 'object()' this DatabaseOperation handles. |
globalID(self)Returns the 'GlobalID' of the 'object()' this DatabaseOperation handles. |
newRow(self)Returns a snapshot (dictionary) representing the object's current state that should be made persistent. See also: setNewRow() for a complete description of what a snapshot is. |
object(self)Returns the object the DatabaseOperation is responsible for |
primaryKeyDiffs(self)Returns a dictionary made of changes observed for the primary key(s) of the object -- for a full description of this dictionary, see rowDiffsForAttributes(). Returned value is always an empty dictionary if the DatabaseOperation's operator() is not DATABASE_UPDATE_OPERATOR. Implementation note: This method is not used for the moment being. In fact, it is in direct relation with the fact that the propagation of the primary key value is not supported yet for to-one relationships ; however, this is the only case where an object's primary key(s) can be changed. |
recordToManySnapshot(self, globalIDs, name)Registers the array of GlobalIDs corresponding to the objects that are in relation with self.object(), for the supplied relationship. Parameters:
See also: recordToManySnapshots(), toManySnapshots() |
recordToManySnapshots(self, toManySnapshots)Registers the toMany snapshots corresponding to the objects that are in relation with self.object(). Parameter:
See also: recordToManySnapshot() |
removeAdaptorOperation(self, anAdaptorOperation)Removes an AdaptorOperation from the bound adaptorOperations() Raises 'ValueError' in case 'anAdaptorOperation' is not in the object's 'adaptorOperations()' Parameter: anAdaptorOperation -- an AdaptorOperation object See also: adaptorOperations(), addAdaptorOperation() |
rowDiffs(self)Returns the set of value that are different between the database napshot and the newRow. Returned value is a dictionary with attributes' names as keys, associated with the new value. |
rowDiffsForAttributes(self, attributes)Same as rowDiffs(), but the returned dictionary is restricted to the names of the supplied attributes. Parameter: attributes -- a sequence of Attribute object. |
setDatabaseOperator(self, aDatabaseOperator)Sets the DatabaseOperation's operator. Parameter: aDatabaseOperator -- one of the 'DATABASE_OPERATORS' Raises 'ValueError' if 'aDatabaseOperator' is not within DATABASE_OPERATORS, or if 'aDatabaseOperator' is 'DATABASE_INSERT_OPERATOR' (resp. 'DATABASE_DELETE_OPERATOR') and the object's databae operator is already set to 'DATABASE_DELETE_OPERATOR' (resp. 'DATABASE_INSERT_OPERATOR') [this is to make sure that the re-insertion of a previously deleted object has been correctly handled within the 'EditingContext', as it should be] |
setDBSnapshot(self, dbSnapshot)Sets the DatabaseOperation's DB snaphost Parameter: dbSnapshot -- the snapshot of the object as it was when the object was last fetched from/committed to the database. See also: dbSnapshot() |
setNewRow(self, newRow)Sets the rows which reflects the state of the object about to be saved. Parameter 'newRow' -- a dictionary whose keys are the attributes of the object's entity (derived attribute shouldn't be included), along with name of the entity's to-one relationships, and whose values are, unsurprisingly, the corresponding values! |
toManySnapshots(self)See also: recordToManySnapshot() |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Sat Mar 4 13:36:24 2006 | http://epydoc.sf.net |