[CMF-checkins] SVN: CMF/branches/jens_tools_as_utilities/ - continuing work on utility conversion branch: portal_catalog

Jens Vagelpohl jens at dataflake.org
Tue Dec 26 07:55:13 EST 2006


Log message for revision 71651:
  - continuing work on utility conversion branch: portal_catalog
  

Changed:
  U   CMF/branches/jens_tools_as_utilities/CMFCalendar/tests/test_Calendar.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/CMFCatalogAware.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/CatalogTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/DiscussionTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/actions.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/cachingpolicymgr.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/catalog.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_actions.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_cachingpolicymgr.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_catalog.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/testing.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_CMFCatalogAware.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_CachingPolicyManager.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSDTMLMethod.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPageTemplate.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSReSTMethod.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSSTXMethod.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_OpaqueItems.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalContent.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalFolder.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/utils.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/DefaultWorkflow.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/Extensions/update_catalogIndexes.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/componentregistry.xml
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Discussions.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_File.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Image.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Portal.py
  U   CMF/branches/jens_tools_as_utilities/CMFTopic/Topic.py
  U   CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_DateC.py
  U   CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_Topic.py
  U   CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdHandlerTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFUid/tests/test_uidhandling.py
  U   CMF/branches/jens_tools_as_utilities/DCWorkflow/DCWorkflow.py
  U   CMF/branches/jens_tools_as_utilities/DCWorkflow/tests/test_DCWorkflow.py

-=-
Modified: CMF/branches/jens_tools_as_utilities/CMFCalendar/tests/test_Calendar.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCalendar/tests/test_Calendar.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCalendar/tests/test_Calendar.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -21,10 +21,13 @@
 
 import locale
 
+from zope.component import getSiteManager
+
 from AccessControl.SecurityManagement import newSecurityManager
 from AccessControl.User import UnrestrictedUser
 from DateTime import DateTime
 
+from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFCalendar.testing import FunctionalLayer
 
 
@@ -113,6 +116,10 @@
         sdm = self.app.session_data_manager
         self.app.REQUEST.set_lazy('SESSION', sdm.getSessionData)
 
+        # register utilities
+        sm = getSiteManager()
+        sm.registerUtility(self.app.site.portal_catalog, ICatalogTool)
+
     def _testURL(self, url, params=None):
         obj = self.app.site.restrictedTraverse(url)
         if params is None:

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/CMFCatalogAware.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/CMFCatalogAware.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/CMFCatalogAware.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -24,8 +24,10 @@
 from Globals import InitializeClass
 from OFS.interfaces import IObjectClonedEvent
 from OFS.interfaces import IObjectWillBeMovedEvent
+
 from zope.app.container.interfaces import IObjectAddedEvent
 from zope.app.container.interfaces import IObjectMovedEvent
+from zope.component import queryUtility
 from zope.component import subscribers
 
 from permissions import AccessContentsInformation
@@ -36,6 +38,7 @@
 from utils import getToolByName
 
 from interfaces import ICallableOpaqueItem
+from interfaces import ICatalogTool
 from interfaces.IOpaqueItems \
         import ICallableOpaqueItem as z2ICallableOpaqueItem
 
@@ -55,7 +58,7 @@
     # for a given content type
 
     def _getCatalogTool(self):
-        return getToolByName(self, 'portal_catalog', None)
+        return queryUtility(ICatalogTool)
 
     def _getWorkflowTool(self):
         return getToolByName(self, 'portal_workflow', None)

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/CatalogTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/CatalogTool.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/CatalogTool.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -44,6 +44,7 @@
 from utils import _getAuthenticatedUser
 from utils import _mergedLocalRoles
 from utils import getToolByName
+from utils import registerToolInterface
 from utils import UniqueObject
 
 
@@ -295,3 +296,4 @@
         self.catalog_object(object, uid, idxs, update_metadata)
 
 InitializeClass(CatalogTool)
+registerToolInterface('portal_catalog', ICatalogTool)

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/DiscussionTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/DiscussionTool.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/DiscussionTool.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -19,6 +19,8 @@
 from Globals import InitializeClass, DTMLFile
 from Acquisition import Implicit
 from AccessControl import ClassSecurityInfo
+
+from zope.component import getUtility
 from zope.interface import implements
 
 from ActionProviderBase import ActionProviderBase
@@ -26,6 +28,7 @@
 from permissions import ManagePortal
 from permissions import ReplyToItem
 from permissions import View
+from interfaces import ICatalogTool
 from interfaces import IOldstyleDiscussable
 from interfaces import IOldstyleDiscussionTool
 from interfaces.Discussions import OldDiscussable as z2IOldstyleDiscussable
@@ -91,7 +94,7 @@
             Often, the actual objects are not needed.  This is less expensive
             than fetching the objects.
         """
-        catalog = getToolByName(self.content, 'portal_catalog')
+        catalog = getUtility(ICatalogTool)
         return catalog.searchResults(in_reply_to=
                                       urllib.unquote('/'+self.absolute_url(1)))
 
@@ -101,7 +104,7 @@
             Return a sequence of the DiscussionResponse objects which are
             associated with this Discussable
         """
-        catalog = getToolByName(self.content, 'portal_catalog')
+        catalog = getUtility(ICatalogTool)
         results = self.getReplyResults()
         rids    = map(lambda x: x.data_record_id_, results)
         objects = map(catalog.getobject, rids)

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/actions.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/actions.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/actions.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -35,7 +35,7 @@
 from zope.component import adapts
 from zope.component import getUtility
 from zope.component import getSiteManager
-from zope.component.interfaces import ComponentLookupError
+from zope.component import queryUtility
 
 _SPECIAL_PROVIDERS = ('portal_actions', 'portal_types', 'portal_workflow')
 
@@ -258,9 +258,8 @@
     """Export actions tool.
     """
     sm = getSiteManager(context.getSite())
-    try:
-        tool = sm.getUtility(IActionsTool)
-    except ComponentLookupError:
+    tool = sm.queryUtility(IActionsTool)
+    if tool is None:
         logger = context.getLogger('actions')
         logger.info('Nothing to export.')
         return

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/cachingpolicymgr.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/cachingpolicymgr.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/cachingpolicymgr.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -19,7 +19,7 @@
 from zope.component import getUtility
 from zope.component import getSiteManager
 from zope.component import queryMultiAdapter
-from zope.component.interfaces import ComponentLookupError
+from zope.component import queryUtility
 
 from Products.GenericSetup.interfaces import INode
 from Products.GenericSetup.interfaces import ISetupEnviron
@@ -183,9 +183,8 @@
     """Export caching policy manager settings as an XML file.
     """
     sm = getSiteManager(context.getSite())
-    try:
-        tool = sm.getUtility(ICachingPolicyManager)
-    except ComponentLookupError:
+    tool = sm.queryUtility(ICachingPolicyManager)
+    if tool is None:
         logger = context.getLogger('cachingpolicies')
         logger.info('Nothing to export.')
         return

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/catalog.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/catalog.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/catalog.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -15,25 +15,28 @@
 $Id$
 """
 
+from Products.CMFCore.interfaces import ICatalogTool
 from Products.GenericSetup.utils import exportObjects
 from Products.GenericSetup.utils import importObjects
 
-from Products.CMFCore.utils import getToolByName
+from zope.component import getSiteManager
+from zope.component import getUtility
+from zope.component import queryUtility
 
 
 def importCatalogTool(context):
     """Import catalog tool.
     """
-    site = context.getSite()
-    tool = getToolByName(site, 'portal_catalog')
+    sm = getSiteManager(context.getSite())
+    tool = sm.getUtility(ICatalogTool)
 
     importObjects(tool, '', context)
 
 def exportCatalogTool(context):
     """Export catalog tool.
     """
-    site = context.getSite()
-    tool = getToolByName(site, 'portal_catalog', None)
+    sm = getSiteManager(context.getSite())
+    tool = sm.queryUtility(ICatalogTool)
     if tool is None:
         logger = context.getLogger('catalog')
         logger.info('Nothing to export.')

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_actions.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_actions.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_actions.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -330,7 +330,7 @@
         self.assertEqual(obj.action_providers[0], 'portal_actions')
 
     def setUp(self):
-        from Products.CMFCore.interfaces._tools import IActionsTool
+        from Products.CMFCore.interfaces import IActionsTool
         from Products.CMFCore.ActionsTool import ActionsTool
         from zope.component import getGlobalSiteManager
 

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_cachingpolicymgr.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_cachingpolicymgr.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_cachingpolicymgr.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -26,7 +26,7 @@
 from Products.GenericSetup.tests.common import DummyExportContext
 from Products.GenericSetup.tests.common import DummyImportContext
 
-from Products.CMFCore.interfaces._tools import ICachingPolicyManager
+from Products.CMFCore.interfaces import ICachingPolicyManager
 from Products.CMFCore.testing import ExportImportZCMLLayer
 
 from zope.component import getSiteManager

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_catalog.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_catalog.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_catalog.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -25,11 +25,14 @@
 from Products.ZCTextIndex.Lexicon import StopWordRemover
 from Products.ZCTextIndex.ZCTextIndex import PLexicon
 
+from zope.component import getSiteManager
+
 from Products.GenericSetup.tests.common import BaseRegistryTests
 from Products.GenericSetup.tests.common import DummyExportContext
 from Products.GenericSetup.tests.common import DummyImportContext
 
 from Products.CMFCore.CatalogTool import CatalogTool
+from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFCore.testing import ExportImportZCMLLayer
 
 _EMPTY_EXPORT = """\
@@ -79,6 +82,9 @@
         site = self.root.site = Folder(id='site')
         ctool = site.portal_catalog = CatalogTool()
 
+        sm = getSiteManager(site)
+        sm.registerUtility(ctool, ICatalogTool)
+
         for obj_id in ctool.objectIds():
             ctool._delObject(obj_id)
         for idx_id in ctool.indexes():

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/testing.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/testing.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/testing.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -130,6 +130,7 @@
         zcml.load_config('meta.zcml', Products.Five)
         zcml.load_config('event.zcml', Products.Five)
         zcml.load_config('event.zcml', Products.CMFCore)
+        setHooks()
 
     @classmethod
     def tearDown(cls):
@@ -151,6 +152,23 @@
         cleanUp()
 
 
+class TraversingEventZCMLLayer:
+
+    @classmethod
+    def setUp(cls):
+        import Products.Five
+
+        zcml.load_config('meta.zcml', Products.Five)
+        zcml.load_config('traversing.zcml', Products.Five)
+        zcml.load_config('event.zcml', Products.Five)
+        zcml.load_config('event.zcml', Products.CMFCore)
+        setHooks()
+
+    @classmethod
+    def tearDown(cls):
+        cleanUp()
+
+
 class FunctionalZCMLLayer:
 
     @classmethod

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_CMFCatalogAware.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_CMFCatalogAware.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_CMFCatalogAware.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -22,12 +22,16 @@
 from AccessControl.SecurityManagement import newSecurityManager
 from OFS.Folder import Folder
 from OFS.SimpleItem import SimpleItem
+
+from zope.component import getSiteManager
 from zope.interface import implements
 
 from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
 from Products.CMFCore.exceptions import NotFound
+from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFCore.interfaces import IContentish
 from Products.CMFCore.testing import EventZCMLLayer
+from Products.CMFCore.testing import TraversingZCMLLayer
 from Products.CMFCore.tests.test_PortalFolder import _AllowedUser
 from Products.CMFCore.tests.test_PortalFolder import _SensitiveSecurityPolicy
 from Products.CMFCore.tests.base.testcase import LogInterceptor
@@ -115,11 +119,15 @@
 
 class CMFCatalogAwareTests(unittest.TestCase, LogInterceptor):
 
+    layer = TraversingZCMLLayer
+
     def setUp(self):
         self.root = DummyRoot('')
         self.root.site = SimpleFolder('site')
         self.site = self.root.site
+        sm = getSiteManager(self.site)
         self.site._setObject('portal_catalog', DummyCatalog())
+        sm.registerUtility(self.site.portal_catalog, ICatalogTool)
         self.site._setObject('portal_workflow', DummyWorkflowTool())
         self.site.foo = TheClass('foo')
 
@@ -219,8 +227,10 @@
 
     def _makeSite(self):
         self.app._setObject('site', SimpleFolder('site'))
+        sm = getSiteManager(self.app.site)
         site = self.app._getOb('site')
         site._setObject('portal_catalog', DummyCatalog())
+        sm.registerUtility(site.portal_catalog, ICatalogTool)
         site._setObject('portal_workflow', DummyWorkflowTool())
         # Hack, we need a _p_mtime for the file, so we make sure that it
         # has one. We use a subtransaction, which means we can rollback

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_CachingPolicyManager.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_CachingPolicyManager.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_CachingPolicyManager.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -41,7 +41,7 @@
 from Products.CMFCore.tests.base.dummy import DummyUserFolder
 from Products.CMFCore.tests.base.testcase import FSDVTest
 from Products.CMFCore.tests.base.testcase import RequestTest
-from Products.CMFCore.interfaces._tools import ICachingPolicyManager
+from Products.CMFCore.interfaces import ICachingPolicyManager
 
 ACCLARK = DateTime( '2001/01/01' )
 portal_owner = 'portal_owner'

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSDTMLMethod.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSDTMLMethod.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSDTMLMethod.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -26,7 +26,7 @@
 
 from Products.CMFCore.FSDTMLMethod import FSDTMLMethod
 from Products.CMFCore.FSMetadata import FSMetadata
-from Products.CMFCore.interfaces._tools import ICachingPolicyManager
+from Products.CMFCore.interfaces import ICachingPolicyManager
 from Products.CMFCore.tests.base.dummy import DummyCachingManager
 from Products.CMFCore.tests.base.dummy import DummyCachingManagerWithPolicy
 from Products.CMFCore.tests.base.testcase import FSDVTest

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPageTemplate.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPageTemplate.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPageTemplate.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -30,7 +30,7 @@
 
 from Products.CMFCore.FSPageTemplate import FSPageTemplate
 from Products.CMFCore.FSMetadata import FSMetadata
-from Products.CMFCore.interfaces._tools import ICachingPolicyManager
+from Products.CMFCore.interfaces import ICachingPolicyManager
 from Products.CMFCore.testing import TraversingZCMLLayer
 from Products.CMFCore.tests.base.dummy import DummyCachingManager
 from Products.CMFCore.tests.base.testcase import FSDVTest

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSReSTMethod.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSReSTMethod.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSReSTMethod.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -20,7 +20,7 @@
 
 from zope.component import getSiteManager
 
-from Products.CMFCore.interfaces._tools import ICachingPolicyManager
+from Products.CMFCore.interfaces import ICachingPolicyManager
 from Products.CMFCore.testing import TraversingZCMLLayer
 from Products.CMFCore.tests.base.testcase import FSDVTest
 from Products.CMFCore.tests.base.testcase import RequestTest

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSSTXMethod.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSSTXMethod.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSSTXMethod.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -20,7 +20,7 @@
 
 from zope.component import getSiteManager
 
-from Products.CMFCore.interfaces._tools import ICachingPolicyManager
+from Products.CMFCore.interfaces import ICachingPolicyManager
 from Products.CMFCore.testing import TraversingZCMLLayer
 from Products.CMFCore.tests.base.testcase import FSDVTest
 from Products.CMFCore.tests.base.testcase import RequestTest

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_OpaqueItems.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_OpaqueItems.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_OpaqueItems.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -28,7 +28,7 @@
 from Products.CMFCore.interfaces.IOpaqueItems \
         import ICallableOpaqueItemEvents as z2ICallableOpaqueItemEvents
 from Products.CMFCore.PortalFolder import PortalFolder
-from Products.CMFCore.testing import EventZCMLLayer
+from Products.CMFCore.testing import TraversingEventZCMLLayer
 from Products.CMFCore.tests.base.dummy \
     import DummyContent as OriginalDummyContent
 from Products.CMFCore.tests.base.testcase import SecurityTest
@@ -140,7 +140,7 @@
 
 class ManageBeforeAfterTests(SecurityTest):
 
-    layer = EventZCMLLayer
+    layer = TraversingEventZCMLLayer
 
     def setUp(self):
         SecurityTest.setUp(self)

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalContent.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalContent.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalContent.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -23,7 +23,7 @@
 from OFS.Folder import Folder
 
 from Products.CMFCore.exceptions import NotFound
-from Products.CMFCore.testing import EventZCMLLayer
+from Products.CMFCore.testing import TraversingEventZCMLLayer
 from Products.CMFCore.tests.base.dummy import DummyContent
 from Products.CMFCore.tests.base.dummy import DummyObject
 from Products.CMFCore.tests.base.dummy import DummySite
@@ -95,7 +95,7 @@
     # Tests related to http://www.zope.org/Collectors/CMF/205
     # Copy/pasting a content item must set ownership to pasting user
 
-    layer = EventZCMLLayer
+    layer = TraversingEventZCMLLayer
 
     def setUp(self):
         SecurityRequestTest.setUp(self)

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalFolder.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalFolder.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_PortalFolder.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -26,14 +26,17 @@
 from Acquisition import Implicit
 from DateTime import DateTime
 from OFS.Image import manage_addFile
+
 from zope.component import getGlobalSiteManager
+from zope.component import getSiteManager
 from zope.component.interfaces import IFactory
 
 from Products.CMFCore.CatalogTool import CatalogTool
 from Products.CMFCore.exceptions import BadRequest
+from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFCore.testing import ConformsToFolder
-from Products.CMFCore.testing import EventZCMLLayer
 from Products.CMFCore.testing import FunctionalZCMLLayer
+from Products.CMFCore.testing import TraversingEventZCMLLayer
 from Products.CMFCore.tests.base.dummy import DummyContent
 from Products.CMFCore.tests.base.dummy import DummyFactoryDispatcher
 from Products.CMFCore.tests.base.dummy import DummySite
@@ -55,7 +58,7 @@
 
 class PortalFolderFactoryTests(SecurityTest):
 
-    layer = EventZCMLLayer
+    layer = TraversingEventZCMLLayer
     _PORTAL_TYPE = 'Test Folder'
 
     def _getTargetObject(self):
@@ -217,9 +220,11 @@
         # Test is a new object does get cataloged upon _setObject
         # and uncataloged upon manage_deleteObjects
         #
+        sm = getSiteManager(self.site)
         test = self._makeOne('test')
         ttool = self.site._setObject( 'portal_types', TypesTool() )
         ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
+        sm.registerUtility(ctool, ICatalogTool)
         self.assertEqual( len(ctool), 0 )
 
         test._setObject( 'foo', DummyContent( 'foo' , catalog=1 ) )
@@ -239,8 +244,10 @@
         # Test to ensure a portal folder itself is *not* cataloged upon
         # instantiation (Tracker issue 309)
         #
+        sm = getSiteManager(self.site)
         ttool = self.site._setObject( 'portal_types', TypesTool() )
         ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
+        sm.registerUtility(ctool, ICatalogTool)
         wftool = self.site._setObject( 'portal_workflow', WorkflowTool() )
         test = self._makeOne('test')
         wftool.notifyCreated(test)
@@ -254,9 +261,11 @@
         #
         from Products.CMFCore.PortalFolder import PortalFolder
 
+        sm = getSiteManager(self.site)
         test = self._makeOne('test')
         ttool = self.site._setObject( 'portal_types', TypesTool() )
         ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
+        sm.registerUtility(ctool, ICatalogTool)
         self.assertEqual( len(ctool), 0 )
 
         test._setObject( 'sub', PortalFolder( 'sub', '' ) )
@@ -425,7 +434,7 @@
 
 class PortalFolderMoveTests(SecurityTest):
 
-    layer = EventZCMLLayer
+    layer = TraversingEventZCMLLayer
 
     def setUp(self):
         SecurityTest.setUp(self)
@@ -443,8 +452,10 @@
         #
         from Products.CMFCore.PortalFolder import PortalFolder
 
+        sm = getSiteManager(self.site)
         ttool = self.site._setObject( 'portal_types', TypesTool() )
         ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
+        sm.registerUtility(ctool, ICatalogTool)
         ctool.addIndex('getId', 'FieldIndex')
         self.assertEqual( len(ctool), 0 )
 
@@ -489,7 +500,9 @@
         #
         #   Does copy / paste work?
         #
+        sm = getSiteManager(self.site)
         ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
+        sm.registerUtility(ctool, ICatalogTool)
         ttool = self.site._setObject( 'portal_types', TypesTool() )
         fti = FTIDATA_DUMMY[0].copy()
         ttool._setObject( 'Dummy Content', FTI(**fti) )

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/utils.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/utils.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/utils.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -47,12 +47,13 @@
 from thread import allocate_lock
 from webdav.common import rfc1123_date
 from zope.component import getUtility
+from zope.component import queryUtility
 from zope.component.interfaces import ComponentLookupError
 from zope.i18nmessageid import MessageFactory
 
 from exceptions import AccessControl_Unauthorized
 from exceptions import NotFound
-from interfaces._tools import ICachingPolicyManager
+from interfaces import ICachingPolicyManager
 
 SUBTEMPLATE = '__SUBTEMPLATE__'
 
@@ -332,9 +333,8 @@
         # not a conditional GET
         return False
 
-    try:
-        manager = getUtility(ICachingPolicyManager)
-    except ComponentLookupError:
+    manager = queryUtility(ICachingPolicyManager)
+    if manager is None:
         return False
 
     ret = manager.getModTimeAndETag(aq_parent(obj), obj.getId(), extra_context)
@@ -414,9 +414,8 @@
         delattr(REQUEST, SUBTEMPLATE)
 
         content = aq_parent(obj)
-        try:
-            manager = getUtility(ICachingPolicyManager)
-        except ComponentLookupError:
+        manager = queryUtility(ICachingPolicyManager)
+        if manager is None:
             return
 
         view_name = obj.getId()

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/DefaultWorkflow.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/DefaultWorkflow.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/DefaultWorkflow.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -21,8 +21,11 @@
 from AccessControl import ClassSecurityInfo
 from DateTime import DateTime
 from Globals import InitializeClass
+
+from zope.component import queryUtility
 from zope.interface import implements
 
+from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFCore.interfaces import IWorkflowDefinition
 from Products.CMFCore.interfaces.portal_workflow \
         import WorkflowDefinition as z2IWorkflowDefinition
@@ -156,18 +159,20 @@
             return None
 
         actions = []
-        catalog = getToolByName(self, 'portal_catalog', None)
-        if catalog is not None:
-            pending = len(catalog.searchResults(
-                review_state='pending'))
-            if pending > 0:
-                actions.append(
-                    {'name': 'Pending review (%d)' % pending,
-                     'url': info.portal_url +
-                     '/search?review_state=pending',
-                     'permissions': (ReviewPortalContent, ),
-                     'category': 'global'}
-                    )
+        catalog = query(ICatalogTool)
+        if catalog is None:
+            return actions
+
+        pending = len(catalog.searchResults(review_state='pending'))
+        if pending > 0:
+            actions.append(
+                {'name': 'Pending review (%d)' % pending,
+                 'url': info.portal_url +
+                 '/search?review_state=pending',
+                 'permissions': (ReviewPortalContent, ),
+                 'category': 'global'}
+                )
+
         return actions
 
     security.declarePrivate('isActionSupported')

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/Extensions/update_catalogIndexes.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/Extensions/update_catalogIndexes.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/Extensions/update_catalogIndexes.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -1,4 +1,5 @@
-from Products.CMFCore.utils import getToolByName
+from zope.component import queryUtility
+from Products.CMFCore.interfaces import ICatalogTool
 
 def update_catalogIndexes(self, REQUEST):
     '''
@@ -8,7 +9,7 @@
     rIndexes = {'allowedRolesAndUsers': 'KeywordIndex'
               , 'effective': 'FieldIndex'
               , 'expires': 'FieldIndex'}
-    ct = getToolByName(self, 'portal_catalog')
+    ct = queryUtility(ICatalogTool)
     map(lambda x, ct=ct: ct.delIndex(x), rIndexes.keys())
     map(lambda x, ct=ct: ct.addIndex(x[0], x[1]), rIndexes.items()) 
     ct.manage_reindexIndex(ids=rIndexes.keys(), REQUEST=REQUEST)

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/componentregistry.xml
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/componentregistry.xml	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/componentregistry.xml	2006-12-26 12:55:10 UTC (rev 71651)
@@ -8,5 +8,8 @@
   <utility
      interface="Products.CMFCore.interfaces._tools.ICachingPolicyManager"
      object="/caching_policy_manager"/>
+  <utility
+     interface="Products.CMFCore.interfaces._tools.ICatalogTool"
+     object="/portal_catalog"/>
  </utilities>
 </componentregistry>

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Discussions.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Discussions.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Discussions.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -18,7 +18,11 @@
 import unittest
 import Testing
 
+from zope.component import getSiteManager
+
+
 from Products.CMFCore.CatalogTool import CatalogTool
+from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFCore.testing import EventZCMLLayer
 from Products.CMFCore.tests.base.dummy import DummyContent
 from Products.CMFCore.tests.base.dummy import DummySite
@@ -196,7 +200,9 @@
         assert parents[ 0 ] == reply1
 
     def test_itemCataloguing( self ):
+        sm = getSiteManager(self.site)
         ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
+        sm.registerUtility(ctool, ICatalogTool)
         dtool = self.site.portal_discussion
         catalog = ctool._catalog
         test = self._makeDummyContent('test', catalog=1)
@@ -258,7 +264,9 @@
                 DiscussionItem.notifyWorkflowCreated = old_method
 
     def test_deletePropagation( self ):
+        sm = getSiteManager(self.site)
         ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
+        sm.registerUtility(ctool, ICatalogTool)
         dtool = self.site.portal_discussion
         test = self._makeDummyContent('test', catalog=1)
         test.allow_discussion = 1
@@ -272,8 +280,10 @@
         self.assertEqual( len(ctool), 0 )
 
     def test_deleteReplies(self):
+        sm = getSiteManager(self.site)
         dtool = self.site.portal_discussion
         ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
+        sm.registerUtility(ctool, ICatalogTool)
         test = self._makeDummyContent('test')
         test.allow_discussion = 1
 

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_File.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_File.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_File.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -23,7 +23,7 @@
 from zope.app.component.hooks import setHooks
 from zope.component import getSiteManager
 
-from Products.CMFCore.interfaces._tools import ICachingPolicyManager
+from Products.CMFCore.interfaces import ICachingPolicyManager
 from Products.CMFCore.testing import ConformsToContent
 from Products.CMFCore.tests.base.dummy import DummyCachingManagerWithPolicy
 from Products.CMFCore.tests.base.dummy import DummyCachingManager

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Image.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Image.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Image.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -28,7 +28,7 @@
 from AccessControl.SecurityManagement import newSecurityManager
 from AccessControl.User import UnrestrictedUser
 
-from Products.CMFCore.interfaces._tools import ICachingPolicyManager
+from Products.CMFCore.interfaces import ICachingPolicyManager
 from Products.CMFCore.testing import ConformsToContent
 from Products.CMFCore.tests.base.dummy import DummyCachingManager
 from Products.CMFCore.tests.base.dummy import DummyCachingManagerWithPolicy

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Portal.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Portal.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_Portal.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -22,6 +22,9 @@
 from AccessControl.User import UnrestrictedUser
 from Acquisition import aq_base
 
+from zope.component import getSiteManager
+
+from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFDefault.testing import FunctionalLayer
 
 
@@ -29,6 +32,12 @@
 
     layer = FunctionalLayer
 
+    def afterSetUp(self):
+        ZopeTestCase.FunctionalTestCase.afterSetUp(self)
+
+        sm = getSiteManager()
+        sm.registerUtility(self.app.site.portal_catalog, ICatalogTool)
+
     def _makeContent( self, site, portal_type, id='document', **kw ):
         newSecurityManager(None, UnrestrictedUser('god', '', ['Manager'], ''))
 

Modified: CMF/branches/jens_tools_as_utilities/CMFTopic/Topic.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFTopic/Topic.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFTopic/Topic.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -18,10 +18,13 @@
 from AccessControl import ClassSecurityInfo
 from Acquisition import aq_parent, aq_inner
 from Globals import InitializeClass
+
+from zope.component import getUtility
 from zope.component.factory import Factory
 from zope.interface import implements
 
 from Products.CMFDefault.SkinnedFolder import SkinnedFolder
+from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFCore.utils import getToolByName
 
 from interfaces import IMutableTopic
@@ -80,7 +83,7 @@
     def listAvailableFields(self):
         """ Return a list of available fields for new criteria.
         """
-        portal_catalog = getToolByName( self, 'portal_catalog' )
+        portal_catalog = getUtility(ICatalogTool)
         currentfields = map( lambda x: x.Field(), self.listCriteria() )
         availfields = filter(
             lambda field, cf=currentfields: field not in cf,
@@ -140,7 +143,7 @@
         o Built-in criteria update any criteria passed in 'kw'.
         """
         kw.update( self.buildQuery() )
-        portal_catalog = getToolByName( self, 'portal_catalog' )
+        portal_catalog = getUtility(ICatalogTool)
         return portal_catalog.searchResults(REQUEST, **kw)
 
     security.declareProtected(View, 'synContentValues')

Modified: CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_DateC.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_DateC.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_DateC.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -18,8 +18,11 @@
 import unittest
 from Testing import ZopeTestCase
 
+from zope.component import getSiteManager
+
 from DateTime.DateTime import DateTime
 
+from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFCore.tests.base.dummy import DummyContent
 from Products.CMFDefault.testing import FunctionalLayer
 from Products.CMFTopic.Topic import Topic
@@ -161,6 +164,8 @@
 
     def afterSetUp(self):
         self.site = self.app.site
+        sm = getSiteManager()
+        sm.registerUtility(self.site.portal_catalog, ICatalogTool)
         self.site._setObject( 'topic', Topic('topic') )
         self.topic = self.site.topic
         self.topic.addCriterion('modified', 'Friendly Date Criterion')

Modified: CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_Topic.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_Topic.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFTopic/tests/test_Topic.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -21,6 +21,9 @@
 
 from Acquisition import Implicit
 
+from zope.component import getSiteManager
+
+from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFCore.testing import ConformsToFolder
 from Products.CMFCore.testing import EventZCMLLayer
 from Products.CMFCore.tests.base.dummy import DummySite
@@ -62,7 +65,7 @@
         for index_id in index_ids:
             self._indexes[ index_id ] = {}
 
-    def _index( self, obj ):
+    def _index( self, obj, idxs=[] ):
 
         marker = object()
         self._objects.append( obj )
@@ -80,6 +83,8 @@
 
     indexObject = _index
 
+    reindexObject = _index
+
     def searchResults( self, REQUEST=None, **kw ):
 
         limit = None
@@ -136,7 +141,9 @@
                                     self._getTargetClass()(id, *args, **kw))
 
     def _initSite(self, max_items=15, index_ids=()):
+        sm = getSiteManager(self.site)
         self.site.portal_catalog = DummyCatalog( index_ids )
+        sm.registerUtility(self.site.portal_catalog, ICatalogTool)
         self.site.portal_syndication = DummySyndicationTool( max_items )
 
     def _initDocuments(self, **kw):

Modified: CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdHandlerTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdHandlerTool.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdHandlerTool.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -27,9 +27,12 @@
 from Globals import package_home
 from OFS.SimpleItem import SimpleItem
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+
+from zope.component import getUtility
 from zope.interface import implements
 
 from Products.CMFCore.ActionProviderBase import ActionProviderBase
+from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFCore.permissions import ManagePortal
 from Products.CMFCore.utils import getToolByName
 from Products.CMFCore.utils import UniqueObject
@@ -80,7 +83,7 @@
     def _reindexObject(self, obj):
         # add uid index and colums to catalog if not yet done
         UID_ATTRIBUTE_NAME = self.UID_ATTRIBUTE_NAME
-        catalog = getToolByName(self, 'portal_catalog')
+        catalog = getUtility(ICatalogTool)
         if UID_ATTRIBUTE_NAME not in catalog.indexes():
             catalog.addIndex(UID_ATTRIBUTE_NAME, 'FieldIndex')
             catalog.addColumn(UID_ATTRIBUTE_NAME)
@@ -179,7 +182,7 @@
         generator = getToolByName(self, 'portal_uidgenerator')
         uid = generator.convert(uid)
 
-        catalog = getToolByName(self, 'portal_catalog')
+        catalog = getUtility(ICatalogTool)
         searchMethod = getattr(catalog, searchMethodName)
         result = searchMethod({self.UID_ATTRIBUTE_NAME: uid})
         len_result = len(result)

Modified: CMF/branches/jens_tools_as_utilities/CMFUid/tests/test_uidhandling.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFUid/tests/test_uidhandling.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/CMFUid/tests/test_uidhandling.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -18,6 +18,9 @@
 import unittest
 import Testing
 
+from zope.component import getSiteManager
+
+from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFCore.tests.base.dummy import DummyContent
 from Products.CMFCore.tests.base.dummy import DummyFolder
 from Products.CMFCore.tests.base.dummy import DummySite
@@ -51,6 +54,9 @@
         self.root._setObject('dummy', DummyContent(id='dummy'))
         self.root._setObject('dummy2', DummyContent(id='dummy2'))
 
+        sm = getSiteManager()
+        sm.registerUtility(self.root.portal_catalog, ICatalogTool)
+
     def test_z3interfaces(self):
         from zope.interface.verify import verifyClass
         from Products.CMFUid.interfaces import IUniqueIdBrainQuery

Modified: CMF/branches/jens_tools_as_utilities/DCWorkflow/DCWorkflow.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/DCWorkflow/DCWorkflow.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/DCWorkflow/DCWorkflow.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -25,13 +25,15 @@
 from Globals import InitializeClass
 from OFS.Folder import Folder
 from OFS.ObjectManager import bad_id
+
+from zope.component import getUtility
 from zope.interface import implements
 
 # CMFCore
+from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFCore.interfaces import IWorkflowDefinition
 from Products.CMFCore.interfaces.portal_workflow \
         import WorkflowDefinition as z2IWorkflowDefinition
-from Products.CMFCore.utils import getToolByName
 from Products.CMFCore.WorkflowCore import ObjectDeleted
 from Products.CMFCore.WorkflowCore import ObjectMoved
 from Products.CMFCore.WorkflowCore import WorkflowException
@@ -230,7 +232,7 @@
                     var_match_keys = qdef.getVarMatchKeys()
                     if var_match_keys:
                         # Check the catalog for items in the worklist.
-                        catalog = getToolByName(self, 'portal_catalog')
+                        catalog = getUtility(ICatalogTool)
                         kw = {}
                         for k in var_match_keys:
                             v = qdef.getVarMatch(k)

Modified: CMF/branches/jens_tools_as_utilities/DCWorkflow/tests/test_DCWorkflow.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/DCWorkflow/tests/test_DCWorkflow.py	2006-12-25 20:03:18 UTC (rev 71650)
+++ CMF/branches/jens_tools_as_utilities/DCWorkflow/tests/test_DCWorkflow.py	2006-12-26 12:55:10 UTC (rev 71651)
@@ -18,6 +18,7 @@
 import unittest
 import Testing
 
+from Products.CMFCore.testing import TraversingZCMLLayer
 from Products.CMFCore.tests.base.dummy import DummyContent
 from Products.CMFCore.tests.base.dummy import DummySite
 from Products.CMFCore.tests.base.dummy import DummyTool
@@ -26,6 +27,8 @@
 
 class DCWorkflowDefinitionTests(unittest.TestCase):
 
+    layer = TraversingZCMLLayer
+
     def setUp(self):
         self.site = DummySite('site')
         self.site._setObject( 'portal_types', DummyTool() )



More information about the CMF-checkins mailing list