[CMF-checkins] SVN: CMF/branches/jens_tools_as_utilities/CMF - another checkpoint checkin with more tools, but odd unit test behavior

Jens Vagelpohl jens at dataflake.org
Tue Dec 26 15:42:57 EST 2006


Log message for revision 71654:
  - another checkpoint checkin with more tools, but odd unit test behavior
  

Changed:
  U   CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.py
  U   CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.txt
  U   CMF/branches/jens_tools_as_utilities/CMFCalendar/setuphandlers.py
  U   CMF/branches/jens_tools_as_utilities/CMFCalendar/tests/test_Calendar.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/FSObject.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/MemberDataTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/MembershipTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/PortalObject.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/Skinnable.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/SkinsTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/skins.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_skins.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_FSPropertiesObject.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPythonScript.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_FSZSQLMethod.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_SkinsTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/DublinCore.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/MetadataTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/PropertiesTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/RegistrationTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/formlib/schema.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/componentregistry.xml
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/import_steps.xml
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_content/metadata_edit_form.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/change_password.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/members_add_control.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/portal_config_control.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/validatePassword.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/breadcrumbs.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/getMainGlobals.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/get_permalink.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/join_form.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/logged_in.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/password_email.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/password_form.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/permalink.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/reconfig_form.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/registered_email.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/tests/RegistrationTool.txt
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DublinCore.py
  U   CMF/branches/jens_tools_as_utilities/CMFDefault/utils.py

-=-
Modified: CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -18,6 +18,7 @@
 from zope.app.form.browser import DatetimeI18nWidget
 from zope.app.schema.vocabulary import IVocabularyFactory
 from zope.component import adapts
+from zope.component import getUtility
 from zope.formlib import form
 from zope.interface import implements
 from zope.interface import Interface
@@ -30,7 +31,7 @@
 from zope.schema import TextLine
 from zope.schema import URI
 
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.interfaces import IMetadataTool
 from Products.CMFDefault.formlib.form import ContentEditFormBase
 from Products.CMFDefault.formlib.form import DisplayFormBase
 from Products.CMFDefault.formlib.schema import EmailLine
@@ -51,7 +52,7 @@
 
     def __call__(self, context):
         context = getattr(context, 'context', context)
-        mdtool = getToolByName(context, 'portal_metadata')
+        mdtool = getUtility(IMetadataTool)
         items = [ (str(v), unicode(v), _(v))
                   for v in mdtool.listAllowedSubjects(context) ]
         return SimpleVocabulary.fromTitleItems(items)

Modified: CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.txt
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.txt	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCalendar/browser/event.txt	2006-12-26 20:42:55 UTC (rev 71654)
@@ -9,6 +9,15 @@
     >>> uf = app.site.acl_users
     >>> uf._doAddUser('mgr', 'mgrpw', ['Manager'], [])
 
+Register the portal_properties tool
+
+    >>> from zope.component import getSiteManager
+    >>> from Products.CMFCore.interfaces import IPropertiesTool
+    >>> from Products.CMFCore.interfaces import ISkinsTool
+    >>> sm = getSiteManager()
+    >>> sm.registerUtility(app.site.portal_properties, IPropertiesTool)
+    >>> sm.registerUtility(app.site.portal_skins, ISkinsTool)
+
 Create the browser object we'll be using.
 
     >>> from Products.Five.testbrowser import Browser

Modified: CMF/branches/jens_tools_as_utilities/CMFCalendar/setuphandlers.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCalendar/setuphandlers.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCalendar/setuphandlers.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -15,8 +15,10 @@
 $Id$
 """
 
-from Products.CMFCore.utils import getToolByName
+from zope.component import getUtility
 
+from Products.CMFCore.interfaces import IMetadataTool
+
 from exceptions import MetadataError
 
 
@@ -27,7 +29,7 @@
     are implemented for these steps.
     """
     site = context.getSite()
-    mdtool = getToolByName(site, 'portal_metadata')
+    mdtool = getUtility(IMetadataTool)
 
     # Set up a MetadataTool element policy for events
     try:

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-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCalendar/tests/test_Calendar.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -30,6 +30,8 @@
 from Products.CMFCore.interfaces import IActionsTool
 from Products.CMFCore.interfaces import ICatalogTool
 from Products.CMFCore.interfaces import IMembershipTool
+from Products.CMFCore.interfaces import IPropertiesTool
+from Products.CMFCore.interfaces import ISkinsTool
 from Products.CMFCalendar.testing import FunctionalLayer
 
 
@@ -123,6 +125,8 @@
         sm.registerUtility(self.app.site.portal_actions, IActionsTool)
         sm.registerUtility(self.app.site.portal_catalog, ICatalogTool)
         sm.registerUtility(self.app.site.portal_membership, IMembershipTool)
+        sm.registerUtility(self.app.site.portal_properties, IPropertiesTool)
+        sm.registerUtility(self.app.site.portal_skins, ISkinsTool)
 
     def _testURL(self, url, params=None):
         obj = self.app.site.restrictedTraverse(url)

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/FSObject.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/FSObject.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/FSObject.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -28,12 +28,15 @@
 from DateTime import DateTime
 from OFS.Cache import Cacheable
 from OFS.SimpleItem import Item
+
+from zope.component import getUtility
+
 from Products.PythonScripts.standard import html_quote
 
+from interfaces import ISkinsTool
 from permissions import ManagePortal
 from permissions import View
 from permissions import ViewManagementScreens
-from utils import getToolByName
 
 
 class FSObject(Implicit, Item, RoleManager, Cacheable):
@@ -113,15 +116,9 @@
                 # The permission was invalid, never mind
                 pass
 
-        skins_tool_namegetter = getattr(self, 'getSkinsFolderName', None)
-        if skins_tool_namegetter is not None:
-            skins_tool_name = skins_tool_namegetter()
-        else:
-            skins_tool_name = 'portal_skins'
-
         id = obj.getId()
         fpath = tuple( folder_path.split('/') )
-        portal_skins = getToolByName(self, skins_tool_name)
+        portal_skins = getUtility(ISkinsTool)
         folder = portal_skins.restrictedTraverse(fpath)
         if id in folder.objectIds():
             # we cant catch the badrequest so

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/MemberDataTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/MemberDataTool.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/MemberDataTool.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -25,6 +25,7 @@
 from ZPublisher.Converters import type_converters
 
 from zope.component import getUtility
+from zope.component import queryUtility
 from zope.interface import implements
 
 from ActionProviderBase import ActionProviderBase
@@ -32,6 +33,7 @@
 from interfaces import IMemberData
 from interfaces import IMemberDataTool
 from interfaces import IMembershipTool
+from interfaces import IRegistrationTool
 from interfaces.portal_memberdata import MemberData as z2IMemberData
 from interfaces.portal_memberdata \
         import portal_memberdata as z2IMemberDataTool
@@ -39,7 +41,6 @@
 from permissions import SetOwnProperties
 from permissions import ViewManagementScreens
 from utils import _dtmldir
-from utils import getToolByName
 from utils import registerToolInterface
 from utils import UniqueObject
 
@@ -307,7 +308,7 @@
         if properties is None:
             properties = kw
         membership = getUtility(IMembershipTool)
-        registration = getToolByName(self, 'portal_registration', None)
+        registration = queryUtility(IRegistrationTool)
         if not membership.isAnonymousUser():
             member = membership.getAuthenticatedMember()
             if registration:

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/MembershipTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/MembershipTool.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/MembershipTool.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -37,6 +37,7 @@
 from exceptions import BadRequest
 from interfaces import IMemberDataTool
 from interfaces import IMembershipTool
+from interfaces import IRegistrationTool
 from interfaces.portal_membership \
         import portal_membership as z2IMembershipTool
 from permissions import AccessContentsInformation
@@ -98,7 +99,7 @@
     def setPassword(self, password, domains=None):
         '''Allows the authenticated member to set his/her own password.
         '''
-        registration = getToolByName(self, 'portal_registration', None)
+        registration = queryUtility(IRegistrationTool)
         if not self.isAnonymousUser():
             member = self.getAuthenticatedMember()
             if registration:

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/PortalObject.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/PortalObject.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/PortalObject.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -15,6 +15,8 @@
 $Id$
 """
 
+from warnings import warn
+
 from Globals import InitializeClass
 from zope.interface import implements
 
@@ -53,6 +55,9 @@
         )
 
     def getSkinsFolderName(self):
+        warn('getSkinsFolderName is deprecated and will be removed in '
+             'CMF 2.3, please use "getUtility(ISkinsTool)" to retrieve '
+             'the skins tool object.', DeprecationWarning, stacklevel=2)
         return PORTAL_SKINS_TOOL_ID
 
 InitializeClass(PortalObjectBase)

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/Skinnable.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/Skinnable.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/Skinnable.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -20,6 +20,7 @@
 
 import logging
 from thread import get_ident
+from warnings import warn
 
 from AccessControl import ClassSecurityInfo
 from Acquisition import aq_base
@@ -28,7 +29,10 @@
 from OFS.ObjectManager import ObjectManager
 from ZODB.POSException import ConflictError
 
+from zope.component import queryUtility
 
+from Products.CMFCore.interfaces import ISkinsTool
+
 logger = logging.getLogger('CMFCore.Skinnable')
 
 
@@ -64,6 +68,9 @@
     security.declarePrivate('getSkinsFolderName')
     def getSkinsFolderName(self):
         # Not implemented.
+        warn('getSkinsFolderName is deprecated and will be removed in '
+             'CMF 2.3, please use "getUtility(ISkinsTool)" to retrieve '
+             'the skins tool object.', DeprecationWarning, stacklevel=2)
         return None
 
     def __getattr__(self, name):
@@ -99,27 +106,24 @@
         """Returns the requested skin.
         """
         skinob = None
-        sfn = self.getSkinsFolderName()
+        sf = queryUtility(ISkinsTool)
 
-        if sfn is not None:
-            sf = getattr(self, sfn, None)
-            if sf is not None:
-               if name is not None:
-                   skinob = sf.getSkinByName(name)
+        if sf is not None:
+           if name is not None:
+               skinob = sf.getSkinByName(name)
+           if skinob is None:
+               skinob = sf.getSkinByName(sf.getDefaultSkin())
                if skinob is None:
-                   skinob = sf.getSkinByName(sf.getDefaultSkin())
-                   if skinob is None:
-                       skinob = sf.getSkinByPath('')
+                   skinob = sf.getSkinByPath('')
+
         return skinob
 
     security.declarePublic('getSkinNameFromRequest')
     def getSkinNameFromRequest(self, REQUEST=None):
         '''Returns the skin name from the Request.'''
-        sfn = self.getSkinsFolderName()
-        if sfn is not None:
-            sf = getattr(self, sfn, None)
-            if sf is not None:
-                return REQUEST.get(sf.getRequestVarname(), None)
+        sf = queryUtility(ISkinsTool)
+        if sf is not None:
+            return REQUEST.get(sf.getRequestVarname(), None)
 
     security.declarePublic('changeSkin')
     def changeSkin(self, skinname):
@@ -146,11 +150,9 @@
             if skinname is not None:
                 return skinname
         # nothing here, so assume the default skin
-        sfn = self.getSkinsFolderName()
-        if sfn is not None:
-            sf = getattr(self, sfn, None)
-            if sf is not None:
-                return sf.getDefaultSkin()
+        sf = queryUtility(ISkinsTool)
+        if sf is not None:
+            return sf.getDefaultSkin()
         # and if that fails...
         return None
 

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/SkinsTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/SkinsTool.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/SkinsTool.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -44,6 +44,7 @@
 from SkinsContainer import SkinsContainer
 from utils import _dtmldir
 from utils import getToolByName
+from utils import registerToolInterface
 from utils import UniqueObject
 
 
@@ -374,3 +375,5 @@
             self.default_skin = skinname
 
 InitializeClass(SkinsTool)
+registerToolInterface('portal_skins', ISkinsTool)
+

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/skins.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/skins.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/skins.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -17,7 +17,11 @@
 
 from Acquisition import aq_inner
 from Acquisition import aq_parent
+
 from zope.component import adapts
+from zope.component import getSiteManager
+from zope.component import getUtility
+from zope.component import queryUtility
 
 from Products.GenericSetup.interfaces import ISetupEnviron
 from Products.GenericSetup.utils import exportObjects
@@ -28,7 +32,6 @@
 
 from Products.CMFCore.interfaces import IDirectoryView
 from Products.CMFCore.interfaces import ISkinsTool
-from Products.CMFCore.utils import getToolByName
 
 
 class DirectoryViewNodeAdapter(NodeAdapterBase):
@@ -191,16 +194,16 @@
 def importSkinsTool(context):
     """Import skins tool FSDirViews and skin paths from an XML file.
     """
-    site = context.getSite()
-    tool = getToolByName(site, 'portal_skins')
+    sm = getSiteManager(context.getSite())
+    tool = sm.getUtility(ISkinsTool)
 
     importObjects(tool, '', context)
 
 def exportSkinsTool(context):
     """Export skins tool FSDVs and skin paths as an XML file.
     """
-    site = context.getSite()
-    tool = getToolByName(site, 'portal_skins', None)
+    sm = getSiteManager(context.getSite())
+    tool = sm.queryUtility(ISkinsTool)
     if tool is None:
         logger = context.getLogger('skins')
         logger.info('Nothing to export.')

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_skins.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_skins.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_skins.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -22,6 +22,8 @@
 import os
 
 from OFS.Folder import Folder
+
+from zope.component import getSiteManager
 from zope.interface import implements
 
 from Products.GenericSetup.testing import BodyAdapterTestCase
@@ -256,6 +258,10 @@
         fsdvs = [ (id, DirectoryView(id, 'CMFCore/exportimport/tests/%s' %
                                          id)) for id in ids ]
         site._setObject('portal_skins', DummySkinsTool(selections, fsdvs))
+
+        sm = getSiteManager(site)
+        sm.registerUtility(site.portal_skins, ISkinsTool)
+        
         site.REQUEST = 'exists'
         return site
 

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-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSDTMLMethod.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -27,6 +27,7 @@
 from Products.CMFCore.FSDTMLMethod import FSDTMLMethod
 from Products.CMFCore.FSMetadata import FSMetadata
 from Products.CMFCore.interfaces import ICachingPolicyManager
+from Products.CMFCore.interfaces import ISkinsTool
 from Products.CMFCore.tests.base.dummy import DummyCachingManager
 from Products.CMFCore.tests.base.dummy import DummyCachingManagerWithPolicy
 from Products.CMFCore.tests.base.testcase import FSDVTest
@@ -120,6 +121,8 @@
 
         self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
         self.skins = self.root.portal_skins
+        sm = getSiteManager()
+        sm.registerUtility(self.skins, ISkinsTool)
 
         self.skins._setObject( 'custom', Folder( 'custom' ) )
         self.custom = self.skins.custom

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-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPageTemplate.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -31,6 +31,7 @@
 from Products.CMFCore.FSPageTemplate import FSPageTemplate
 from Products.CMFCore.FSMetadata import FSMetadata
 from Products.CMFCore.interfaces import ICachingPolicyManager
+from Products.CMFCore.interfaces import ISkinsTool
 from Products.CMFCore.testing import TraversingZCMLLayer
 from Products.CMFCore.tests.base.dummy import DummyCachingManager
 from Products.CMFCore.tests.base.testcase import FSDVTest
@@ -147,6 +148,8 @@
 
         self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
         self.skins = self.root.portal_skins
+        sm = getSiteManager()
+        sm.registerUtility(self.skins, ISkinsTool)
 
         self.skins._setObject( 'custom', Folder( 'custom' ) )
         self.custom = self.skins.custom

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPropertiesObject.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPropertiesObject.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPropertiesObject.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -1,5 +1,8 @@
 import unittest
 
+from zope.component import getSiteManager
+
+from Products.CMFCore.interfaces import ISkinsTool
 from Products.CMFCore.tests.base.testcase import FSDVTest
 from Products.CMFCore.tests.base.testcase import SecurityTest
 
@@ -27,6 +30,8 @@
 
         self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
         skins = self.root.portal_skins
+        sm = getSiteManager()
+        sm.registerUtility(skins, ISkinsTool)
 
         skins._setObject( 'custom', Folder( 'custom' ) )
         custom = skins.custom

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPythonScript.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPythonScript.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSPythonScript.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -28,8 +28,11 @@
 from OFS.SimpleItem import SimpleItem
 from Products.StandardCacheManagers import RAMCacheManager
 
+from zope.component import getSiteManager
+
 from Products.CMFCore.FSMetadata import FSMetadata
 from Products.CMFCore.FSPythonScript import FSPythonScript
+from Products.CMFCore.interfaces import ISkinsTool
 from Products.CMFCore.tests.base.testcase import FSDVTest
 from Products.CMFCore.tests.base.testcase import SecurityTest
 from Products.CMFCore.tests.base.testcase import WarningInterceptor
@@ -97,6 +100,8 @@
         root = self.root
         root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
         tool = self.root.portal_skins
+        sm = getSiteManager()
+        sm.registerUtility(tool, ISkinsTool)
 
         tool._setObject( 'custom', Folder( 'custom' ) )
         custom = tool.custom

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-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSReSTMethod.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -21,6 +21,7 @@
 from zope.component import getSiteManager
 
 from Products.CMFCore.interfaces import ICachingPolicyManager
+from Products.CMFCore.interfaces import ISkinsTool
 from Products.CMFCore.testing import TraversingZCMLLayer
 from Products.CMFCore.tests.base.testcase import FSDVTest
 from Products.CMFCore.tests.base.testcase import RequestTest
@@ -166,6 +167,8 @@
 
         self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
         self.skins = self.root.portal_skins
+        sm = getSiteManager()
+        sm.registerUtility(self.skins, ISkinsTool)
 
         self.skins._setObject( 'custom', Folder( 'custom' ) )
         self.custom = self.skins.custom

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-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSSTXMethod.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -21,6 +21,7 @@
 from zope.component import getSiteManager
 
 from Products.CMFCore.interfaces import ICachingPolicyManager
+from Products.CMFCore.interfaces import ISkinsTool
 from Products.CMFCore.testing import TraversingZCMLLayer
 from Products.CMFCore.tests.base.testcase import FSDVTest
 from Products.CMFCore.tests.base.testcase import RequestTest
@@ -201,6 +202,8 @@
 
         self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
         self.skins = self.root.portal_skins
+        sm = getSiteManager()
+        sm.registerUtility(self.skins, ISkinsTool)
 
         self.skins._setObject( 'custom', Folder( 'custom' ) )
         self.custom = self.skins.custom

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSZSQLMethod.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSZSQLMethod.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_FSZSQLMethod.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -6,8 +6,11 @@
 
 from OFS.Folder import Folder
 
+from zope.component import getSiteManager
+
 from Products.CMFCore.FSMetadata import FSMetadata
 from Products.CMFCore.FSZSQLMethod import FSZSQLMethod
+from Products.CMFCore.interfaces import ISkinsTool
 from Products.CMFCore.tests.base.testcase import FSDVTest
 from Products.CMFCore.tests.base.testcase import SecurityTest
 
@@ -49,6 +52,8 @@
 
         self.root._setObject( 'portal_skins', Folder( 'portal_skins' ) )
         self.skins = self.root.portal_skins
+        sm = getSiteManager()
+        sm.registerUtility(self.skins, ISkinsTool)
 
         self.skins._setObject( 'custom', Folder( 'custom' ) )
         self.custom = self.skins.custom

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_SkinsTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_SkinsTool.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/tests/test_SkinsTool.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -18,7 +18,10 @@
 import unittest
 import Testing
 
+from zope.component import getSiteManager
 
+from Products.CMFCore.interfaces import ISkinsTool
+
 class SkinsContainerTests(unittest.TestCase):
 
     def test_z2interfaces(self):
@@ -97,12 +100,11 @@
 
         class TestSkinnableObjectManager(SkinnableObjectManager):
             tool = SkinsTool()
+            sm = getSiteManager()
+            sm.registerUtility(tool, ISkinsTool)
             # This is needed otherwise REQUEST is the string
             # '<Special Object Used to Force Acquisition>'
             REQUEST = None 
-            def getSkinsFolderName(self):
-                '''tool'''
-                return 'tool'
         
         return TestSkinnableObjectManager()
     

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/DublinCore.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/DublinCore.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/DublinCore.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -28,6 +28,7 @@
 from Products.CMFCore.interfaces import ICatalogableDublinCore
 from Products.CMFCore.interfaces import IDublinCore
 from Products.CMFCore.interfaces import IMembershipTool
+from Products.CMFCore.interfaces import IMetadataTool
 from Products.CMFCore.interfaces import IMutableDublinCore
 from Products.CMFCore.interfaces.DublinCore \
         import CatalogableDublinCore as z2ICatalogableDublinCore
@@ -35,7 +36,6 @@
         import DublinCore as z2IDublinCore
 from Products.CMFCore.interfaces.DublinCore \
         import MutableDublinCore as z2IMutableDublinCore
-from Products.CMFCore.utils import getToolByName
 
 from permissions import ModifyPortalContent
 from permissions import View
@@ -172,7 +172,7 @@
     def Publisher( self ):
         """ Dublin Core Publisher element - resource publisher.
         """
-        tool = getToolByName(self, 'portal_metadata', None)
+        tool = queryUtility(IMetadataTool)
 
         if tool is not None:
             return tool.getPublisher()

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/MetadataTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/MetadataTool.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/MetadataTool.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -28,6 +28,7 @@
 from Products.CMFCore.interfaces import IMetadataTool
 from Products.CMFCore.interfaces.portal_metadata \
         import portal_metadata as z2IMetadataTool
+from Products.CMFCore.utils import registerToolInterface
 from Products.CMFCore.utils import UniqueObject
 
 from exceptions import MetadataError
@@ -620,3 +621,5 @@
                             'metadata element %s.' % ( value, element )
 
 InitializeClass( MetadataTool )
+registerToolInterface('portal_metadata', IMetadataTool)
+

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/PropertiesTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/PropertiesTool.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/PropertiesTool.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -25,6 +25,7 @@
 from Products.CMFCore.interfaces import IPropertiesTool
 from Products.CMFCore.interfaces.portal_properties \
         import portal_properties as z2IPropertiesTool
+from Products.CMFCore.utils import registerToolInterface
 from Products.CMFCore.utils import UniqueObject
 
 from permissions import ManagePortal
@@ -73,3 +74,5 @@
         return self.MailHost.smtp_host
 
 InitializeClass(PropertiesTool)
+registerToolInterface('portal_properties', IPropertiesTool)
+

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/RegistrationTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/RegistrationTool.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/RegistrationTool.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -20,11 +20,14 @@
 from Globals import InitializeClass
 
 from zope.component import getUtility
+from zope.interface import implements
 from zope.schema import ValidationError
 
 from Products.CMFCore.interfaces import IMembershipTool
+from Products.CMFCore.interfaces import IRegistrationTool
 from Products.CMFCore.RegistrationTool import RegistrationTool as BaseTool
 from Products.CMFCore.utils import _checkPermission
+from Products.CMFCore.utils import registerToolInterface
 
 from permissions import ManagePortal
 from utils import checkEmailAddress
@@ -36,6 +39,7 @@
     """ Manage through-the-web signup policies.
     """
 
+    implements(IRegistrationTool)
     __implements__ = BaseTool.__implements__
 
     meta_type = 'Default Registration Tool'
@@ -205,3 +209,5 @@
         return member
 
 InitializeClass(RegistrationTool)
+registerToolInterface('portal_registration', IRegistrationTool)
+

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/formlib/schema.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/formlib/schema.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/formlib/schema.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -18,12 +18,14 @@
 from datetime import datetime
 
 from DateTime.DateTime import DateTime
+
+from zope.component import getUtility
 from zope.datetime import parseDatetimetz
 from zope.interface import implements
 from zope.schema import BytesLine
 from zope.schema.interfaces import IBytesLine
 
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.interfaces import IPropertiesTool
 from Products.CMFDefault.utils import checkEmailAddress
 
 
@@ -31,7 +33,7 @@
 
     def __init__(self, context):
         self.context = context
-        ptool = getToolByName(context, 'portal_properties')
+        ptool = getUtility(IPropertiesTool).__of__(context)
         self.encoding = ptool.getProperty('default_charset', None)
 
 

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-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/componentregistry.xml	2006-12-26 20:42:55 UTC (rev 71654)
@@ -26,5 +26,17 @@
   <utility
      interface="Products.CMFCore.interfaces.IMembershipTool"
      object="/portal_membership"/>
+  <utility
+     interface="Products.CMFCore.interfaces.IMetadataTool"
+     object="/portal_metadata"/>
+  <utility
+     interface="Products.CMFCore.interfaces.IPropertiesTool"
+     object="/portal_properties"/>
+  <utility
+     interface="Products.CMFCore.interfaces.IRegistrationTool"
+     object="/portal_registration"/>
+  <utility
+     interface="Products.CMFCore.interfaces.ISkinsTool"
+     object="/portal_skins"/>
  </utilities>
 </componentregistry>

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/import_steps.xml
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/import_steps.xml	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/import_steps.xml	2006-12-26 20:42:55 UTC (rev 71654)
@@ -58,7 +58,7 @@
  <import-step id="skins" version="20040630-01"
               handler="Products.CMFCore.exportimport.skins.importSkinsTool"
               title="Skins Tool">
-  <dependency step="toolset"/>
+  <dependency step="componentregistry"/>
   Import skins tool's filesystem directory views and skin path definitions.
  </import-step>
  <import-step id="toolset" version="20040630-01"

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_content/metadata_edit_form.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_content/metadata_edit_form.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_content/metadata_edit_form.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -1,10 +1,12 @@
 ##parameters=change='', change_and_edit='', change_and_view=''
 ##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
 from Products.CMFDefault.utils import decode
 from Products.CMFDefault.utils import Message as _
 
-mdtool = getToolByName(script, 'portal_metadata')
+mdtool = getToolByInterfaceName( script
+                               , 'Products.CMFCore.interfaces.IMetadataTool'
+                               )
 
 
 form = context.REQUEST.form

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/change_password.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/change_password.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/change_password.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -1,11 +1,15 @@
 ##parameters=password, confirm, domains=None, **kw
 ##title=Action to change password
 ##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
 from Products.CMFDefault.utils import Message as _
 
-mtool = getToolByName(script, 'portal_membership')
-rtool = getToolByName(script, 'portal_registration')
+mtool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IMembershipTool'
+                              )
+rtool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IRegistrationTool'
+                              )
 
 result = rtool.testPasswordValidity(password, confirm)
 if result:

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/members_add_control.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/members_add_control.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/members_add_control.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -1,13 +1,19 @@
 ##parameters=member_id, password, member_email, send_password=False, **kw
 ##title=Add a member
 ##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
 from Products.CMFDefault.permissions import ManageUsers
 from Products.CMFDefault.utils import Message as _
 
-mtool = getToolByName(script, 'portal_membership')
-ptool = getToolByName(script, 'portal_properties')
-rtool = getToolByName(script, 'portal_registration')
+mtool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IMembershipTool'
+                              )
+ptool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IPropertiesTool'
+                              )
+rtool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IRegistrationTool'
+                              )
 
 try:
     rtool.addMember( id=member_id, password=password,

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/portal_config_control.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/portal_config_control.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/portal_config_control.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -1,9 +1,11 @@
 ##parameters=**kw
 ##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
 from Products.CMFDefault.utils import Message as _
 
-ptool = getToolByName(script, 'portal_properties')
+ptool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IPropertiesTool'
+                              )
 
 if not ptool.hasProperty('default_charset'):
     ptool.manage_addProperty('default_charset', '', 'string')

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/validatePassword.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/validatePassword.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/validatePassword.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -2,10 +2,14 @@
 ##parameters=password='', confirm='', **kw
 ##title=
 ##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
 
-ptool = getToolByName(script, 'portal_properties')
-rtool = getToolByName(script, 'portal_registration')
+ptool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IPropertiesTool'
+                              )
+rtool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IRegistrationTool'
+                              )
 
 if ptool.getProperty('validate_email'):
     password = rtool.generatePassword()

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/breadcrumbs.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/breadcrumbs.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/breadcrumbs.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -1,10 +1,13 @@
 ##parameters=include_root=1
 ##title=Return breadcrumbs
 ##
+from Products.CMFCore.utils import getToolByInterfaceName
 from Products.CMFCore.utils import getToolByName
 from Products.CMFDefault.utils import Message as _
 
-ptool = getToolByName(script, 'portal_properties')
+ptool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IPropertiesTool'
+                              )
 utool = getToolByName(script, 'portal_url')
 portal_url = utool()
 result = []

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/getMainGlobals.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/getMainGlobals.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/getMainGlobals.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -12,7 +12,9 @@
 mtool = getToolByInterfaceName( script
                               , 'Products.CMFCore.interfaces.IMembershipTool'
                               )
-ptool = getToolByName(script, 'portal_properties')
+ptool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IPropertiesTool'
+                              )
 utool = getToolByName(script, 'portal_url')
 wtool = getToolByName(script, 'portal_workflow')
 portal_object = utool.getPortalObject()

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/get_permalink.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/get_permalink.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/get_permalink.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -7,14 +7,17 @@
 ##parameters=
 ##title=Returns the permalink url or None
 ##
+from Products.CMFCore.utils import getToolByInterfaceName
 from Products.CMFCore.utils import getToolByName
 
 # calculate the permalink if the uid handler tool exists, permalinks
 # are configured to be shown and the object is not folderish
 uidtool = getToolByName(context, 'portal_uidhandler', None)
 if uidtool is not None:
-    proptool = getToolByName(context, 'portal_properties', None)
-    showPermalink = getattr(proptool, 'enable_permalink', None)
+    ptool = getToolByInterfaceName( script
+                                  , 'Products.CMFCore.interfaces.IPropertiesTool'
+                                  )
+    showPermalink = getattr(ptool, 'enable_permalink', None)
     isFolderish = getattr(context.aq_explicit, 'isPrincipiaFolderish', None)
     
     if showPermalink and not isFolderish:

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/join_form.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/join_form.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/join_form.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -1,13 +1,20 @@
 ##parameters=b_start=0, member_id='', member_email='', password='', confirm='', send_password='', add='', cancel=''
 ##
+from Products.CMFCore.utils import getToolByInterfaceName
 from Products.CMFCore.utils import getToolByName
 from Products.CMFDefault.permissions import ManageUsers
 from Products.CMFDefault.utils import decode
 from Products.CMFDefault.utils import Message as _
 
-atool = getToolByName(script, 'portal_actions')
-mtool = getToolByName(script, 'portal_membership')
-ptool = getToolByName(script, 'portal_properties')
+atool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IActionsTool'
+                              )
+mtool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IMembershipTool'
+                              )
+ptool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IPropertiesTool'
+                              )
 utool = getToolByName(script, 'portal_url')
 portal_url = utool()
 validate_email = ptool.getProperty('validate_email')

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/logged_in.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/logged_in.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/logged_in.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -1,12 +1,19 @@
 ##parameters=
 ##
+from Products.CMFCore.utils import getToolByInterfaceName
 from Products.CMFCore.utils import getToolByName
 from Products.CMFDefault.utils import decode
 from Products.CMFDefault.utils import Message as _
 
-mtool = getToolByName(script, 'portal_membership')
-ptool = getToolByName(script, 'portal_properties')
-stool = getToolByName(script, 'portal_skins')
+mtool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IMembershipTool'
+                              )
+ptool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IPropertiesTool'
+                              )
+stool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.ISkinsTool'
+                              )
 utool = getToolByName(script, 'portal_url')
 portal_url = utool()
 

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/password_email.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/password_email.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/password_email.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -9,7 +9,9 @@
 atool = getToolByInterfaceName( script
                               , 'Products.CMFCore.interfaces.IActionsTool'
                               )
-ptool = getToolByName(script, 'portal_properties')
+ptool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IPropertiesTool'
+                              )
 utool = getToolByName(script, 'portal_url')
 portal_url = utool()
 

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/password_form.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/password_form.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/password_form.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -1,12 +1,19 @@
 ##parameters=change='', cancel=''
 ##
+from Products.CMFCore.utils import getToolByInterfaceName
 from Products.CMFCore.utils import getToolByName
 from Products.CMFDefault.utils import decode
 from Products.CMFDefault.utils import Message as _
 
-atool = getToolByName(script, 'portal_actions')
-mtool = getToolByName(script, 'portal_membership')
-ptool = getToolByName(script, 'portal_properties')
+atool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IActionsTool'
+                              )
+mtool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IMembershipTool'
+                              )
+ptool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IPropertiesTool'
+                              )
 utool = getToolByName(script, 'portal_url')
 member = mtool.getAuthenticatedMember()
 portal_url = utool()

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/permalink.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/permalink.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/permalink.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -7,6 +7,7 @@
 ##parameters=
 ##title=Returns an object by unique id
 ##
+from Products.CMFCore.utils import getToolByInterfaceName
 from Products.CMFCore.utils import getToolByName
 
 subpath = traverse_subpath[0]
@@ -18,8 +19,10 @@
     # no permalink feature without an uid handler tool being installed
     if uid_handler is None:
         return '0'
-    proptool = getToolByName(context, 'portal_properties', None)
-    isAvailable = getattr(proptool, 'enable_permalink', 0)
+    ptool = getToolByInterfaceName( script
+                                  , 'Products.CMFCore.interfaces.IPropertiesTool'
+                                  )
+    isAvailable = getattr(ptool, 'enable_permalink', 0)
     return str(int(isAvailable))
 
 obj = uid_handler.getObject(subpath)

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/reconfig_form.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/reconfig_form.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/reconfig_form.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -1,11 +1,15 @@
 ##parameters=change=''
 ##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
 from Products.CMFDefault.utils import decode
 from Products.CMFDefault.utils import Message as _
 
-atool = getToolByName(script, 'portal_actions')
-ptool = getToolByName(script, 'portal_properties')
+atool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IActionsTool'
+                              )
+ptool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IPropertiesTool'
+                              )
 
 
 form = context.REQUEST.form

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/registered_email.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/registered_email.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/registered_email.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -9,7 +9,9 @@
 atool = getToolByInterfaceName( script
                               , 'Products.CMFCore.interfaces.IActionsTool'
                               )
-ptool = getToolByName(script, 'portal_properties')
+ptool = getToolByInterfaceName( script
+                              , 'Products.CMFCore.interfaces.IPropertiesTool'
+                              )
 utool = getToolByName(script, 'portal_url')
 portal_url = utool()
 

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/RegistrationTool.txt
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/RegistrationTool.txt	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/RegistrationTool.txt	2006-12-26 20:42:55 UTC (rev 71654)
@@ -89,11 +89,13 @@
 
     >>> from Testing.makerequest import makerequest
     >>> from Products.CMFCore.interfaces import IActionsTool
+    >>> from Products.CMFCore.interfaces import IPropertiesTool
     >>> s = makerequest(DummySite())
     >>> s.REQUEST.environ['HTTP_X_FORWARDED_FOR'] = 'NNN.NNN.NNN.NNN'
     >>> s.portal_actions = s.portal_properties = s.portal_url = DummyTool()
     >>> sm = getSiteManager()
     >>> sm.registerUtility(s.portal_actions, IActionsTool)
+    >>> sm.registerUtility(s.portal_properties, IPropertiesTool)
     >>> s.ZopeTime = 'NNNN/NN/NN'
     >>> s.description = 'THE SITE DESCRIPTION.'
     >>> s.default_charset = 'utf-8'

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DublinCore.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DublinCore.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_DublinCore.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -25,6 +25,7 @@
 from zope.component import getSiteManager
 
 from Products.CMFCore.interfaces import IMembershipTool
+from Products.CMFCore.interfaces import IMetadataTool
 from Products.CMFCore.tests.base.dummy import DummySite
 from Products.CMFCore.tests.base.dummy import DummyUserFolder
 from Products.CMFCore.tests.base.testcase import SecurityTest
@@ -172,7 +173,9 @@
     def test_publisher_with_metadata_tool(self):
         PUBLISHER = 'Some Publisher'
         site = DummySite('site').__of__(self.root)
+        sm = getSiteManager()
         site.portal_metadata = DummyMetadataTool(publisher=PUBLISHER)
+        sm.registerUtility(site.portal_metadata, IMetadataTool)
         item = self._makeDummyContent('item').__of__(site)
         self.assertEqual(item.Publisher(), PUBLISHER)
 

Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/utils.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/utils.py	2006-12-26 17:52:14 UTC (rev 71653)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/utils.py	2006-12-26 20:42:55 UTC (rev 71654)
@@ -28,11 +28,13 @@
 from Products.PageTemplates.GlobalTranslationService \
         import getGlobalTranslationService
 from ZTUtils.Zope import complex_marshal
+
 from zope import i18n
+from zope.component import getUtility
 from zope.i18n.interfaces import IUserPreferredCharsets
 from zope.i18nmessageid import MessageFactory
 
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.interfaces import IPropertiesTool
 
 from exceptions import EmailAddressInvalid
 from exceptions import IllegalHTML
@@ -446,7 +448,7 @@
 def decode(value, context):
     """ Decode value using default_charset.
     """
-    ptool = getToolByName(context, 'portal_properties')
+    ptool = getUtility(IPropertiesTool).__of__(context)
     default_charset = ptool.getProperty('default_charset', None)
     return toUnicode(value, default_charset)
 
@@ -474,7 +476,7 @@
 def makeEmail(mtext, context, headers={}):
     """ Make email message.
     """
-    ptool = getToolByName(context, 'portal_properties')
+    ptool = getUtility(IPropertiesTool).__of__(context)
     email_charset = ptool.getProperty('email_charset', None) or 'utf-8'
     try:
         msg = MIMEText(mtext.encode(), 'plain')



More information about the CMF-checkins mailing list