[Zapp-cvs-commit] ZApp ZApp_Application.py,1.27,1.28 ZApp_CMFBase.py,1.19,1.20 ZApp_RelatableItem.py
Brought to you by:
sspickle
|
From: <ssp...@us...> - 2003-12-16 17:19:47
|
Update of /cvsroot/zapp/ZApp
In directory sc8-pr-cvs1:/tmp/cvs-serv6778
Modified Files:
ZApp_Application.py ZApp_CMFBase.py ZApp_RelatableItem.py
Log Message:
working with plone now..
Index: ZApp_Application.py
===================================================================
RCS file: /cvsroot/zapp/ZApp/ZApp_Application.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** ZApp_Application.py 10 Dec 2003 14:20:21 -0000 1.27
--- ZApp_Application.py 16 Dec 2003 17:19:44 -0000 1.28
***************
*** 27,30 ****
--- 27,35 ----
_marker = []
+ from ZApp_LOG import ZApp_LOG
+ from zLOG import INFO, PROBLEM, ERROR
+
+ dbug_level = PROBLEM
+
Folder = OFS.Folder.Folder
DTMLMethod = OFS.DTMLMethod
***************
*** 104,112 ****
ob = ZApp_Application(id)
ob.id = id
- ob.zapp_app_id = id
ob.title = "ZApp Application Object"
else:
ob = appObject
- ob.zapp_app_id = id
self._setObject(ob.id, ob)
--- 109,115 ----
***************
*** 118,122 ****
if leverSet != 'Generic Lever Methods':
ob.LeversSetGroup._constructPlugIn('Generic Lever Methods', 'genericLevers')
!
updateMethodsInFolder(ob, getUIMethods(ui_method_names))
--- 121,125 ----
if leverSet != 'Generic Lever Methods':
ob.LeversSetGroup._constructPlugIn('Generic Lever Methods', 'genericLevers')
!
updateMethodsInFolder(ob, getUIMethods(ui_method_names))
***************
*** 124,128 ****
return MessageDialog(title='OK', message = ' Added ZApp Application ', action='manage_main')
-
from ZApp_RelationshipManager import rManID
--- 127,130 ----
***************
*** 130,134 ****
applicationMetaType = meta_type = 'Z App Application'
! specialistMetaTypes = ['Specialist','Z App Specialist']
LOCALE_ID = 'TST'
MiscDataSpecialist = 'MiscData'
--- 132,136 ----
applicationMetaType = meta_type = 'Z App Application'
! specialistMetaTypes = ['Specialist','Z App Specialist','Z App Relationship Manager']
LOCALE_ID = 'TST'
MiscDataSpecialist = 'MiscData'
***************
*** 136,139 ****
--- 138,145 ----
def _v_SpecialistsCache(self):
+ for mType in ZApp_Application.specialistMetaTypes:
+ if mType not in self.specialistMetaTypes:
+ self.specialistMetaTypes.append(mType)
+
v = self._v_SpecialistsCache = self.getSpecialistsCache()
return v
***************
*** 142,148 ****
def zapp_app_id(self):
! return self.id
zapp_app_id = ComputedAttribute( zapp_app_id )
_v_debugApp = None
--- 148,170 ----
def zapp_app_id(self):
! return self.getId()
zapp_app_id = ComputedAttribute( zapp_app_id )
+
+ def zapp_portal_object( self ):
+ if hasattr(self, 'portal_url'):
+ return self.portal_url.getPortalObject()
+
+ for item in self.objectValues():
+ if hasattr(item, '_isPortalRoot'):
+ return item
+
+ zapp_portal_object = ComputedAttribute( zapp_portal_object )
+
+ def zapp_portal_id(self):
+ po = self.zapp_portal_object
+ return (po and po.getId()) or 'none'
+
+ zapp_portal_id = ComputedAttribute( zapp_portal_id )
_v_debugApp = None
***************
*** 172,176 ****
{'id':'CMFDataSpecialist','type':'string','mode':'w'},
{'id':'MiscDataSpecialist','type':'string','mode':'w'},
! {'id':'zapp_app_id','type':'string','mode':'w'},
)
--- 194,199 ----
{'id':'CMFDataSpecialist','type':'string','mode':'w'},
{'id':'MiscDataSpecialist','type':'string','mode':'w'},
! {'id':'zapp_app_id','type':'string','mode':''},
! {'id':'zapp_portal_id','type':'string','mode':''},
)
***************
*** 181,190 ****
)
-
manage_leverActionsForm = DTMLFile('manage_ui/leverActionsForm',globals(),management_view='Lever Actions')
manage_leverResults = DTMLFile('manage_ui/leverResults',globals(),management_view='Lever Actions')
!
!
def __bobo_traverse__(self, REQUEST, name):
--- 204,211 ----
)
manage_leverActionsForm = DTMLFile('manage_ui/leverActionsForm',globals(),management_view='Lever Actions')
manage_leverResults = DTMLFile('manage_ui/leverResults',globals(),management_view='Lever Actions')
!
def __bobo_traverse__(self, REQUEST, name):
***************
*** 256,261 ****
get the application's "RelationshipManager".
"""
! return self.getSpecialist(rManID)
def getSpecialistsCache(self):
--- 277,288 ----
get the application's "RelationshipManager".
"""
+ result = self.getSpecialist(rManID)
+ if not result:
+ import pdb
+ pdb.set_trace()
! ZApp_LOG("Failed to get rman!", dbug_level);
!
! return result
def getSpecialistsCache(self):
Index: ZApp_CMFBase.py
===================================================================
RCS file: /cvsroot/zapp/ZApp/ZApp_CMFBase.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** ZApp_CMFBase.py 10 Dec 2003 14:20:21 -0000 1.19
--- ZApp_CMFBase.py 16 Dec 2003 17:19:44 -0000 1.20
***************
*** 6,9 ****
--- 6,11 ----
import time
import string
+ import traceback
+
from ZApp_Base import ZApp_Base, extendProperties, LeverPropertyCollection, LeverProperty
***************
*** 11,14 ****
--- 13,17 ----
missing = []
+ dbug_level = 0
lpcol = LeverPropertyCollection
***************
*** 72,76 ****
def calcPathID(self):
-
try:
if self.id.find(',') != -1:
--- 75,78 ----
***************
*** 78,82 ****
else:
objPath = ','.join(self.getPhysicalPath())
! portalPath = ','.join(self.portal_url.getPortalObject().getPhysicalPath()) + ','
result = objPath[len(portalPath)-1:]
except:
--- 80,85 ----
else:
objPath = ','.join(self.getPhysicalPath())
! portal_object = self.zapp_portal_object
! portalPath = ','.join(portal_object.getPhysicalPath()) + ','
result = objPath[len(portalPath)-1:]
except:
***************
*** 103,127 ****
def _notifyOfCopyTo(self, container, op=0):
"""we use _notifyOfCopy to save our miscData to a property
! so that the copy can retrieve it once created..."""
! return self._prepareRecursiveCopy(container, op)
- def _prepareRecursiveCopy(self, container, op=0, mdm=None):
if mdm is None:
mdm = self.getMiscDataSpecialist()
! safeStorage = mdm.ZApp_createNewItem(objectID=self.calcPathID(), dataType='copyPasteStorage', Manager=self.safeMiscData.Manager)
! if safeStorage:
safeStorage.setXMLAttrs( operationType = op )
! safeStorage.setXMLAttrs( oldID = self.calcPathID())
safeStorageID = safeStorage.getId()
! self.change(safeStorageID = safeStorageID )
! get_transaction().commit(1)
!
! ZApp_LOG("_notifyOfCopyTo: Setting safeStorageID to " + safeStorageID, 100)
! for subObject in self.objectValues():
! if getattr(subObject, 'zapp_cmf_type', 0):
! subObject._prepareRecursiveCopy( self, op, mdm)
def _setId(self, id):
--- 106,154 ----
def _notifyOfCopyTo(self, container, op=0):
+ """
+ notify of copy...
+ """
+
+ if self.REQUEST.get('notifyClear',0):
+ import pdb
+ pdb.set_trace()
+
+ self._ZCMFnotifyOfCopyTo(container, op)
+
+ def _subobjectNotify(self, op, mdm, notify_depth, safeStorage):
+ """notify subobjects of their impending change... """
+
+ for item in self.objectValues():
+ if getattr(item, 'zapp_cmf_type', 0):
+ item._ZCMFnotifyOfCopyTo( self, op, mdm, notify_depth+1, safeStorage)
+
+ def _ZCMFnotifyOfCopyTo(self, container, op=0, mdm=None, notify_depth=0, safeStorage=None):
"""we use _notifyOfCopy to save our miscData to a property
! so that the copy can retrieve it once created..."""
!
! ZApp_LOG("_notifyOfCopyTo: " + container.getId() + ":" + `op` + ":" + `notify_depth`, dbug_level)
!
! if notify_depth > 20:
! ZApp_LOG("Err... recursion problem?", dbug_level)
! return
if mdm is None:
mdm = self.getMiscDataSpecialist()
! selfID = self.calcPathID()
! mdmManager = self.safeMiscData.Manager
!
! if safeStorage is None:
! safeStorage = mdm.ZApp_createNewItem(objectID=selfID, dataType='copyPasteStorage', Manager=mdmManager)
safeStorage.setXMLAttrs( operationType = op )
! safeStorage.setXMLAttrs( oldID = selfID)
safeStorageID = safeStorage.getId()
! self.change(safeStorageID = safeStorageID, cmf_portal_type=self.portal_type )
! ZApp_LOG("commit sub-transaction...")
! get_transaction().commit(1)
!
! ZApp_LOG("do subobject notify: safeStorageID:" + safeStorage.getId() + ":self.id:" + selfID + ":Manager:" + mdmManager, dbug_level)
! self._subobjectNotify( op, mdm, notify_depth, safeStorage)
def _setId(self, id):
***************
*** 133,137 ****
if oldID:
safeStorageID = getattr(self, 'safeStorageID','')
- cmf_portal_type = getattr(self, 'portal_type', getattr(self, 'cmf_portal_type',''))
result = ZApp_Base._setId(self, id)
--- 160,163 ----
***************
*** 139,153 ****
if oldID:
self._v_safeStorageID = safeStorageID
- self._v_cmf_portal_type = cmf_portal_type
else:
self._v_safeStorageID = None
- self._v_cmf_portal_type = None
! ZApp_LOG("_setID: SafeStorageID, cmf_portal_type are now %s" % (`(self._v_safeStorageID,oldID,id,self._v_cmf_portal_type)`), 100)
return result
def _getCopy(self, container):
- ZApp_LOG("_getCopy, before" + `self.__dict__` + ":" + self.portal_type, 100)
safeStorageID = self.safeStorageID
--- 165,176 ----
if oldID:
self._v_safeStorageID = safeStorageID
else:
self._v_safeStorageID = None
! ZApp_LOG("_setID: SafeStorageID, oldID, id, are now %s" % (`(self._v_safeStorageID,oldID,id)`), dbug_level)
return result
def _getCopy(self, container):
safeStorageID = self.safeStorageID
***************
*** 155,166 ****
ob = CopySource._getCopy.im_func(self,container)
ob.__of__(container) # force DM hookup
if safeStorageID:
ob.__dict__['safeStorageID'] = safeStorageID
- ob.__dict__['cmf_portal_type'] = self.portal_type
! ZApp_LOG("_getCopy, after" + `ob.__dict__`, 100)
return ob
def manage_afterAdd(self, item, container):
""" restore XML from volitile attribute..
--- 178,232 ----
ob = CopySource._getCopy.im_func(self,container)
ob.__of__(container) # force DM hookup
+
+ ZApp_LOG("_getCopy, before" + self.getId() + ":" + `safeStorageID` + ":" + `self.portal_type` , dbug_level)
+
if safeStorageID:
ob.__dict__['safeStorageID'] = safeStorageID
! ZApp_LOG("_getCopy, after" + `ob.__dict__.keys()` , dbug_level)
return ob
+ def ZAppCMF_afterAdd(self, safeStorage, newID):
+ """
+ For (sub)objects that need to be hooked up after an 'add'
+ operation.
+ """
+
+ get = safeStorage.getXMLAttr
+ op = get('operationType','')
+ oldID = get('oldID','')
+ mySpec = self.getMySpecialist()
+ newRelID = self.calcPathID().split(newID)[1]
+ oldItemID = oldID + newRelID
+
+ ZApp_LOG("ZAppCMF_afterAdd: " + newRelID + ":" + oldItemID + ":" + mySpec.getId() + ":", dbug_level)
+
+ if mySpec and oldItemID:
+ oldSelf = mySpec.getItem( oldItemID )
+ if oldSelf:
+ newSelf = mySpec.ZApp_createNewItem(id=self.calcPathID())
+ mySpec.commit_subtransaction()
+
+ newSelf.setMiscData( dataDict = oldSelf.safeMiscData.getXMLDict())
+ newSelf.change(safeStorageID = '', cmf_portal_type=self.portal_type)
+ mySpec.commit_subtransaction()
+
+ newSelf.copyObjectRelations( oldSelf.objectRelations( returnObjects=1 ))
+
+ if op:
+ #
+ # it's a move operation...
+ #
+ oldSelf.manage_delete()
+
+ else:
+
+ oldSelf.change(safeStorageID = '')
+
+ for item in self.objectValues():
+ if getattr(item, 'zapp_cmf_type', 0):
+ item.ZAppCMF_afterAdd( safeStorage, newID )
+
def manage_afterAdd(self, item, container):
""" restore XML from volitile attribute..
***************
*** 168,217 ****
"""
- ZApp_LOG("_manage_afterAdd" + `self.__dict__`, 100)
-
safeStorageID = getattr(self, '_v_safeStorageID','')
! cmf_portal_type = getattr(self, '_v_cmf_portal_type','')
! SkinnedFolder.manage_afterAdd(self, item, container)
! ZApp_Base.manage_afterAdd(self, item, container)
!
if safeStorageID:
mdm = self.getMiscDataSpecialist()
safeStorage = mdm.getItem(safeStorageID)
if safeStorage:
! get = safeStorage.getXMLAttr
! op = get('operationType','')
! oldID = get('oldID','')
! mySpec = self.getMySpecialist()
!
! if mySpec and oldID:
! oldSelf = mySpec.getItem( oldID )
!
! if oldSelf:
! newSelf = mySpec.ZApp_createNewItem(id=self.calcPathID())
! mySpec.commit_subtransaction()
!
! newSelf.setMiscData( dataDict = oldSelf.safeMiscData.getXMLDict())
! newSelf.change(safeStorageID = '', cmf_portal_type=cmf_portal_type)
! mySpec.commit_subtransaction()
! newSelf.copyObjectRelations( oldSelf.objectRelations( returnObjects=1 ))
! if op:
! #
! # it's a move operation...
! #
! oldSelf.manage_delete()
! else:
! oldSelf.change(safeStorageID = '')
!
! safeStorage.manage_delete()
! if self.safeStorageID:
! self.change(safeStorageID = '')
! if hasattr(self, '_v_safeStorageID'):
! del self._v_safeStorageID # we've got it now.. thanks. ;-)
!
def copyObjectRelations(self, theObjectRelations):
--- 234,263 ----
"""
safeStorageID = getattr(self, '_v_safeStorageID','')
! newID = self.calcPathID()
! ZApp_LOG("_manage_afterAdd: " + self.getId() + ":" + safeStorageID + ":_v_in_manage_afterAdd:" + `getattr(self,'_v_in_manage_afterAdd',0)`, dbug_level)
!
! if getattr(self,'_v_in_manage_afterAdd',0):
! return
! else:
! self._v_in_manage_afterAdd = 1
!
if safeStorageID:
mdm = self.getMiscDataSpecialist()
safeStorage = mdm.getItem(safeStorageID)
if safeStorage:
! self.ZAppCMF_afterAdd( safeStorage, newID )
! safeStorage.manage_delete()
! del self._v_safeStorageID # we've got it now.. thanks. ;-)
! self.change( cmf_portal_type = self.portal_type)
! get_transaction().commit(1)
! SkinnedFolder.manage_afterAdd(self, item, container)
! ZApp_Base.manage_afterAdd(self, item, container)
! del self._v_in_manage_afterAdd
def copyObjectRelations(self, theObjectRelations):
Index: ZApp_RelatableItem.py
===================================================================
RCS file: /cvsroot/zapp/ZApp/ZApp_RelatableItem.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** ZApp_RelatableItem.py 28 Oct 2003 20:27:03 -0000 1.21
--- ZApp_RelatableItem.py 16 Dec 2003 17:19:44 -0000 1.22
***************
*** 11,14 ****
--- 11,19 ----
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from ZApp_LOG import ZApp_LOG
+ from zLOG import PROBLEM, INFO, ERROR
+
+ dbug_level=INFO
+
+ import traceback
class ZApp_RelatableParentMixin:
***************
*** 279,283 ****
def getRelationshipManager(self):
! return self.findApplication().getRelationshipManager()
def getObjectManagerID(self):
--- 284,293 ----
def getRelationshipManager(self):
! rm = self.findApplication().getRelationshipManager()
! if not rm:
! ZApp_LOG("Ack... can't find relationship manager!", ERROR)
! traceback.print_stack()
!
! return rm
def getObjectManagerID(self):
***************
*** 317,330 ****
A UI method to create and add an object..
"""
-
cond = {}
if objectProperties is not None:
! for k in objectProperties.keys():
! cond[k] = objectProperties[k]
!
if kw:
cond.update(kw)
self.createAndAddObject(objectProperties=cond, objectManager=objectManager, objectRole=objectRole, selfRole=selfRole, createIfNone=createIfNone, contextID=contextID)
--- 327,343 ----
A UI method to create and add an object..
"""
cond = {}
if objectProperties is not None:
! cond.update(objectProperties)
!
if kw:
cond.update(kw)
+ if REQUEST:
+ cond.update(REQUEST.form)
+
+ ZApp_LOG("createAndAddObject_ui:" + `cond` + ":" + `kw`, dbug_level)
+
self.createAndAddObject(objectProperties=cond, objectManager=objectManager, objectRole=objectRole, selfRole=selfRole, createIfNone=createIfNone, contextID=contextID)
***************
*** 374,378 ****
rm = self.getRelationshipManager()
! selfRItem = rm.relateObjects( object1=self, object1Role=selfRole, object2=otherObject, object2Role=objectRole, createIfNone=createIfNone, contextID=contextID)
return selfRItem
--- 387,395 ----
rm = self.getRelationshipManager()
! if rm:
! selfRItem = rm.relateObjects( object1=self, object1Role=selfRole, object2=otherObject, object2Role=objectRole, createIfNone=createIfNone, contextID=contextID)
! else:
! raise RuntimeError, "Can't find relationship manager!"
!
return selfRItem
|