[CMF-checkins] CVS: CMF/CMFDefault - DefaultWorkflow.py:1.11

Florent Guillaume fg@nuxeo.com
Sat, 29 Jun 2002 19:49:48 -0400


Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv16574/CMFDefault

Modified Files:
	DefaultWorkflow.py 
Log Message:
Correctly reindex the just-reset workflow variables of an object in a
DCWorkflow after a paste.

(I put the responsibility for this in CMFCatalogAware.manage_afterClone
and not in notifyCreated because the latter is called from other places
that already have do the reindexing for other reasons.)

Cleaned up DefaultWorkflow so that the notifySuccess & co methods are
not called twice, the WorkflowTool deals with that. Reindexing after a
workflow transition is also taken care of by WorkflowTool.



=== CMF/CMFDefault/DefaultWorkflow.py 1.10 => 1.11 ===
     def setReviewStateOf(self, ob, review_state, action, comment):
         tool = aq_parent(aq_inner(self))
-        tool.notifyBefore(ob, action)
-        try:
-            pm = getToolByName(self, 'portal_membership')
-            current_user = pm.getAuthenticatedMember().getUserName()
-            status = {
-                'actor': current_user,
-                'action': action,
-                'review_state': review_state,
-                'time': DateTime(),
-                'comments': comment,
-                }
-            tool.setStatusOf(self.getId(), ob, status)
-        except:
-            tool.notifyException(ob, action, sys.exc_info())
-            raise
-        else:
-            tool.notifySuccess(ob, action)
-            catalog = getToolByName(self, 'portal_catalog', None)
-            if catalog is not None:
-                catalog.reindexObject(ob)
+        pm = getToolByName(self, 'portal_membership')
+        current_user = pm.getAuthenticatedMember().getUserName()
+        status = {
+            'actor': current_user,
+            'action': action,
+            'review_state': review_state,
+            'time': DateTime(),
+            'comments': comment,
+            }
+        tool.setStatusOf(self.getId(), ob, status)
+        self.updateRoleMappingsFor(ob)
 
     security.declarePrivate('notifyCreated')
     def notifyCreated(self, ob):
@@ -258,7 +249,7 @@
         and put in its new place.
         '''
         self.setReviewStateOf( ob, 'private', 'joined', '' )
-        self.updateRoleMappingsFor(ob)
+        self.notifySuccess(ob, 'joined', '')
 
     security.declarePrivate('notifyBefore')
     def notifyBefore(self, ob, action):
@@ -275,7 +266,7 @@
         '''
         Notifies this workflow that an action has taken place.
         '''
-        self.updateRoleMappingsFor(ob)
+        pass
 
     security.declarePrivate('notifyException')
     def notifyException(self, ob, action, exc):