# -*- 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.
#-----------------------------------------------------------------------------
"""
DatabaseObject interface
CVS information
$Id: DatabaseObject.py 932 2004-07-20 06:21:57Z sbigaret $
"""
__version__='$Revision: 932 $'[11:-2]
try:
from Interface import Base
except:
class Base:
pass
from Modeling.interfaces.Validation import ValidationInterface
from Modeling.interfaces.KeyValueCoding import KeyValueCodingInterface
from Modeling.interfaces.RelationshipManipulation import
import RelationshipManipulationInterface
from Modeling.interfaces.Faulting import FaultingInterface
class DatabaseObjectInterface(FaultingInterface,
KeyValueCodingInterface,
RelationshipManipulationInterface,
ValidationInterface):
"""
"""
def awakeFromFetch(self, anEditingContext):
"""
'EditingContext' sends this message to every object fetched and
registered in it.
See 'EditingContext.objectsWithFetchSpecification()'
'CustomObject' 's implementation calls 'awakeObjectFromFetch()' on the
underlying 'ClassDescription'.
Override this method if you want to make additional initialization after
an object has been fetched and registered within an 'EditingContext'.
In that case, it is your responsability to make sure that
'CustomObject' 's method is called before proceeding.
"""
def awakeFromInsertion(self, anEditingContext):
"""
'EditingContext' sends this message to every object inserted in it.
See 'EditingContext.insertObject()' and
'EditingContext.insertObjectWithGlobalID()'
'CustomObject' 's implementation calls 'awakeObjectFromInsertion()' on the
underlying 'ClassDescription'.
Override this method if you want to make additional initialization after
an object has been inserted into an 'EditingContext'. In that case,
it is your responsability to make sure that 'CustomObject' 's method is
called before proceeding.
"""
def allPropertyKeys(self):
"attributesKeys + toOne/toManyRelationshipKeys"
def attributeKeys(self):
"See ClassDescription"
def classDescription(self):
"Returns the ClassDescription assigned to the receiver"
def classDescriptionForDestinationKey(self, aKey):
"Returns the ClassDescription assigned to the receiver"
def clearProperties(self):
"""
Clears all of the object's properties.
This is used to break circular reference / for garbage collection 'n co,
e.g. when an EditingContext is finalized and about to be garbage-collected
See also: EditingContext.invalidatesObjectsWhenFinalized() for details
"""
def deleteRuleForRelationshipKey(self, aKey):
"See ClassDescription"
raise 'Unimplemented'
def entityName(self):
"""
Returns the corresponding entity's name.
Note that derived objects **must** override this.
As a reminder this method raises 'MethodShouldBeOverridden'
"""
def editingContext(self):
""
def inverseForRelationshipKey(self, aKey):
"""
Returns the name of the relationship pointing back to current entity, or
None if it does not exists.
Note: can be overriden in subclasses if the default behaviour would not
return the correct answer.
"""
def isToManyKey(self, aKey):
"""
Tells whether the receiver's classDescription has a toMany relationship
'aKey'
"""
def propagateDeleteWithEditingContext(self, editingContext):
"XXXX"
def snapshot(self):
"""
Returns a snapshot for the current object...
... NullValue vs. None ...
Returned value: dictionary
"""
def toManyRelationshipKeys(self):
"See ClassDescription"
def toOneRelationshipKeys(self):
"See ClassDescription"
def updateFromSnapshot(aSnapshotDictionary):
"Updates the values from the supplied snapshot"
def willChange(self):
"""
XXXXX
Transparently calls 'willRead'
"""
|