[Zapp-cvs-commit] ZApp ZApp_Specialist.py,1.32,1.33
Brought to you by:
sspickle
|
From: <ssp...@us...> - 2004-01-08 11:20:28
|
Update of /cvsroot/zapp/ZApp
In directory sc8-pr-cvs1:/tmp/cvs-serv5312
Modified Files:
ZApp_Specialist.py
Log Message:
make CMF object a bit more flexible WRT attribute management
Index: ZApp_Specialist.py
===================================================================
RCS file: /cvsroot/zapp/ZApp/ZApp_Specialist.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** ZApp_Specialist.py 24 Nov 2003 21:57:47 -0000 1.32
--- ZApp_Specialist.py 8 Jan 2004 11:20:25 -0000 1.33
***************
*** 419,422 ****
--- 419,468 ----
return self.defaultRack.getKlassAttr( attr, default )
+ def ZApp_getReferenceLookup(self):
+ """
+ return a lookup table for references by objects managed
+ by this specialist.
+
+ referenceLookup is an attribute of the specialist or the
+ class to a string, or a dictionary. If it's a string, it should be of the
+ form:
+
+ thisClassPropertyName:otherSpecialistName:otherClassPropertyName
+
+ e.g., if this specialist's class has a property personID, and
+ the "People" specialist uses 'personID' as a primary key you
+ would establish the relationship with a line in referenceLookup
+ as:
+
+ personID:People:personID
+
+ This permits the backend lever to qualify the schema with 'references xxxx'
+ clauses so that the backend can enforce referential integrity automatically.
+ (in addition to whatever enforcement is already done by ZPatterns/triggers).
+
+ """
+ missing = []
+
+ refLookup = getattr(self, 'ZApp_referenceLookup', missing)
+
+ if refLookup is missing:
+ refLookup = self.ZApp_getItemClassAttr('ZApp_referenceLookup', {})
+
+ if hasattr( refLookup, 'func_code' ) or hasattr( refLookup, '__call__'):
+ refLookup = refLookup()
+
+ if type(refLookup) == type(''):
+ refLookup = refLookup.split('\n')
+
+ if type(refLookup) == type([]):
+ result = {}
+ for item in refLookup:
+ if type(refLookup) == type(''):
+ rList = refLookup.split(':')
+ if len(rList) >= 3:
+ result[ rList[0] ] = [ rList[1], rList[2] ]
+ refLookup = result
+
+ return refLookup
def ZApp_printDebugMessage(self, message, priority=INFO):
|