[CMF-checkins] CVS: CMF/CMFCore - WorkflowCore.py:1.10.36.1 WorkflowTool.py:1.24.4.3

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


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

Modified Files:
      Tag: CMF-1_3-branch
	WorkflowCore.py WorkflowTool.py 
Log Message:
Merged changes from HEAD:

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 objects that don't want to be reindexed.



=== CMF/CMFCore/WorkflowCore.py 1.10 => 1.10.36.1 ===
             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.24.4.2 => 1.24.4.3 ===
             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)