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

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:

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
  __init__(self, aGlobalID, anObject, anEntity)
Initializer for a DatabaseOperation.
  __repr__(self)
  __str__(self)
  adaptorOperations(self)
Returns the set of AdaptorOperations bound to this DatabaseOperation.
  addAdaptorOperation(self, anAdaptorOperation)
Binds a new AdaptorOperation to the DatabaseOperation().
  databaseOperator(self)
Returns the database operator.
  dbSnapshot(self)
Returns the snapshot that represents the object as it was last fetched from/saved to the database.
  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.
  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().
  recordToManySnapshot(self, globalIDs, name)
Registers the array of GlobalIDs corresponding to the objects that are in relation with self.object(), for the supplied relationship.
  recordToManySnapshots(self, toManySnapshots)
Registers the toMany snapshots corresponding to the objects that are in relation with self.object().
  removeAdaptorOperation(self, anAdaptorOperation)
Removes an AdaptorOperation from the bound adaptorOperations()
  rowDiffs(self)
Returns the set of value that are different between the database napshot and the newRow.
  rowDiffsForAttributes(self, attributes)
Same as rowDiffs(), but the returned dictionary is restricted to the names of the supplied attributes.
  setDatabaseOperator(self, aDatabaseOperator)
Sets the DatabaseOperation's operator.
  setDBSnapshot(self, dbSnapshot)
Sets the DatabaseOperation's DB snaphost
  setNewRow(self, newRow)
Sets the rows which reflects the state of the object about to be saved.
  toManySnapshots(self)
See also: recordToManySnapshot()

Method Details

__init__(self, aGlobalID, anObject, anEntity)
(Constructor)

Initializer for a DatabaseOperation.

Raises ValueError if at least one of the arguments are None.

adaptorOperations(self)

Returns the set of AdaptorOperations bound to this DatabaseOperation. This set is built by a DatabaseContext.

See also: addAdaptorOperation(), DatabaseContext.performChanges()
removeAdaptorOperation()

addAdaptorOperation(self, anAdaptorOperation)

Binds a new AdaptorOperation to the DatabaseOperation().

See also: adaptorOperations(), DatabaseContext.performChanges(),
removeAdaptorOperation()

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:

globalIDs -- a sequence made of GlobalIDs, or '0' (integer 0) if the
relationship is still a fault.

name -- the name of the corresponding relationship

See also: recordToManySnapshots(), toManySnapshots()

recordToManySnapshots(self, toManySnapshots)

Registers the toMany snapshots corresponding to the objects that are in relation with self.object().

Parameter:

snapshots -- an dictionary whose keys are relationships' names, and
whose values are GlobalIDs sequence (a '0' (integer 0) value represents a faulted relationship)

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

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