[CMF-checkins] SVN: CMF/branches/jens_tools_as_utilities/ -
checkpoint with more tools converted
Jens Vagelpohl
jens at dataflake.org
Thu Dec 28 17:42:25 EST 2006
Log message for revision 71662:
- checkpoint with more tools converted
Changed:
U CMF/branches/jens_tools_as_utilities/CMFCore/TypesTool.py
U CMF/branches/jens_tools_as_utilities/CMFCore/browser/actions.py
U CMF/branches/jens_tools_as_utilities/CMFCore/browser/typeinfo.py
U CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/mailhost.py
U CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_mailhost.py
U CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/typeinfo.py
U CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/workflow.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/Favorite.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/MembershipTool.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/__init__.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/factory.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/componentregistry.xml
U CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_content/metadata_edit_control.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/addtoFavorites.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/folder_localrole_edit.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/members_delete_control.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/discitem_delete.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/discussion_reply.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/discussion_reply_form.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/members_delete_form.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/members_manage_form.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/permalink.py
U CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdAnnotationTool.py
U CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdGeneratorTool.py
U CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdHandlerTool.py
U CMF/branches/jens_tools_as_utilities/CMFUid/tests/test_uidannotation.py
U CMF/branches/jens_tools_as_utilities/CMFUid/tests/test_uidhandling.py
U CMF/branches/jens_tools_as_utilities/DCWorkflow/browser/workflow.py
-=-
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/TypesTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/TypesTool.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/TypesTool.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -49,7 +49,6 @@
from utils import _checkPermission
from utils import _dtmldir
from utils import _wwwdir
-from utils import getToolByName
from utils import registerToolInterface
from utils import SimpleItemWithProperties
from utils import UniqueObject
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/browser/actions.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/browser/actions.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/browser/actions.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -18,12 +18,13 @@
from xml.dom.minidom import parseString
from zope.component import queryMultiAdapter
+from zope.component import queryUtility
from Products.CMFCore.ActionInformation import Action
from Products.CMFCore.ActionInformation import ActionCategory
-from Products.CMFCore.utils import getToolByName
from Products.GenericSetup.browser.utils import AddWithPresettingsViewBase
from Products.GenericSetup.interfaces import INode
+from Products.GenericSetup.interfaces import ISetupTool
class ActionAddView(AddWithPresettingsViewBase):
@@ -37,7 +38,7 @@
def getProfileInfos(self):
profiles = []
- stool = getToolByName(self, 'portal_setup', None)
+ stool = queryUtility(ISetupTool)
if stool:
for info in stool.listContextInfos():
obj_ids = []
@@ -70,7 +71,7 @@
return [ ('%s/%s' % (category_id, path)) for path in action_paths ]
def _initSettings(self, obj, profile_id, obj_path):
- stool = getToolByName(self, 'portal_setup', None)
+ stool = queryUtility(ISetupTool)
if stool is None:
return
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/browser/typeinfo.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/browser/typeinfo.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/browser/typeinfo.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -18,12 +18,13 @@
from xml.dom.minidom import parseString
from zope.component import queryMultiAdapter
+from zope.component import queryUtility
from Products.CMFCore.TypesTool import FactoryTypeInformation
from Products.CMFCore.TypesTool import ScriptableTypeInformation
-from Products.CMFCore.utils import getToolByName
from Products.GenericSetup.browser.utils import AddWithPresettingsViewBase
from Products.GenericSetup.interfaces import IBody
+from Products.GenericSetup.interfaces import ISetupTool
class FactoryTypeInformationAddView(AddWithPresettingsViewBase):
@@ -37,7 +38,7 @@
def getProfileInfos(self):
profiles = []
- stool = getToolByName(self, 'portal_setup', None)
+ stool = queryUtility(ISetupTool)
if stool:
for info in stool.listContextInfos():
obj_ids = []
@@ -68,7 +69,7 @@
return tuple(profiles)
def _initSettings(self, obj, profile_id, obj_path):
- stool = getToolByName(self, 'portal_setup', None)
+ stool = queryUtility(ISetupTool)
if stool is None:
return
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/mailhost.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/mailhost.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/mailhost.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -15,25 +15,27 @@
$Id$
"""
+from Products.MailHost.interfaces import IMailHost
+
+from zope.component import getSiteManager
+
from Products.GenericSetup.utils import exportObjects
from Products.GenericSetup.utils import importObjects
-from Products.CMFCore.utils import getToolByName
-
def importMailHost(context):
"""Import mailhost settings from an XML file.
"""
- site = context.getSite()
- tool = getToolByName(site, 'MailHost')
+ sm = getSiteManager(context.getSite())
+ tool = sm.getUtility(IMailHost)
importObjects(tool, '', context)
def exportMailHost(context):
"""Export mailhost settings as an XML file.
"""
- site = context.getSite()
- tool = getToolByName(site, 'MailHost', None)
+ sm = getSiteManager(context.getSite())
+ tool = sm.queryUtility(IMailHost)
if tool is None:
logger = context.getLogger('mailhost')
logger.info('Nothing to export.')
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_mailhost.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_mailhost.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/tests/test_mailhost.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -19,7 +19,10 @@
import Testing
from OFS.Folder import Folder
+from Products.MailHost.interfaces import IMailHost
+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
@@ -47,6 +50,8 @@
self.root.site = Folder(id='site')
site = self.root.site
mh = site.MailHost = MailHost('MailHost')
+ sm = getSiteManager()
+ sm.registerUtility(site.MailHost, IMailHost)
if use_changed:
mh.smtp_port='1'
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/typeinfo.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/typeinfo.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/typeinfo.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -28,7 +28,6 @@
from Products.CMFCore.interfaces import ITypeInformation
from Products.CMFCore.interfaces import ITypesTool
-from Products.CMFCore.utils import getToolByName
class TypeInformationXMLAdapter(XMLAdapterBase, PropertyManagerHelpers):
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/workflow.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/workflow.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/exportimport/workflow.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -26,7 +26,6 @@
from Products.GenericSetup.utils import XMLAdapterBase
from Products.CMFCore.interfaces import IConfigurableWorkflowTool
-from Products.CMFCore.utils import getToolByName
class WorkflowToolXMLAdapter(XMLAdapterBase, ObjectManagerHelpers,
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/Favorite.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/Favorite.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/Favorite.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -20,14 +20,16 @@
from Globals import InitializeClass
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
+
from zope.app.container.interfaces import IObjectAddedEvent
from zope.component import adapter
from zope.component import getUtility
+from zope.component import queryUtility
from zope.component.factory import Factory
from zope.interface import implements
from Products.CMFCore.interfaces import IURLTool
-from Products.CMFCore.utils import getToolByName
+from Products.CMFUid.interfaces import IUniqueIdAnnotationManagement
from DublinCore import DefaultDublinCoreImpl
from interfaces import IFavorite
@@ -70,7 +72,7 @@
the unique id handler tool is available.
"""
# check for unique id handler tool
- handler = getToolByName(self, 'portal_uidhandler', None)
+ handler = queryUtility(IUniqueIdAnnotationManagement)
if handler is None or not hasattr(handler, 'register'):
return
@@ -83,7 +85,7 @@
the unique id handler tool is available.
"""
# check for unique id handler tool
- handler = getToolByName(self, 'portal_uidhandler', None)
+ handler = queryUtility(IUniqueIdAnnotationManagement)
if handler is None or not hasattr(handler, 'queryObject'):
return
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/MembershipTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/MembershipTool.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/MembershipTool.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -27,7 +27,6 @@
from Products.CMFCore.MembershipTool import MembershipTool as BaseTool
from Products.CMFCore.utils import _checkPermission
from Products.CMFCore.utils import _getAuthenticatedUser
-from Products.CMFCore.utils import getToolByName
from Products.CMFCore.utils import registerToolInterface
from Document import addDocument
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/__init__.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/__init__.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/__init__.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -65,6 +65,14 @@
registerDirectory('skins', globals())
registerDirectory('help', globals())
+# Register the ID to interface data for those items that don't have their
+# own module
+from Products.CMFCore.utils import registerToolInterface
+from Products.GenericSetup.interfaces import ISetupTool
+registerToolInterface('portal_setup', ISetupTool)
+from Products.MailHost.interfaces import IMailHost
+registerToolInterface('MailHost', IMailHost)
+
def initialize(context):
ToolInit( 'CMF Default Tool'
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/factory.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/factory.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/factory.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -18,7 +18,6 @@
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.CMFCore.interfaces import ISiteRoot
-from Products.CMFCore.utils import getToolByName
from Products.GenericSetup import EXTENSION
from Products.GenericSetup import profile_registry
from Products.GenericSetup.tool import SetupTool
@@ -55,7 +54,7 @@
site = dispatcher._getOb( site_id )
site._setObject(_TOOL_ID, SetupTool(_TOOL_ID))
- setup_tool = getToolByName(site, _TOOL_ID)
+ setup_tool = getattr(site, _TOOL_ID)
setup_tool.setImportContext( 'profile-%s' % profile_id )
setup_tool.runAllImportSteps()
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-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/componentregistry.xml 2006-12-28 22:42:24 UTC (rev 71662)
@@ -53,5 +53,11 @@
<utility
interface="Products.CMFCore.interfaces.IConfigurableWorkflowTool"
object="/portal_workflow"/>
+ <utility
+ interface="Products.GenericSetup.interfaces.ISetupTool"
+ object="/portal_setup"/>
+ <utility
+ interface="Products.MailHost.interfaces.IMailHost"
+ object="/MailHost"/>
</utilities>
</componentregistry>
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_content/metadata_edit_control.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_content/metadata_edit_control.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_content/metadata_edit_control.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -1,10 +1,12 @@
##parameters=allow_discussion, title=None, subject=None, description=None, contributors=None, effective_date=None, expiration_date=None, format=None, language=None, rights=None, **kw
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.exceptions import ResourceLockedError
from Products.CMFDefault.utils import Message as _
-dtool = getToolByName(script, 'portal_discussion')
+dtool = getToolByInterfaceName( script
+ , 'Products.CMFCore.interfaces.IDiscussionTool'
+ )
def tuplify( value ):
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/addtoFavorites.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/addtoFavorites.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/addtoFavorites.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -1,8 +1,10 @@
##parameters=
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
-mtool = getToolByName(script, 'portal_membership')
+mtool = getToolByInterfaceName( script
+ , 'Products.CMFCore.interfaces.IMembershipTool'
+ )
home = mtool.getHomeFolder()
if not hasattr(home, 'Favorites'):
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/folder_localrole_edit.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/folder_localrole_edit.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/folder_localrole_edit.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -1,10 +1,12 @@
##parameters=change_type
##title=Set local roles
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import Message as _
-mtool = getToolByName(script, 'portal_membership')
+mtool = getToolByInterfaceName( script
+ , 'Products.CMFCore.interfaces.IMembershipTool'
+ )
if change_type == 'add':
mtool.setLocalRoles(obj=context,
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/members_delete_control.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/members_delete_control.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_control/members_delete_control.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -1,10 +1,12 @@
##parameters=ids, **kw
##title=Delete members
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import Message as _
-mtool = getToolByName(script, 'portal_membership')
+mtool = getToolByInterfaceName( script
+ , 'Products.CMFCore.interfaces.IMembershipTool'
+ )
mtool.deleteMembers(ids)
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/discitem_delete.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/discitem_delete.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/discitem_delete.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -1,10 +1,12 @@
##parameters=
##title=Delete reply
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import Message as _
-dtool = getToolByName(script, 'portal_discussion')
+dtool = getToolByInterfaceName( script
+ , 'Products.CMFCore.interfaces.IDiscussionTool'
+ )
parent = context.inReplyTo()
talkback = dtool.getDiscussionFor(parent)
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/discussion_reply.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/discussion_reply.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/discussion_reply.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -1,10 +1,12 @@
##parameters=title, text, **kw
##title=Reply to content
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import Message as _
-dtool = getToolByName(script, 'portal_discussion')
+dtool = getToolByInterfaceName( script
+ , 'Products.CMFCore.interfaces.IDiscussionTool'
+ )
talkback = dtool.getDiscussionFor(context)
replyID = talkback.createReply(title=title, text=text)
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/discussion_reply_form.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/discussion_reply_form.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/discussion_reply_form.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -1,12 +1,14 @@
##parameters=add='', edit='', preview=''
##
from Products.PythonScripts.standard import structured_text
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import html_marshal
from Products.CMFDefault.utils import Message as _
-atool = getToolByName(script, 'portal_actions')
+atool = getToolByInterfaceName( script
+ , 'Products.CMFCore.interfaces.IActionsTool'
+ )
form = context.REQUEST.form
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-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/get_permalink.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -8,11 +8,14 @@
##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)
+uidtool = getToolByInterfaceName( context
+ , 'Products.CMFUid.interfaces.IUniqueIdHandler'
+ , default=None
+ )
+
if uidtool is not None:
ptool = getToolByInterfaceName( script
, 'Products.CMFCore.interfaces.IPropertiesTool'
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/members_delete_form.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/members_delete_form.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/members_delete_form.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -1,11 +1,13 @@
##parameters=ids, b_start=0, delete='', cancel=''
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import html_marshal
from Products.CMFDefault.utils import Message as _
-atool = getToolByName(script, 'portal_actions')
+atool = getToolByInterfaceName( script
+ , 'Products.CMFCore.interfaces.IActionsTool'
+ )
form = context.REQUEST.form
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/members_manage_form.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/members_manage_form.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/members_manage_form.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -1,13 +1,17 @@
##parameters=b_start=0, ids=(), members_new='', members_delete=''
##
from ZTUtils import Batch
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import html_marshal
from Products.CMFDefault.utils import Message as _
-atool = getToolByName(script, 'portal_actions')
-mtool = getToolByName(script, 'portal_membership')
+atool = getToolByInterfaceName( script
+ , 'Products.CMFCore.interfaces.IActionsTool'
+ )
+mtool = getToolByInterfaceName( script
+ , 'Products.CMFCore.interfaces.IMembershipTool'
+ )
form = context.REQUEST.form
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-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/skins/zpt_generic/permalink.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -8,10 +8,10 @@
##title=Returns an object by unique id
##
from Products.CMFCore.utils import getToolByInterfaceName
-from Products.CMFCore.utils import getToolByName
subpath = traverse_subpath[0]
-uid_handler = getToolByName(context, 'portal_uidhandler', None)
+iface = 'Products.CMFUid.interfaces.UniqueIDHandler'
+uid_handler = getToolByInterfaceName(context, iface)
# appending 'isAvailable' instead of a unique id returns if
# the site permalink feature is available.
Modified: CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdAnnotationTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdAnnotationTool.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdAnnotationTool.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -24,9 +24,12 @@
from Globals import Persistent
from OFS.PropertyManager import PropertyManager
from OFS.SimpleItem import SimpleItem
+
+from zope.component import getUtility
from zope.interface import implements
-from Products.CMFCore.utils import getToolByName, UniqueObject
+from Products.CMFCore.utils import UniqueObject
+from Products.CMFCore.utils import registerToolInterface
from Products.CMFCore.ActionProviderBase import ActionProviderBase
from Products.CMFUid.interfaces import IUniqueIdAnnotation
@@ -69,7 +72,7 @@
# the uid object may already be removed by the 'manage_afterAdd'.
# To be independent of the implementation of 'manage_afterAdd'
# the unique id object probably gets removed another time.
- anno_tool = getToolByName(item, 'portal_uidannotation')
+ anno_tool = getUtility(IUniqueIdAnnotationManagement)
if anno_tool.remove_on_clone:
try:
delattr( aq_parent( aq_inner(self) ), self.id )
@@ -81,7 +84,7 @@
"""
# This helps in distinguishing renaming from copying/adding and
# importing in 'manage_afterAdd' (see below)
- anno_tool = getToolByName(item, 'portal_uidannotation')
+ anno_tool = getUtility(IUniqueIdAnnotationManagement)
if anno_tool.remove_on_add:
self._cmf_uid_is_rename = True
@@ -93,7 +96,7 @@
# a rename operation.
# This way I the unique id gets deleted on imports.
_is_rename = getattr(aq_base(self), '_cmf_uid_is_rename', None)
- anno_tool = getToolByName(item, 'portal_uidannotation')
+ anno_tool = getUtility(IUniqueIdAnnotationManagement)
if anno_tool.remove_on_add and anno_tool.remove_on_clone \
and not _is_rename:
try:
@@ -145,3 +148,5 @@
return UniqueIdAnnotation(obj, id)
InitializeClass(UniqueIdAnnotationTool)
+registerToolInterface('portal_uidannotation', IUniqueIdAnnotationManagement)
+
Modified: CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdGeneratorTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdGeneratorTool.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdGeneratorTool.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -24,6 +24,7 @@
from zope.interface import implements
from Products.CMFCore.ActionProviderBase import ActionProviderBase
+from Products.CMFCore.utils import registerToolInterface
from Products.CMFCore.utils import UniqueObject
from Products.CMFUid.interfaces import IUniqueIdGenerator
@@ -75,3 +76,5 @@
return int(uid)
InitializeClass(UniqueIdGeneratorTool)
+registerToolInterface('portal_uidgenerator', IUniqueIdGenerator)
+
Modified: CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdHandlerTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdHandlerTool.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFUid/UniqueIdHandlerTool.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -34,10 +34,12 @@
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 registerToolInterface
from Products.CMFCore.utils import UniqueObject
+from Products.CMFUid.interfaces import IUniqueIdAnnotationManagement
from Products.CMFUid.interfaces import IUniqueIdBrainQuery
+from Products.CMFUid.interfaces import IUniqueIdGenerator
from Products.CMFUid.interfaces import IUniqueIdHandler
from Products.CMFUid.interfaces import IUniqueIdUnrestrictedQuery
from Products.CMFUid.interfaces import UniqueIdError
@@ -95,7 +97,7 @@
"""Attaches a unique id to the object and does reindexing.
"""
# attach a unique id annotation to the object
- anno_tool = getToolByName(self, 'portal_uidannotation')
+ anno_tool = getUtility(IUniqueIdAnnotationManagement)
annotation = anno_tool(obj, self.UID_ATTRIBUTE_NAME)
annotation.setUid(uid)
@@ -109,7 +111,7 @@
uid = self.queryUid(obj, default=None)
if uid is None:
# generate a new unique id and set it
- generator = getToolByName(self, 'portal_uidgenerator')
+ generator = getUtility(IUniqueIdGenerator)
uid = generator()
self._setUid(obj, uid)
@@ -179,7 +181,7 @@
return default
# convert the uid to the right format
- generator = getToolByName(self, 'portal_uidgenerator')
+ generator = getUtility(IUniqueIdGenerator)
uid = generator.convert(uid)
catalog = getUtility(ICatalogTool)
@@ -263,3 +265,5 @@
manage_queryObject = PageTemplateFile('queryUID.pt', _wwwdir)
InitializeClass(UniqueIdHandlerTool)
+registerToolInterface('portal_uidhandler', IUniqueIdHandler)
+
Modified: CMF/branches/jens_tools_as_utilities/CMFUid/tests/test_uidannotation.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFUid/tests/test_uidannotation.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFUid/tests/test_uidannotation.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -19,13 +19,16 @@
import Testing
from OFS.event import ObjectClonedEvent
+
from zope.app.container.contained import ObjectAddedEvent
+from zope.component import getSiteManager
from zope.event import notify
from Products.CMFCore.PortalFolder import PortalFolder
from Products.CMFCore.testing import EventZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFCore.tests.base.testcase import SecurityTest
+from Products.CMFUid.interfaces import IUniqueIdAnnotationManagement
UID_ATTRNAME = 'cmf_uid'
@@ -45,6 +48,11 @@
self.root._setObject('portal_uidannotation', self._getTargetClass()())
self.root._setObject('dummy', DummyContent(id='dummy'))
+ sm = getSiteManager()
+ sm.registerUtility( self.root.portal_uidannotation
+ , IUniqueIdAnnotationManagement
+ )
+
def test_z3interfaces(self):
from zope.interface.verify import verifyClass
from Products.CMFUid.interfaces import IUniqueIdAnnotation
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-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/CMFUid/tests/test_uidhandling.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -25,6 +25,9 @@
from Products.CMFCore.tests.base.dummy import DummyFolder
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.testcase import SecurityTest
+from Products.CMFUid.interfaces import IUniqueIdAnnotationManagement
+from Products.CMFUid.interfaces import IUniqueIdGenerator
+from Products.CMFUid.interfaces import IUniqueIdHandler
class DummyUid:
@@ -56,6 +59,11 @@
sm = getSiteManager()
sm.registerUtility(self.root.portal_catalog, ICatalogTool)
+ sm.registerUtility( self.root.portal_uidannotation
+ , IUniqueIdAnnotationManagement
+ )
+ sm.registerUtility(self.root.portal_uidgenerator, IUniqueIdGenerator)
+ sm.registerUtility(self.root.portal_uidhandler, IUniqueIdHandler)
def test_z3interfaces(self):
from zope.interface.verify import verifyClass
Modified: CMF/branches/jens_tools_as_utilities/DCWorkflow/browser/workflow.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/DCWorkflow/browser/workflow.py 2006-12-28 21:05:37 UTC (rev 71661)
+++ CMF/branches/jens_tools_as_utilities/DCWorkflow/browser/workflow.py 2006-12-28 22:42:24 UTC (rev 71662)
@@ -18,10 +18,11 @@
from xml.dom.minidom import parseString
from zope.component import queryMultiAdapter
+from zope.component import queryUtility
-from Products.CMFCore.utils import getToolByName
from Products.GenericSetup.browser.utils import AddWithPresettingsViewBase
from Products.GenericSetup.interfaces import IBody
+from Products.GenericSetup.interfaces import ISetupTool
from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
@@ -37,7 +38,7 @@
def getProfileInfos(self):
profiles = []
- stool = getToolByName(self, 'portal_setup', None)
+ stool = queryUtility(ISetupTool)
if stool:
for info in stool.listContextInfos():
obj_ids = []
@@ -60,7 +61,7 @@
return tuple(profiles)
def _initSettings(self, obj, profile_id, obj_path):
- stool = getToolByName(self, 'portal_setup', None)
+ stool = queryUtility(ISetupTool)
if stool is None:
return
More information about the CMF-checkins
mailing list