[CMF-checkins] CVS: CMF/CMFCore - WorkflowCore.py:1.11 WorkflowTool.py:1.27

Florent Guillaume fg@nuxeo.com
Wed, 24 Jul 2002 08:33:51 -0400


Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv27997

Modified Files:
	WorkflowCore.py WorkflowTool.py 
Log Message:
Made the workflow-related reindexing go through ob.reindexObject instead
of using portal_catalog directly. That way we get more flexibility, and
the workflow doesn't reindex object that don't want to be reindexed.

Note that the code changed in WorkflowCore was buggy (no "ob") and thus
probably had never been exercized (only called if there is a
workflowMethod called without a portal_workflow).



=== CMF/CMFCore/WorkflowCore.py 1.10 => 1.11 ===
             except ObjectDeleted, ex:
                 res = ex.getResult()
             else:
-                catalog = getToolByName(instance, 'portal_catalog', None)
-                if catalog is not None:
-                    catalog.reindexObject(ob)
+                if hasattr(aq_base(instance), 'reindexObject'):
+                    instance.reindexObject()
         else:
             res = wf.wrapWorkflowMethod(instance, self._id, self._m,
                                         (instance,) + args, kw)


=== CMF/CMFCore/WorkflowTool.py 1.26 => 1.27 ===
             if hasattr(aq_base(wf), 'updateRoleMappingsFor'):
                 wfs[id] = wf
         portal = aq_parent(aq_inner(self))
-        catalog = getToolByName(self, 'portal_catalog', None)
-        count = self._recursiveUpdateRoleMappings(portal, wfs, catalog)
+        count = self._recursiveUpdateRoleMappings(portal, wfs)
         if REQUEST is not None:
             return self.manage_selectWorkflows(REQUEST, manage_tabs_message=
                                                '%d object(s) updated.' % count)
@@ -642,7 +641,7 @@
         return res
 
     security.declarePrivate( '_recursiveUpdateRoleMappings' )
-    def _recursiveUpdateRoleMappings(self, ob, wfs, catalog):
+    def _recursiveUpdateRoleMappings(self, ob, wfs):
 
         """ Update roles-permission mappings recursively, and
             reindex special index.
@@ -660,16 +659,15 @@
                         changed = 1
             if changed:
                 count = count + 1
-                if catalog is not None:
+                if hasattr(aq_base(ob), 'reindexObject'):
                     # Reindex security-related indexes
-                    catalog.reindexObject(ob, idxs=['allowedRolesAndUsers'])
+                    ob.reindexObject(idxs=['allowedRolesAndUsers'])
         if hasattr(aq_base(ob), 'objectItems'):
             obs = ob.objectItems()
             if obs:
                 for k, v in obs:
                     changed = getattr(v, '_p_changed', 0)
-                    count = count + self._recursiveUpdateRoleMappings(v, wfs,
-                                                                      catalog)
+                    count = count + self._recursiveUpdateRoleMappings(v, wfs)
                     if changed is None:
                         # Re-ghostify.
                         v._p_deactivate()
@@ -692,13 +690,12 @@
         if not self._default_cataloging:
             return
 
-        catalog = getToolByName(self, 'portal_catalog', None)
-        if catalog is not None:
+        if hasattr(aq_base(ob), 'reindexObject'):
             # XXX We only need the keys here, no need to compute values.
             mapping = self.getCatalogVariablesFor(ob) or {}
             mapping['allowedRolesAndUsers'] = None
             vars = mapping.keys()
-            catalog.reindexObject(ob, idxs=vars)
+            ob.reindexObject(idxs=vars)
 
 InitializeClass(WorkflowTool)