[CMF-checkins] CVS: CMF - WorkflowCore.py:1.6 WorkflowTool.py:1.10
shane@digicool.com
shane@digicool.com
Tue, 12 Jun 2001 12:17:37 -0400 (EDT)
Update of /cvs-repository/CMF/CMFCore
In directory korak.digicool.com:/tmp/cvs-serv1285
Modified Files:
WorkflowCore.py WorkflowTool.py
Log Message:
Added two new exception types:
- NoReindex, to prevent an object from being reindexed by the workflow tool.
- ObjectMoved, to indicate to the workflow tool that an object has moved
to a new location.
--- Updated File WorkflowCore.py in package CMF --
--- WorkflowCore.py 2001/05/22 20:33:42 1.5
+++ WorkflowCore.py 2001/06/12 16:17:24 1.6
@@ -99,6 +99,25 @@
'''
+class NoReindex (Exception):
+ '''
+ Raised to tell the workflow tool not to reindex the object.
+ Swallowed by the workflow tool.
+ '''
+
+
+class ObjectMoved (Exception):
+ '''
+ Raised to tell the workflow tool that the object has moved.
+ Swallowed by the workflow tool.
+ '''
+ def __init__(self, ob):
+ self._ob = ob # Includes acquisition wrappers.
+
+ def getNewObject(self):
+ return self._ob
+
+
class WorkflowMethod (Method):
'''
Wraps a method to workflow-enable it.
@@ -118,8 +137,15 @@
'''
wf = getToolByName(instance, 'portal_workflow', None)
if wf is None or not hasattr(wf, 'wrapWorkflowMethod'):
- # No workflow found.
- res = apply(self._m, (instance,) + args, kw)
+ # No workflow tool found.
+ try:
+ res = apply(self._m, (instance,) + args, kw)
+ except NoReindex:
+ pass
+ else:
+ catalog = getToolByName(instance, 'portal_catalog', None)
+ if catalog is not None:
+ catalog.reindexObject(ob)
else:
res = wf.wrapWorkflowMethod(instance, self._id, self._m,
(instance,) + args, kw)
--- Updated File WorkflowTool.py in package CMF --
--- WorkflowTool.py 2001/06/11 20:34:29 1.9
+++ WorkflowTool.py 2001/06/12 16:17:24 1.10
@@ -95,7 +95,7 @@
from Globals import InitializeClass, PersistentMapping, DTMLFile
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base, aq_inner, aq_parent
-from WorkflowCore import WorkflowException
+from WorkflowCore import WorkflowException, NoReindex, ObjectMoved
import CMFCorePermissions
from string import join, split, replace, strip
@@ -420,10 +420,15 @@
'''
Private utility method.
'''
+ reindex = 1
for w in wfs:
w.notifyBefore(ob, action)
try:
res = apply(func, args, kw)
+ except NoReindex:
+ reindex = 0
+ except ObjectMoved, ex:
+ ob = ex.getNewObject()
except:
exc = sys.exc_info()
try:
@@ -432,9 +437,9 @@
raise exc[0], exc[1], exc[2]
finally:
exc = None
- else:
- for w in wfs:
- w.notifySuccess(ob, action, res)
+ for w in wfs:
+ w.notifySuccess(ob, action, res)
+ if reindex:
catalog = getToolByName(ob, 'portal_catalog', None)
if catalog is not None:
catalog.reindexObject(ob)