# -*- 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.
#-----------------------------------------------------------------------------
"""
ObjectStore Interface
__TBD
In addition, the module declares the following constants for use by the
posted Notifications:
- DeletedKey
- InsertedKey
- InvalidatedKey
- UpdatedKey
The posted notifications are identified by strings declared in the module as
well:
- InvalidatedAllObjectsInStoreNotification: __TBD when/what (object, userInfo)
Posted when the method 'invalidateAllObjects'
- ObjectsChangedInStoreNotification: __TBD when/what (object, userInfo)
Posted every time an ObjectStore notices that some of its objects
has changed.
The notification contains:
* object: the ObjectStore posting the notification
* userInfo: a dictionary
key: DeletedKey
value: __TBD (globalIDs)
key: InsertedKey
value: __TBD (globalIDs)
key: InvalidatedKey
value: __TBD (globalIDs)
key: UpdatedKey
value: a sequence which consists of the updated object's GlobalIDs
CVS information
$Id: ObjectStoreInterface.py 932 2004-07-20 06:21:57Z sbigaret $
"""
__version__='$Revision: 932 $'[11:-2]
try:
from Interface import Base
except:
class Base:
pass
class ObjectStoreInterface(Base):
"""
ObjectStore API
ObjectStore defines a common API for classes which manipulates graphs
of objects.
Contrary to other interfaces, 'ObjectStoreInterface' is not intended to be
fully implemented by all classes which use it. (... __TBD)
Thus, and even if this should be considered as an interface for some
abstract class, a concrete class ('ObjectStore') implementing this
interface exists, in which all defined methods just raises. This class
should be used as a mix-in class for classes implementing this interface.
Theses classes should in turn override the methods which makes sense for
them.
The documentation clearly states which known subclasses (see below) override
the default behaviour. Additionnally, the general purpose of each method
will be explained ; subclasses' particular behaviour or processing will be
explained when possible, or will explicitely refer to some other
documentation.
The classes implementing this interface are: 'EditingContext',
'CooperatingObjectStore', 'ObjectStoreCoordinator' and 'DatabaseContext'.
"""
def arrayFaultWithSourceGlobalID(self, aGlobalID, aRelationshipName,
anEditingContext):
"""
Accurate for:
- ObjectStoreCoordinator: see details in interface
"""
def editingContextDidForgetObjectWithGlobalID(self, aContext, aGlobalID):
"""
"""
def faultForGlobalID(self, aGlobalID, anEditingContext):
"""
Accurate for:
- ObjectStoreCoordinator: see details in interface
"""
def faultForRawRow(self, aRow, anEntityName, anEditingContext):
"""
Turns a row (dictionary) into a real object. Any row, such as the one
returned by a fetch when raw rows is actvated, can be turned into a
real object given that it contains the primary keys.
Parameters:
row -- a dictionary. This dictionary should have the entity's primary
keys in its keys (and their corresponding values)
entityName -- the name of the entity the row represents
anEditingContext -- The EditingContext in which the object should be
registered.
"""
def handlesObject(self, anObject):
"""
An alias for ownsObject
"""
def initializeObject(self, anObject, aGlobalID, anEditingContext):
"""
"""
def invalidateAllObjects(self):
"""
Accurate for:
- ObjectStoreCoordinator: see details in interface
"""
def invalidateObjectsWithGlobalIDs(self, globalIDs):
"""
Accurate for:
- ObjectStoreCoordinator: see details in interface
"""
def isObjectLockedWithGlobalID(self, aGlobalID, anEditingContext):
"""
anEditingContext optional?
"""
def lockObjectWithGlobalID(self, aGlobalID, anEditingContext):
"""
"""
def objectsForSourceGlobalID(self, aGlobalID, aRelationshipName, anEditingContext):
"""
Accurate for:
- ObjectStoreCoordinator: see details in interface
"""
def objectsCountWithFetchSpecification(self, aFetchSpecification, anEditingContext):
"""
Returns the approximate number of objects that would be returned by
objectsWithFetchSpecification() if called with the very same parameters.
About approximate: see EditingContext.objectsWithFetchSpecification doc.
"""
def objectsWithFetchSpecification(self, aFetchSpecification, anEditingContext):
"""
Accurate for:
- ObjectStoreCoordinator: see details in interface
"""
def ownsObject(self, anObject):
"""
Tells whether the object store can handle 'anObject'.
A ObjectStoreCoordinator take the opportunity to load the appropriate
DatabaseContext when it receives such a message, while a DatabaseContext
simply answers true or false (using ownsObject() which is part
of the CooperatingObjectStore interface)
Returns: a boolean value
"""
def refaultObject(self, anObject, aGlobalID, anEditingContext):
"""
Accurate for:
- ObjectStoreCoordinator: see details in interface
"""
def rootObjectStore(self):
"""
This method is dedicated to interactions between a hierarchy of
'EditingContext' (parent/child EC configuration) and the parent object
store of the hierarchy's root EditingContext. 'EditingContext' 's
implementation forwards the message to its parent object store. Any other
classes derived from 'ObjectStore' which may be set as the parent store of
an EditingContext returns 'self': e.g. 'ObjectStoreCoordinator'. Last, all
other classes implementing the 'ObjectStore' interface but which do not
fall under the previous categories should raise since this message is a
non-sense for them (for example: DatabaseContext)
"""
def savesChangesInEditingContext(self, anEditingContext):
"""
Accurate for:
- EditingContext for parent/child ECs configuration
- ObjectStoreCoordinator: see details in interface
"""
|