[Zapp-cvs-commit] ZApp ZApp_RelationshipManager.py,NONE,1.1 ZApp_Application.py,1.19,1.20 ZApp_Relat
Brought to you by:
sspickle
Update of /cvsroot/zapp/ZApp
In directory sc8-pr-cvs1:/tmp/cvs-serv443
Modified Files:
ZApp_Application.py ZApp_RelationshipManagerMixin.py
ZApp_Specialist.py __init__.py addZApp_SpecialistForm.dtml
Added Files:
ZApp_RelationshipManager.py
Log Message:
moved 'relationship manager' to a proper specialist.
--- NEW FILE: ZApp_RelationshipManager.py ---
import ZApp_Specialist
import string
from Globals import DTMLFile, MessageDialog, default__class_init__
from Products.PlugIns import PlugInFinder
from Products.ZPatterns.Specialists import Specialist
rManID = 'Relationships'
rItemsID = 'RelationshipItems'
rRolesID = 'RelationshipRoles'
class ZApp_RelationshipManager(ZApp_Specialist.ZApp_Specialist):
"""
This Specialist provides methods for a 'relationshipmanger' to handle
creation/destruction/discovery of relationships.
"""
meta_type = 'Z App Relationship Manager'
def relateObjects(self, object1, object2, object1Role=None, object2Role=None, createIfNone=0, contextID=''):
"""
Relate two objects..
"""
newR = self.ZApp_createNewItem()
relIRolesMan = getattr(self, rRolesID)
relItems = getattr(self, rItemsID)
role1ID=''
role2ID=''
if object1Role:
role1IDs = relIRolesMan.ZApp_getItemIds( name=object1Role, objectType=object1.objectType, relatedObjectType=object2.objectType, createIfNone=createIfNone)
role1ID = role1IDs and role1IDs[0]
if not role1ID:
raise RuntimeError, ("No such role '%s'" % object1Role)
if object2Role:
role2IDs = relIRolesMan.ZApp_getItemIds( name=object2Role, objectType=object2.objectType, relatedObjectType=object1.objectType, createIfNone=createIfNone)
role2ID = role2IDs and role2IDs[0]
if not role2ID:
raise RuntimeError, ("No such role '%s'" % object2Role)
rItem1 = getattr(self, rItemsID).ZApp_createNewItem(relationshipID=newR.id, objectID=object1.id, objectManager=object1.Manager, roleID=role1ID)
rItem2 = getattr(self, rItemsID).ZApp_createNewItem(relationshipID=newR.id, objectID=object2.id, objectManager=object2.Manager, roleID=role2ID, contextID=contextID)
def removeObjects(self, object1, object2=None, object1Role=None, object2Role=None, object2Type=None, object2Manager=None):
"""
Relate two objects..
"""
role1ID=''
role2ID=''
o2Type=''
if object2:
o2Type=object2.objectType
elif object2Type:
o2Type=object2Type
o2Manager=''
if object2:
o2Manager=object2.Manager
elif object2Manager:
o2Manger=object2Manager
relIRolesMan = getattr(self, rRolesID)
if object1Role:
role1IDs = relIRolesMan.ZApp_getItemIds( name=object1Role, objectType=object1.objectType, relatedObjectType=o2Type)
role1ID = role1IDs and role1IDs[0]
if object2Role:
role2IDs = relIRolesMan.ZApp_getItemIds( name=object2Role, objectType=o2Type, relatedObjectType=object1.objectType)
role2ID = role2IDs and role2IDs[0]
relationshipIDs = []
for rItem1 in getattr(self, rItemsID).ZApp_getItems(objectID=object1.id, objectManager=object1.Manager, roleID=role1ID):
theRID=rItem1.relationshipID
for rItem2 in getattr(self, rItemsID).ZApp_getItems(relationshipID=rItem1.relationshipID, objectManager=o2Manager, roleID=role2ID):
if (not ((rItem2.objectID == object1.id) and (rItem2.objectManager == object2.Manager))):
rItem2.manage_delete()
rItem1.manage_delete()
self.commit_subtransaction()
rItemsLeft = getattr(self, rItemsID).ZApp_getItems(relationshipID=theRID)
if len(rItemsLeft) < 2:
for ri in rItemsLeft:
ri.manage_delete()
relation = self.getItem(theRID)
if relation:
relation.manage_delete()
def getRelatedObjects(self, anObject, objectTypes=None, objectRoles=None, selfRoles=None):
"""
find related objects... this is the 'brute force' approach.....
"""
myRelationshipItems = getattr(self, rItemsID).ZApp_getItems( objectID=anObject.id, objectManager=anObject.Manager)
riMan = getattr(self, rRolesID)
results = []
for anRI in myRelationshipItems:
if selfRoles:
RIRole = riMan.getItem(anRI.roleID)
if (not RIRole) or (RIRole.name not in selfRoles):
continue
theRelationshipItems = getattr(self, rItemsID).ZApp_getItems( relationshipID=anRI.relationshipID )
for rItem in theRelationshipItems:
if objectRoles:
RIRole = riMan.getItem(rItem.roleID)
if not RIRole:
continue
elif RIRole.name not in objectRoles:
continue
if (not ((rItem.objectManager == anObject.Manager) and (rItem.objectID == anObject.id))):
theObject = rItem.getObject()
if objectTypes and (theObject.objectType not in objectTypes):
continue
results.append(theObject)
return results
def getRelatedObjectContextIDs(self, anObject, objectTypes=None, objectRoles=None, selfRoles=None, returnTuple=0):
"""
find related objects... this is the 'brute force' approach.....
"""
myRelationshipItems = getattr(self, rItemsID).ZApp_getItems( objectID=anObject.id, objectManager=anObject.Manager)
riMan = getattr(self, rRolesID)
results = []
for anRI in myRelationshipItems:
if selfRoles:
RIRole = riMan.getItem(anRI.roleID)
if (not RIRole) or (RIRole.name not in selfRoles):
continue
theRelationshipItems = getattr(self, rItemsID).ZApp_getItems( relationshipID=anRI.relationshipID )
for rItem in theRelationshipItems:
if objectRoles:
RIRole = riMan.getItem(rItem.roleID)
if not RIRole:
continue
elif RIRole.name not in objectRoles:
continue
if (not ((rItem.objectManager == anObject.Manager) and (rItem.objectID == anObject.id))):
if objectTypes and (theObject.objectType not in objectTypes):
continue
results.append((rItem.getSortableContextID(), rItem.contextID)) # build a sortable list...
results.sort()
if not returnTuple:
results = map(lambda x:x[1], results) # grab the actual context id...
return results
def nextContextID(self, anObject, objectTypes=None, objectRoles=None, selfRoles=None):
"""
get the 'next' contextID that makes sense..
"""
contextIDs = self.getRelatedObjectContextIDs( anObject, objectTypes=objectTypes, objectRoles=objectRoles, selfRoles=selfRoles, returnTuple=1)
maxVal = contextIDs and contextIDs[-1][0]
iVal = 1
if maxVal:
try:
iVal = string.atoi(maxVal) + 1
except ValueError:
try:
iVal = chr(ord(maxVal) + 1)
except ValueError:
pass
else:
pass
return iVal
def manage_addZApp_RelationshipManager(self, id=rManID, title='', rack='', leverSet='', REQUEST=None, lsmID=ZApp_Specialist.DEFAULT_LEVER_SET_ID):
"""
Add a RelationshipManager to this applicaton..
"""
ob = ZApp_Specialist.manage_addZApp_Specialist(self, id, title,
rack=rack,
leverSet=leverSet,
REQUEST=REQUEST,
lsmID=lsmID,
subClass=ZApp_RelationshipManager)
ZApp_Specialist.manage_addZApp_Specialist(ob, rItemsID,'',rack,leverSet,lsmID) # add the RelationshipItems Manager
ZApp_Specialist.manage_addZApp_Specialist(ob, rRolesID,'',rack,leverSet,lsmID) # add the RelationshipRoles Manager
rItems = getattr(ob, rItemsID)
rRoles = getattr(ob, rRolesID)
if (leverSet == 'ZODB_Lever_Methods'):
rItems.defaultRack.manage_setStorage(zclass='Products.ZApp.ZApp_RelationshipItem/ZApp_RelationshipItem', use_attrib='NO', load_attrib='')
rRoles.defaultRack.manage_setStorage(zclass='Products.ZApp.ZApp_Role/ZApp_RelationshipItemRole', use_attrib='NO', load_attrib='')
ob.defaultRack.manage_setStorage(zclass='Products.ZApp.ZApp_Relationship/ZApp_Relationship', use_attrib="NO", load_attrib='')
else:
rItems.defaultRack.manage_setStorage(zclass='Products.ZApp.ZApp_RelationshipItem/ZApp_RelationshipItem', use_attrib='YES', load_attrib='relationshipItemID')
rRoles.defaultRack.manage_setStorage(zclass='Products.ZApp.ZApp_Role/ZApp_RelationshipItemRole', use_attrib='YES', load_attrib='relationshipRoleID')
ob.defaultRack.manage_setStorage(zclass='Products.ZApp.ZApp_Relationship/ZApp_Relationship', use_attrib="YES", load_attrib='relationshipID')
if self.hasProperty('specialistMetaTypes'):
theApp = self
else:
theApp = self.findApplication()
oldList = theApp.specialistMetaTypes
if ZApp_RelationshipManager.meta_type not in oldList:
theApp.manage_changeProperties( specialistMetaTypes = oldList + [ZApp_RelationshipManager.meta_type])
if REQUEST:
return self.manage_main(self,REQUEST,update_menu=1)
ZApp_Specialist.setupClassInit(subClass=ZApp_RelationshipManager)
manage_addZApp_RelationshipManagerForm = DTMLFile('addZApp_SpecialistForm',
globals(),
RacksMetaTypes = PlugInFinder(Specialist.RacksGroup),
ZApp_Specialist_SubclassID=rManID,
ZApp_subClass_addMethod='manage_addZApp_RelationshipManager',
)
def initialize(context):
ZApp_Specialist.initialize(context,
subClass=ZApp_RelationshipManager,
addMethod=manage_addZApp_RelationshipManager,
addForm=manage_addZApp_RelationshipManagerForm)
Index: ZApp_Application.py
===================================================================
RCS file: /cvsroot/zapp/ZApp/ZApp_Application.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** ZApp_Application.py 7 May 2003 01:29:12 -0000 1.19
--- ZApp_Application.py 30 Jun 2003 20:25:05 -0000 1.20
***************
*** 18,22 ****
from Products.PlugIns import PlugInContainer, PlugInFinder, PlugInGroup, MakePICBase
from Products.ZApp.ZApp_Specialist import DEFAULT_LEVER_SET_ID
- from ZApp_RelationshipManagerMixin import ZApp_RelationshipManagerMixin
from ComputedAttribute import ComputedAttribute
--- 18,21 ----
***************
*** 119,123 ****
return MessageDialog(title='OK', message = ' Added ZApp Application ', action='manage_main')
! class ZApp_Application( PlugInContainer, ZApp_RelationshipManagerMixin ):
applicationMetaType = meta_type = 'Z App Application'
--- 118,125 ----
return MessageDialog(title='OK', message = ' Added ZApp Application ', action='manage_main')
!
! from ZApp_RelationshipManager import rManID
!
! class ZApp_Application( PlugInContainer):
applicationMetaType = meta_type = 'Z App Application'
***************
*** 212,215 ****
--- 214,224 ----
theSpecialistPath = '%s' % '/'.join(specCache.get(specName,None))
return self.restrictedTraverse( theSpecialistPath )
+
+ def getRelationshipManager(self):
+ """
+ get the application's "RelationshipManager".
+ """
+
+ return self.getSpecialist(rManID)
def getSpecialistsCache(self):
Index: ZApp_RelationshipManagerMixin.py
===================================================================
RCS file: /cvsroot/zapp/ZApp/ZApp_RelationshipManagerMixin.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ZApp_RelationshipManagerMixin.py 2 Jun 2003 14:46:08 -0000 1.3
--- ZApp_RelationshipManagerMixin.py 30 Jun 2003 20:25:05 -0000 1.4
***************
*** 1,176 ****
- """
- This module provides methods for a 'relationshipmanger' to handle creation/destruction/discovery of relationships.
- """
-
- import string
-
- class ZApp_RelationshipManagerMixin:
-
- def relateObjects(self, relMan, object1, object2, object1Role=None, object2Role=None, createIfNone=0, contextID=''):
- """
- Relate two objects..
- """
- newR = relMan.ZApp_createNewItem()
- relIRolesMan = relMan.RelationshipRoles
- relItems = relMan.RelationshipItems
-
- role1ID=''
- role2ID=''
-
- if object1Role:
- role1IDs = relIRolesMan.ZApp_getItemIds( name=object1Role, objectType=object1.objectType, relatedObjectType=object2.objectType, createIfNone=createIfNone)
- role1ID = role1IDs and role1IDs[0]
- if not role1ID:
- raise RuntimeError, ("No such role '%s'" % object1Role)
-
- if object2Role:
- role2IDs = relIRolesMan.ZApp_getItemIds( name=object2Role, objectType=object2.objectType, relatedObjectType=object1.objectType, createIfNone=createIfNone)
- role2ID = role2IDs and role2IDs[0]
- if not role2ID:
- raise RuntimeError, ("No such role '%s'" % object2Role)
-
-
- rItem1 = relMan.RelationshipItems.ZApp_createNewItem(relationshipID=newR.id, objectID=object1.id, objectManager=object1.Manager, roleID=role1ID)
- rItem2 = relMan.RelationshipItems.ZApp_createNewItem(relationshipID=newR.id, objectID=object2.id, objectManager=object2.Manager, roleID=role2ID, contextID=contextID)
-
- def removeObjects(self, relMan, object1, object2=None, object1Role=None, object2Role=None, object2Type=None, object2Manager=None):
- """
- Relate two objects..
- """
- role1ID=''
- role2ID=''
-
- o2Type=''
- if object2:
- o2Type=object2.objectType
- elif object2Type:
- o2Type=object2Type
-
- o2Manager=''
- if object2:
- o2Manager=object2.Manager
- elif object2Manager:
- o2Manger=object2Manager
-
- if object1Role:
- role1IDs = relIRolesMan.ZApp_getItemIds( name=object1Role, objectType=object1.objectType, relatedObjectType=o2Type)
- role1ID = role1IDs and role1IDs[0]
-
- if object2Role:
- role2IDs = relIRolesMan.ZApp_getItemIds( name=object2Role, objectType=o2Type, relatedObjectType=object1.objectType)
- role2ID = role2IDs and role2IDs[0]
-
- relationshipIDs = []
- for rItem1 in relMan.RelationshipItems.ZApp_getItems(objectID=object1.id, objectManager=object1.Manager, roleID=role1ID):
- theRID=rItem1.relationshipID
- for rItem2 in relMan.RelationshipItems.ZApp_getItems(relationshipID=rItem1.relationshipID, objectManager=o2Manager, roleID=role2ID):
- if (not ((rItem2.objectID == object1.id) and (rItem2.objectManager == object2.Manager))):
-
- rItem2.manage_delete()
- rItem1.manage_delete()
-
- relMan.commit_subtransaction()
-
- rItemsLeft = relMan.RelationshipItems.ZApp_getItems(relationshipID=theRID)
- if len(rItemsLeft) < 2:
- for ri in rItemsLeft:
- ri.manage_delete()
-
- relation = relMan.getItem(theRID)
- if relation:
- relation.manage_delete()
-
- def getRelatedObjects(self, relMan, anObject, objectTypes=None, objectRoles=None, selfRoles=None):
- """
- find related objects... this is the 'brute force' approach.....
- """
-
- myRelationshipItems = relMan.RelationshipItems.ZApp_getItems( objectID=anObject.id, objectManager=anObject.Manager)
- riMan = relMan.RelationshipRoles
-
- results = []
-
- for anRI in myRelationshipItems:
- if selfRoles:
- RIRole = riMan.getItem(anRI.roleID)
- if (not RIRole) or (RIRole.name not in selfRoles):
- continue
-
- theRelationshipItems = relMan.RelationshipItems.ZApp_getItems( relationshipID=anRI.relationshipID )
- for rItem in theRelationshipItems:
- if objectRoles:
- RIRole = riMan.getItem(rItem.roleID)
- if not RIRole:
- continue
- elif RIRole.name not in objectRoles:
- continue
-
- if (not ((rItem.objectManager == anObject.Manager) and (rItem.objectID == anObject.id))):
- theObject = rItem.getObject()
- if objectTypes and (theObject.objectType not in objectTypes):
- continue
- results.append(theObject)
-
- return results
-
-
- def getRelatedObjectContextIDs(self, relMan, anObject, objectTypes=None, objectRoles=None, selfRoles=None, returnTuple=0):
- """
- find related objects... this is the 'brute force' approach.....
- """
-
- myRelationshipItems = relMan.RelationshipItems.ZApp_getItems( objectID=anObject.id, objectManager=anObject.Manager)
- riMan = relMan.RelationshipRoles
-
- results = []
-
- for anRI in myRelationshipItems:
- if selfRoles:
- RIRole = riMan.getItem(anRI.roleID)
- if (not RIRole) or (RIRole.name not in selfRoles):
- continue
-
- theRelationshipItems = relMan.RelationshipItems.ZApp_getItems( relationshipID=anRI.relationshipID )
- for rItem in theRelationshipItems:
- if objectRoles:
- RIRole = riMan.getItem(rItem.roleID)
- if not RIRole:
- continue
- elif RIRole.name not in objectRoles:
- continue
-
- if (not ((rItem.objectManager == anObject.Manager) and (rItem.objectID == anObject.id))):
- if objectTypes and (theObject.objectType not in objectTypes):
- continue
- results.append((rItem.getSortableContextID(), rItem.contextID)) # build a sortable list...
-
- results.sort()
-
- if not returnTuple:
- results = map(lambda x:x[1], results) # grab the actual context id...
-
- return results
-
- def nextContextID(self, relMan, anObject, objectTypes=None, objectRoles=None, selfRoles=None):
- """
- get the 'next' contextID that makes sense..
- """
-
- contextIDs = self.getRelatedObjectContextIDs( relMan, anObject, objectTypes=objectTypes, objectRoles=objectRoles, selfRoles=selfRoles, returnTuple=1)
-
- maxVal = contextIDs and contextIDs[-1][0]
-
- iVal = 1
- if maxVal:
- try:
- iVal = string.atoi(maxVal) + 1
- except ValueError:
- try:
- iVal = chr(ord(maxVal) + 1)
- except ValueError:
- pass
- else:
- pass
-
- return iVal
-
--- 0 ----
Index: ZApp_Specialist.py
===================================================================
RCS file: /cvsroot/zapp/ZApp/ZApp_Specialist.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** ZApp_Specialist.py 25 Jun 2003 11:45:53 -0000 1.27
--- ZApp_Specialist.py 30 Jun 2003 20:25:05 -0000 1.28
***************
*** 17,22 ****
DEFAULT_LEVER_SET_ID='defaultLeverSet'
- # from ZApp_LeverMethods import ZApp_LeverMethodSets why??
-
commit_mode = 0 # should we force a commit immediately after structural changes?
--- 17,20 ----
***************
*** 99,125 ****
UIDGen = UniqueIDGenerator()
- def manage_addZApp_Specialist(self, id, title='', rack='', leverSet='', REQUEST=None, URL1='Youre_lost', lsmID=DEFAULT_LEVER_SET_ID):
- '''
- Adds a ZApp Specialist to the current folder.
- '''
-
- ob = ZApp_Specialist(id, title)
- self._setObject(id, ob)
- ob = ob.__of__(self)
-
- if rack:
- ob.RacksGroup._constructPlugIn(rack, id='defaultRack')
-
- if leverSet:
- ob.LeversSetsGroup._constructPlugIn("ZApp Lever Method Sets", id=lsmID)
- lsm = getattr(ob, lsmID, '')
- lsm and lsm.manage_changeProperties(myLeverSet=leverSet)
-
- ob.LeversSetsGroup._constructPlugIn("ZApp Lever Method Sets", id='genericLeverSet')
- lsm = getattr(ob, 'genericLeverSet', '')
- lsm and lsm.manage_changeProperties(myLeverSet='genericLevers')
-
- if REQUEST: return self.manage_main(self,REQUEST,update_menu=1)
-
from Products.PlugIns import PlugInGroup, PlugInContainer, PlugInFinder, MakePICBase
--- 97,100 ----
***************
*** 274,278 ****
return Results((items, data))
! def ZApp_insertNewItem(self, conditions=None, **kw):
"""
This method circumvents all the Specialist, Rack, Dataskin,
--- 249,253 ----
return Results((items, data))
! def ZApp_insertNewItem(self, conditions=None, displayQuery=None, **kw):
"""
This method circumvents all the Specialist, Rack, Dataskin,
***************
*** 294,298 ****
for prop in pm:
! props[prop['id']] = prop.get('sqlDefault',prop.get('prop_default',''))
if conditions:
--- 269,273 ----
for prop in pm:
! props[prop['id']] = prop.get('dbDefault',prop.get('prop_default',''))
if conditions:
***************
*** 301,305 ****
if kw:
props.update(kw.copy())
!
self.insertItem( REQUEST=props )
self._toCache( newID, self.ZApp_createFauxResult( props ))
--- 276,283 ----
if kw:
props.update(kw.copy())
!
! if displayQuery:
! return self.insertItem( REQUEST=props, src__=1 )
!
self.insertItem( REQUEST=props )
self._toCache( newID, self.ZApp_createFauxResult( props ))
***************
*** 315,324 ****
if properties is None:
! kw.update(self.REQUEST.form)
! else:
! kw.update(properties)
! if kw:
! newItem.change(kw)
return newItem
--- 293,306 ----
if properties is None:
! properties = {}
! properties.update(kw)
!
! if not properties:
! properties.update(self.REQUEST.form)
! properties.update(self.REQUEST.other)
!
! if properties:
! newItem.change(properties)
return newItem
***************
*** 367,370 ****
--- 349,387 ----
return "OK!"
+ def ZApp_getDefaultDictionary(self, typeString=0):
+ """
+ return a dictionary with default values for each property...
+
+ if typeString is 'true' the value of each item will be an appropriate type string
+ """
+ dict = {}
+
+ pm = self.ZApp_getPropertyMap()
+
+ if typeString:
+ newPM = []
+ for i in range(len(pm)):
+ item = {}
+ newPM.append(item)
+ item.update(pm[i])
+ itemType = type(item['prop_default'])
+ if itemType == type(''):
+ item['prop_default'] = '%(' + item['id']+ ')s'
+ elif itemType == type(0):
+ item['prop_default'] = '%(' + item['id'] + ')i'
+ elif itemType == type(1.0):
+ item['prop_default'] = '%(' + item['id'] + ')f'
+ pm = tuple(newPM)
+
+ [dict.setdefault(x['id'],x['prop_default']) for x in pm]
+ pk = self.getPrimaryKey()
+
+ if typeString:
+ dict[pk]='%(' + pk + ')s'
+ else:
+ dict[pk]=''
+
+ return dict
+
def ZApp_getPropertyMap(self):
"""
***************
*** 480,489 ****
if conditions is None:
! if not kw:
! conditions = self.REQUEST
! else:
! conditions = kw
! else:
! conditions.update(kw)
if displayQuery:
--- 497,507 ----
if conditions is None:
! conditions = {}
!
! conditions.update(kw)
!
! if not conditions:
! conditions.update(getattr(self.REQUEST,'form',{}))
! conditions.update(getattr(self.REQUEST,'other',{}))
if displayQuery:
***************
*** 563,572 ****
theIDs = []
- if kw:
- conditions = kw.copy()
-
if conditions is None:
try:
! conditions = self.REQUEST.form.copy()
conditions.update(self.REQUEST.other)
except:
--- 581,592 ----
theIDs = []
if conditions is None:
+ conditions = {}
+
+ conditions.update(kw)
+
+ if not conditions:
try:
! conditions.update(self.REQUEST.form)
conditions.update(self.REQUEST.other)
except:
***************
*** 658,672 ****
)
- default__class_init__(ZApp_Specialist); MakePICBase(ZApp_Specialist)
! def initialize(context):
context.registerClass(
! ZApp_Specialist,
permission = 'Add ZApp Specialists',
! constructors = (manage_addZApp_SpecialistForm,
! manage_addZApp_Specialist)
)
! context.registerPIContainerBase(ZApp_Specialist)
--- 678,728 ----
)
! def setupClassInit(subClass = ZApp_Specialist):
! default__class_init__(subClass)
! MakePICBase(subClass)
!
! setupClassInit()
!
! def manage_addZApp_Specialist(self, id, title='', rack='', leverSet='', REQUEST=None, URL1='Youre_lost', lsmID=DEFAULT_LEVER_SET_ID, subClass=ZApp_Specialist):
! '''
! Adds a ZApp Specialist (or a subClass) to the current folder.
!
! if this method is used to build a subClass (i.e., subClass is not ZApp_Specialist) then the
! created object is also returned..
!
! '''
!
! ob = subClass(id, title)
! self._setObject(id, ob)
! ob = ob.__of__(self)
!
! if rack:
! ob.RacksGroup._constructPlugIn(rack, id='defaultRack')
!
! if leverSet:
! ob.LeversSetsGroup._constructPlugIn("ZApp Lever Method Sets", id=lsmID)
! lsm = getattr(ob, lsmID, '')
! lsm and lsm.manage_changeProperties(myLeverSet=leverSet)
!
! ob.LeversSetsGroup._constructPlugIn("ZApp Lever Method Sets", id='genericLeverSet')
! lsm = getattr(ob, 'genericLeverSet', '')
! lsm and lsm.manage_changeProperties(myLeverSet='genericLevers')
!
! if subClass != ZApp_Specialist:
! return ob
!
! if REQUEST:
! return self.manage_main(self,REQUEST,update_menu=1)
!
! def initialize(context, subClass=ZApp_Specialist, addMethod=manage_addZApp_Specialist, addForm=manage_addZApp_Specialist):
context.registerClass(
! subClass,
permission = 'Add ZApp Specialists',
! constructors = (addForm,
! addMethod)
)
! context.registerPIContainerBase(subClass)
Index: __init__.py
===================================================================
RCS file: /cvsroot/zapp/ZApp/__init__.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** __init__.py 25 Jun 2003 11:45:53 -0000 1.14
--- __init__.py 30 Jun 2003 20:25:05 -0000 1.15
***************
*** 13,16 ****
--- 13,17 ----
import ZApp_MiscData
import ZApp_Utils
+ import ZApp_RelationshipManager
from ZApp_LOG import ZApp_LOG
***************
*** 57,61 ****
ZApp_Application.initialize(context)
ZApp_LeverMethods.initialize(context)
! ZApp_MiscData.initialize(context)
context.registerHelp()
--- 58,63 ----
ZApp_Application.initialize(context)
ZApp_LeverMethods.initialize(context)
! ZApp_MiscData.initialize(context)
! ZApp_RelationshipManager.initialize(context)
context.registerHelp()
Index: addZApp_SpecialistForm.dtml
===================================================================
RCS file: /cvsroot/zapp/ZApp/addZApp_SpecialistForm.dtml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** addZApp_SpecialistForm.dtml 2 Mar 2003 19:23:25 -0000 1.2
--- addZApp_SpecialistForm.dtml 30 Jun 2003 20:25:05 -0000 1.3
***************
*** 5,9 ****
)">
! <FORM ACTION="manage_addZApp_Specialist" METHOD="POST">
<TABLE CELLSPACING="2">
<TR>
--- 5,9 ----
)">
! <FORM ACTION="." METHOD="POST">
<TABLE CELLSPACING="2">
<TR>
***************
*** 12,16 ****
--- 12,21 ----
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
+ <dtml-if ZApp_Specialist_SubclassID>
+ &dtml-ZApp_Specialist_SubclassID;
+ <INPUT type="hidden" name="id" value="&dtml-ZApp_Specialist_SubclassID;">
+ <dtml-else>
<INPUT TYPE="TEXT" NAME="id" SIZE="40" VALUE="">
+ </dtml-if>
</TD>
</TR>
***************
*** 51,55 ****
<TD></TD>
<TD>
! <INPUT class="form-element" TYPE="SUBMIT" VALUE=" Add ">
</TD>
</TR>
--- 56,64 ----
<TD></TD>
<TD>
! <dtml-if ZApp_subClass_addMethod>
! <INPUT class="form-element" name="&dtml-ZApp_subClass_addMethod;:method" "TYPE="SUBMIT" VALUE=" Add ">
! <dtml-else>
! <INPUT class="form-element" name="manage_addZApp_Specialist:method" "TYPE="SUBMIT" VALUE=" Add ">
! </dtml-if>
</TD>
</TR>
|