# -*- coding: iso-8859-1 -*-
#-----------------------------------------------------------------------------
# Modeling Framework: an Object-Relational Bridge for python
#
# Copyright (c) 2001-2004 Sbastien Bigaret <sbigaret@users.sourceforge.net>
# All rights reserved.
#
# This file is part of the Modeling Framework.
#
# This code is distributed under a "3-clause BSD"-style license;
# see the LICENSE file for details.
#-----------------------------------------------------------------------------
"""
CooperatingObjectStore
__TBD
CVS information
$Id: CooperatingObjectStoreInterface.py 932 2004-07-20 06:21:57Z sbigaret $
"""
__version__='$Revision: 932 $'[11:-2]
from Modeling.interfaces.ObjectStoreInterface import ObjectStoreInterface
class CooperatingObjectStoreInterface(ObjectStoreInterface):
"""
CooperatingObjectStore
This interface defines the API that any coordinators should implement
so that they can be properly handled by the aplication's
'ObjectStoreCoordinator'
Any class implementing this interface *must* include the following
statement after the class declaration/specification::
# Now enforce interface' specifications
from Interface import verify_class_implementation
verify_class_implementation(CooperatingObjectStoreInterface,
<theClassImplementingTheInterface>)
Known class implementing this interface: DatabaseContext
"""
def commitChanges(self):
"""
Commit the changes made in the previous step (cf. performAdaptorOperations)
This should raise if some problems occur. This method should not clean any
internal state used during the process of saving changes, nor take any
other action than the one described above: this is the responsability of
method finalizeCommitChanges().
"""
def handlesFetchSpecification(self, aFetchSpecification):
"""
Indicates whether the CooperatingObjectStore can handle the supplied
FetchSpecification.
"""
def ownsGlobalID(self, aGlobalID):
"""
Indicates whether the CooperatingObjectStore is responsible for the
object which has this GlobalID.
"""
def ownsObject(self, anObject):
"""
Indicates whether the CooperatingObjectStore is responsible for the changes
made to 'anObject'
"""
def performChanges(self):
"""
Third step in the process of saving changes, where concrete subclasses
uses the DatabaseOperations built at the previous step to make the changes
persistent. DatabaseContext's implementation builds AdaptorOperation
from these DatabaseOperations, and then sends them to the underlying
concret AdaptorChannel using the 'performAdaptorOperations()' message.
"""
def prepareForSaveWithCoordinator(self, aCoordinator, anEditingContext):
"""
This is the first step being triggered by the ObjectStoreCoordinator
when the latter was instructed to do save the changes made in an
EditingContext.
See also: recordChangesInEditingContext(), performChanges(),
commitChanges(), rollbackChanges(),
EditingContext.saveChanges()
"""
def recordChangesInEditingContext(self):
"""
Second step being triggered by the ObjectStoreCoordinator when the latter
was instructed to do save the changes made in an EditingContext.
The 'EditingContext' instance this method works with is the one supplied
when 'prepareForSaveWithCoordinator()' was called.
You should never need to call this method by hand.
See also: prepareForSaveWithCoordinator(), performChanges(),
commitChanges(), rollbackChanges(),
EditingContext.saveChanges()
"""
def recordUpdateForObject(self, anObject, aDictionaryOfChanges):
"""
"""
def rollbackChanges(self):
"""
"""
def valuesForKey(self, keys, anObject):
"""
"""
def finalizeCommitChanges(self):
"""
Last step in the process of saving changes. The ObjectStoreCoordinator
calls it one each of its CooperatingObjectStores when all commitChanges()
did succeed. Concrete classes should transmit the changes made in the
local snapshots (including deletion) to their Database, then they should
take all appropriate actions to clean up the internal state.
"""
|