[CMF-checkins] SVN: CMF/trunk/ - merging the
jens_tools_as_utilities branch
Jens Vagelpohl
jens at dataflake.org
Wed Mar 7 11:41:09 EST 2007
Log message for revision 73035:
- merging the jens_tools_as_utilities branch
Changed:
U CMF/trunk/CHANGES.txt
U CMF/trunk/CMFActionIcons/ActionIconsTool.py
U CMF/trunk/CMFActionIcons/exportimport.py
A CMF/trunk/CMFActionIcons/interfaces/
A CMF/trunk/CMFActionIcons/profiles/actionicons/componentregistry.xml
U CMF/trunk/CMFActionIcons/tests/test_exportimport.py
U CMF/trunk/CMFCalendar/CalendarTool.py
U CMF/trunk/CMFCalendar/browser/calendartool.py
U CMF/trunk/CMFCalendar/browser/event.py
U CMF/trunk/CMFCalendar/browser/event.txt
A CMF/trunk/CMFCalendar/profiles/default/componentregistry.xml
U CMF/trunk/CMFCalendar/setuphandlers.py
U CMF/trunk/CMFCalendar/skins/zpt_calendar/calendar_day_view.py
U CMF/trunk/CMFCalendar/skins/zpt_calendar/getMonthAndYear.py
U CMF/trunk/CMFCalendar/testing.py
U CMF/trunk/CMFCalendar/tests/test_Calendar.py
U CMF/trunk/CMFCore/ActionInformation.py
U CMF/trunk/CMFCore/ActionsTool.py
U CMF/trunk/CMFCore/CMFCatalogAware.py
U CMF/trunk/CMFCore/CachingPolicyManager.py
U CMF/trunk/CMFCore/CatalogTool.py
U CMF/trunk/CMFCore/ContentTypeRegistry.py
U CMF/trunk/CMFCore/CookieCrumbler.py
U CMF/trunk/CMFCore/DiscussionTool.py
U CMF/trunk/CMFCore/DynamicType.py
U CMF/trunk/CMFCore/Expression.py
A CMF/trunk/CMFCore/Extensions/migrateToCMF21.py
U CMF/trunk/CMFCore/FSObject.py
U CMF/trunk/CMFCore/MemberDataTool.py
U CMF/trunk/CMFCore/MembershipTool.py
U CMF/trunk/CMFCore/PortalFolder.py
U CMF/trunk/CMFCore/PortalObject.py
U CMF/trunk/CMFCore/RegistrationTool.py
U CMF/trunk/CMFCore/Skinnable.py
U CMF/trunk/CMFCore/SkinsTool.py
U CMF/trunk/CMFCore/TypesTool.py
U CMF/trunk/CMFCore/URLTool.py
U CMF/trunk/CMFCore/UndoTool.py
U CMF/trunk/CMFCore/WorkflowTool.py
U CMF/trunk/CMFCore/__init__.py
U CMF/trunk/CMFCore/browser/actions.py
U CMF/trunk/CMFCore/browser/typeinfo.py
U CMF/trunk/CMFCore/configure.zcml
U CMF/trunk/CMFCore/exportimport/actions.py
U CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py
U CMF/trunk/CMFCore/exportimport/catalog.py
U CMF/trunk/CMFCore/exportimport/content.py
U CMF/trunk/CMFCore/exportimport/contenttyperegistry.py
U CMF/trunk/CMFCore/exportimport/cookieauth.py
U CMF/trunk/CMFCore/exportimport/mailhost.py
U CMF/trunk/CMFCore/exportimport/skins.py
U CMF/trunk/CMFCore/exportimport/tests/test_actions.py
U CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py
U CMF/trunk/CMFCore/exportimport/tests/test_catalog.py
U CMF/trunk/CMFCore/exportimport/tests/test_content.py
U CMF/trunk/CMFCore/exportimport/tests/test_contenttyperegistry.py
U CMF/trunk/CMFCore/exportimport/tests/test_cookieauth.py
U CMF/trunk/CMFCore/exportimport/tests/test_mailhost.py
U CMF/trunk/CMFCore/exportimport/tests/test_skins.py
U CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py
U CMF/trunk/CMFCore/exportimport/tests/test_workflow.py
U CMF/trunk/CMFCore/exportimport/typeinfo.py
U CMF/trunk/CMFCore/exportimport/workflow.py
U CMF/trunk/CMFCore/interfaces/_tools.py
A CMF/trunk/CMFCore/overrides.zcml
A CMF/trunk/CMFCore/src/
_U CMF/trunk/CMFCore/src/five/
U CMF/trunk/CMFCore/testing.py
U CMF/trunk/CMFCore/tests/base/dummy.py
U CMF/trunk/CMFCore/tests/test_ActionInformation.py
U CMF/trunk/CMFCore/tests/test_ActionProviderBase.py
U CMF/trunk/CMFCore/tests/test_ActionsTool.py
U CMF/trunk/CMFCore/tests/test_CMFCatalogAware.py
U CMF/trunk/CMFCore/tests/test_CachingPolicyManager.py
U CMF/trunk/CMFCore/tests/test_DynamicType.py
U CMF/trunk/CMFCore/tests/test_Expression.py
U CMF/trunk/CMFCore/tests/test_FSDTMLMethod.py
U CMF/trunk/CMFCore/tests/test_FSPageTemplate.py
U CMF/trunk/CMFCore/tests/test_FSPropertiesObject.py
U CMF/trunk/CMFCore/tests/test_FSPythonScript.py
U CMF/trunk/CMFCore/tests/test_FSReSTMethod.py
U CMF/trunk/CMFCore/tests/test_FSSTXMethod.py
U CMF/trunk/CMFCore/tests/test_FSZSQLMethod.py
U CMF/trunk/CMFCore/tests/test_MemberDataTool.py
U CMF/trunk/CMFCore/tests/test_MembershipTool.py
U CMF/trunk/CMFCore/tests/test_OpaqueItems.py
U CMF/trunk/CMFCore/tests/test_PortalContent.py
U CMF/trunk/CMFCore/tests/test_PortalFolder.py
U CMF/trunk/CMFCore/tests/test_SkinsTool.py
U CMF/trunk/CMFCore/tests/test_TypesTool.py
U CMF/trunk/CMFCore/tests/test_URLTool.py
U CMF/trunk/CMFCore/tests/test_WorkflowTool.py
U CMF/trunk/CMFCore/utils.py
U CMF/trunk/CMFDefault/DefaultWorkflow.py
U CMF/trunk/CMFDefault/DiscussionItem.py
U CMF/trunk/CMFDefault/DiscussionTool.py
U CMF/trunk/CMFDefault/DublinCore.py
U CMF/trunk/CMFDefault/Extensions/update_catalogIndexes.py
U CMF/trunk/CMFDefault/Favorite.py
U CMF/trunk/CMFDefault/MembershipTool.py
U CMF/trunk/CMFDefault/MetadataTool.py
U CMF/trunk/CMFDefault/PropertiesTool.py
U CMF/trunk/CMFDefault/RegistrationTool.py
U CMF/trunk/CMFDefault/SyndicationTool.py
U CMF/trunk/CMFDefault/__init__.py
U CMF/trunk/CMFDefault/browser/favorite.py
U CMF/trunk/CMFDefault/browser/folder.py
U CMF/trunk/CMFDefault/browser/folder.txt
U CMF/trunk/CMFDefault/browser/metadata.py
U CMF/trunk/CMFDefault/browser/utils.py
U CMF/trunk/CMFDefault/factory.py
U CMF/trunk/CMFDefault/formlib/form.py
U CMF/trunk/CMFDefault/formlib/schema.py
U CMF/trunk/CMFDefault/formlib/widgets.py
U CMF/trunk/CMFDefault/formlib/widgets.txt
A CMF/trunk/CMFDefault/profiles/default/componentregistry.xml
U CMF/trunk/CMFDefault/profiles/default/export_steps.xml
U CMF/trunk/CMFDefault/profiles/default/import_steps.xml
U CMF/trunk/CMFDefault/skins/zpt_content/content_status_modify.py
U CMF/trunk/CMFDefault/skins/zpt_content/metadata_edit_control.py
U CMF/trunk/CMFDefault/skins/zpt_content/metadata_edit_form.py
U CMF/trunk/CMFDefault/skins/zpt_control/addtoFavorites.py
U CMF/trunk/CMFDefault/skins/zpt_control/change_password.py
U CMF/trunk/CMFDefault/skins/zpt_control/folder_localrole_edit.py
U CMF/trunk/CMFDefault/skins/zpt_control/members_add_control.py
U CMF/trunk/CMFDefault/skins/zpt_control/members_delete_control.py
U CMF/trunk/CMFDefault/skins/zpt_control/portal_config_control.py
U CMF/trunk/CMFDefault/skins/zpt_control/setRedirect.py
U CMF/trunk/CMFDefault/skins/zpt_control/undo.py
U CMF/trunk/CMFDefault/skins/zpt_control/validatePassword.py
U CMF/trunk/CMFDefault/skins/zpt_generic/RSS.py
U CMF/trunk/CMFDefault/skins/zpt_generic/breadcrumbs.py
U CMF/trunk/CMFDefault/skins/zpt_generic/discitem_delete.py
U CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply.py
U CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.py
U CMF/trunk/CMFDefault/skins/zpt_generic/expanded_title.py
U CMF/trunk/CMFDefault/skins/zpt_generic/folder_contents.py
U CMF/trunk/CMFDefault/skins/zpt_generic/folder_rename_form.py
U CMF/trunk/CMFDefault/skins/zpt_generic/getBatchItemInfos.py
U CMF/trunk/CMFDefault/skins/zpt_generic/getMainGlobals.py
U CMF/trunk/CMFDefault/skins/zpt_generic/get_permalink.py
U CMF/trunk/CMFDefault/skins/zpt_generic/join_form.py
U CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.py
U CMF/trunk/CMFDefault/skins/zpt_generic/members_delete_form.py
U CMF/trunk/CMFDefault/skins/zpt_generic/members_manage_form.py
U CMF/trunk/CMFDefault/skins/zpt_generic/news_box.py
U CMF/trunk/CMFDefault/skins/zpt_generic/password_email.py
U CMF/trunk/CMFDefault/skins/zpt_generic/password_form.py
U CMF/trunk/CMFDefault/skins/zpt_generic/permalink.py
U CMF/trunk/CMFDefault/skins/zpt_generic/recent_news.py
U CMF/trunk/CMFDefault/skins/zpt_generic/reconfig_form.py
U CMF/trunk/CMFDefault/skins/zpt_generic/registered_email.py
U CMF/trunk/CMFDefault/skins/zpt_generic/rejectItems.py
U CMF/trunk/CMFDefault/skins/zpt_generic/search.py
U CMF/trunk/CMFDefault/skins/zpt_generic/search_form.py
U CMF/trunk/CMFDefault/skins/zpt_generic/setup_talkback_tree.py
U CMF/trunk/CMFDefault/skins/zpt_generic/synPropertiesForm.py
U CMF/trunk/CMFDefault/testing.py
U CMF/trunk/CMFDefault/tests/RegistrationTool.txt
U CMF/trunk/CMFDefault/tests/test_DiscussionReply.py
U CMF/trunk/CMFDefault/tests/test_DiscussionTool.py
U CMF/trunk/CMFDefault/tests/test_Discussions.py
U CMF/trunk/CMFDefault/tests/test_DublinCore.py
U CMF/trunk/CMFDefault/tests/test_Favorite.py
U CMF/trunk/CMFDefault/tests/test_File.py
U CMF/trunk/CMFDefault/tests/test_Image.py
U CMF/trunk/CMFDefault/tests/test_MembershipTool.py
U CMF/trunk/CMFDefault/tests/test_Portal.py
U CMF/trunk/CMFDefault/tests/test_RegistrationTool.py
U CMF/trunk/CMFDefault/tests/test_SyndicationTool.py
U CMF/trunk/CMFDefault/tests/test_join.py
U CMF/trunk/CMFDefault/utils.py
U CMF/trunk/CMFTopic/Topic.py
U CMF/trunk/CMFTopic/tests/test_DateC.py
U CMF/trunk/CMFTopic/tests/test_Topic.py
U CMF/trunk/CMFUid/UniqueIdAnnotationTool.py
U CMF/trunk/CMFUid/UniqueIdGeneratorTool.py
U CMF/trunk/CMFUid/UniqueIdHandlerTool.py
A CMF/trunk/CMFUid/profiles/default/componentregistry.xml
U CMF/trunk/CMFUid/tests/test_uidannotation.py
U CMF/trunk/CMFUid/tests/test_uidhandling.py
U CMF/trunk/DCWorkflow/DCWorkflow.py
U CMF/trunk/DCWorkflow/Expression.py
U CMF/trunk/DCWorkflow/browser/workflow.py
U CMF/trunk/DCWorkflow/tests/test_DCWorkflow.py
U CMF/trunk/DCWorkflow/tests/test_exportimport.py
U CMF/trunk/DCWorkflow/tests/test_guard.py
U CMF/trunk/INSTALL.txt
-=-
Modified: CMF/trunk/CHANGES.txt
===================================================================
--- CMF/trunk/CHANGES.txt 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CHANGES.txt 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,5 +1,10 @@
CMF 2.1.0-beta (unreleased)
+ IMPORTANT NOTE:
+
+ If you upgrade an existing CMF instance to CMF 2.1, please see
+ INSTALL.txt for instructions on how to run a separate upgrade script.
+
New Features
- DirectoryView: Added 'registerDirectory' ZCML directive.
@@ -48,6 +53,9 @@
Others
+ - Tool lookup and registration is now done "the Zope 3 way" as utilities.
+ Please see docs/ToolsAreUtilities.txt for some developer notes.
+
- CMFCore utils: Marked 'minimalpath' and 'expandpath' as deprecated.
- The CMF now depends on Zope 2.10.2 or higher.
Modified: CMF/trunk/CMFActionIcons/ActionIconsTool.py
===================================================================
--- CMF/trunk/CMFActionIcons/ActionIconsTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFActionIcons/ActionIconsTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -22,10 +22,14 @@
from AccessControl import ClassSecurityInfo
from OFS.SimpleItem import SimpleItem
+from zope.interface import implements
+
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from Products.CMFCore.Expression import Expression
+from Products.CMFCore.utils import registerToolInterface
from Products.CMFCore.utils import UniqueObject
+from interfaces import IActionIconsTool
from permissions import ManagePortal
from permissions import View
@@ -35,6 +39,8 @@
security = ClassSecurityInfo()
+ implements(IActionIconsTool)
+
_title = None # Use the one supplied by the provider
_priority = 0 # All animals are equal....
_category = 'object'
@@ -419,3 +425,5 @@
)
InitializeClass( ActionIconsTool )
+registerToolInterface('portal_actionicons', IActionIconsTool)
+
Modified: CMF/trunk/CMFActionIcons/exportimport.py
===================================================================
--- CMF/trunk/CMFActionIcons/exportimport.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFActionIcons/exportimport.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -22,13 +22,17 @@
from Globals import package_home
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
-from Products.CMFCore.utils import getToolByName
+from zope.component import getSiteManager
+from zope.component import getUtility
+from zope.component import queryUtility
+
from Products.GenericSetup.utils import CONVERTER
from Products.GenericSetup.utils import DEFAULT
from Products.GenericSetup.utils import ExportConfiguratorBase
from Products.GenericSetup.utils import ImportConfiguratorBase
from Products.GenericSetup.utils import KEY
+from interfaces import IActionIconsTool
from permissions import ManagePortal
_pkgdir = package_home( globals() )
@@ -40,10 +44,11 @@
_FILENAME = 'actionicons.xml'
def importActionIconsTool(context):
- """ Import cache policy maanger settings from an XML file.
+ """ Import action icons tool settings from an XML file.
"""
site = context.getSite()
- ait = getToolByName(site, 'portal_actionicons', None)
+ sm = getSiteManager(site)
+ ait = sm.queryUtility(IActionIconsTool)
if ait is None:
return 'Action icons: No tool!'
@@ -89,7 +94,8 @@
def listActionIconInfo(self):
""" Return a list of mappings describing the action icons.
"""
- ait = getToolByName(self._site, 'portal_actionicons')
+ sm = getSiteManager(self._site)
+ ait = sm.getUtility(IActionIconsTool)
for action_icon in ait.listActionIcons():
yield {'category': action_icon.getCategory(),
'action_id': action_icon.getActionId(),
Copied: CMF/trunk/CMFActionIcons/interfaces (from rev 73020, CMF/branches/jens_tools_as_utilities/CMFActionIcons/interfaces)
Copied: CMF/trunk/CMFActionIcons/profiles/actionicons/componentregistry.xml (from rev 73020, CMF/branches/jens_tools_as_utilities/CMFActionIcons/profiles/actionicons/componentregistry.xml)
Modified: CMF/trunk/CMFActionIcons/tests/test_exportimport.py
===================================================================
--- CMF/trunk/CMFActionIcons/tests/test_exportimport.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFActionIcons/tests/test_exportimport.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,7 +18,11 @@
import unittest
import Testing
-from Products.GenericSetup.testing import ExportImportZCMLLayer
+from zope.component import getSiteManager
+
+from Products.CMFActionIcons.interfaces import IActionIconsTool
+from Products.CMFCore.testing import ExportImportZCMLLayer
+from Products.CMFCore.tests.base.utils import _setUpDefaultTraversable
from Products.GenericSetup.tests.common import BaseRegistryTests
from Products.GenericSetup.tests.common import DummyExportContext
from Products.GenericSetup.tests.common import DummyImportContext
@@ -60,11 +64,16 @@
from OFS.Folder import Folder
from Products.CMFActionIcons.ActionIconsTool import ActionIconsTool
+ _setUpDefaultTraversable()
+
self.root.site = Folder(id='site')
site = self.root.site
tool = ActionIconsTool()
site._setObject( tool.getId(), tool )
+ sm = getSiteManager()
+ sm.registerUtility(site.portal_actionicons, IActionIconsTool)
+
if with_icon:
tool.addActionIcon( category=self.CATEGORY
, action_id=self.ACTION_ID
Modified: CMF/trunk/CMFCalendar/CalendarTool.py
===================================================================
--- CMF/trunk/CMFCalendar/CalendarTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCalendar/CalendarTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -24,6 +24,7 @@
from zope.interface import implements
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from Products.CMFCore.utils import registerToolInterface
from Products.CMFCore.utils import UniqueObject
from interfaces import ICalendarTool
@@ -357,3 +358,4 @@
return (begin, end)
InitializeClass(CalendarTool)
+registerToolInterface('portal_calendar', ICalendarTool)
Modified: CMF/trunk/CMFCalendar/browser/calendartool.py
===================================================================
--- CMF/trunk/CMFCalendar/browser/calendartool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCalendar/browser/calendartool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -21,7 +21,9 @@
from Products.CMFDefault.browser.utils import memoize
from Products.CMFDefault.browser.utils import ViewBase
+from Products.CMFCalendar.interfaces import ICalendarTool
+
class CalendarView(ViewBase):
""" Helper class for calendar-related templates
@@ -92,7 +94,7 @@
def listItemInfos(self):
""" List item infos for all event catalog records for a specific day.
"""
- caltool = self._getTool('portal_calendar')
+ caltool = self._getToolByInterface(ICalendarTool)
thisDay = self.viewDay()
items = [ {'title': item.Title,
@@ -112,7 +114,7 @@
def getMonthAndYear(self):
""" Retrieve month/year tuple
"""
- caltool = self._getTool('portal_calendar')
+ caltool = self._getToolByInterface(ICalendarTool)
current = DateTime()
session = None
@@ -146,7 +148,7 @@
def getNextMonthLink(self, base_url, month, year):
""" Return URL for the next month link
"""
- caltool = self._getTool('portal_calendar')
+ caltool = self._getToolByInterface(ICalendarTool)
nextMonthTime = caltool.getNextMonth(month, year)
x = '%s?month:int=%d&year:int=%d' % ( base_url
@@ -159,7 +161,7 @@
def getPreviousMonthLink(self, base_url, month, year):
""" Return URL for the previous month link
"""
- caltool = self._getTool('portal_calendar')
+ caltool = self._getToolByInterface(ICalendarTool)
prevMonthTime = caltool.getPreviousMonth(month, year)
x = '%s?month:int=%d&year:int=%d' % ( base_url
Modified: CMF/trunk/CMFCalendar/browser/event.py
===================================================================
--- CMF/trunk/CMFCalendar/browser/event.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCalendar/browser/event.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFCalendar/browser/event.txt
===================================================================
--- CMF/trunk/CMFCalendar/browser/event.txt 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCalendar/browser/event.txt 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,13 +1,15 @@
Event Views
-----------
-Set up Event and user.
+Set up site, user and Event.
- >>> from Products.CMFCalendar.Event import Event
- >>> id = app.site._setObject('myEvent', Event('myEvent'))
-
+ >>> from zope.app.component.hooks import setSite
+ >>> setSite(app.site)
>>> uf = app.site.acl_users
>>> uf._doAddUser('mgr', 'mgrpw', ['Manager'], [])
+ >>> from AccessControl.SecurityManagement import newSecurityManager
+ >>> newSecurityManager(None, uf.getUser('mgr').__of__(uf))
+ >>> id = app.site.invokeFactory(type_name='Event', id='myEvent')
Create the browser object we'll be using.
Copied: CMF/trunk/CMFCalendar/profiles/default/componentregistry.xml (from rev 73020, CMF/branches/jens_tools_as_utilities/CMFCalendar/profiles/default/componentregistry.xml)
Modified: CMF/trunk/CMFCalendar/setuphandlers.py
===================================================================
--- CMF/trunk/CMFCalendar/setuphandlers.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCalendar/setuphandlers.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFCalendar/skins/zpt_calendar/calendar_day_view.py
===================================================================
--- CMF/trunk/CMFCalendar/skins/zpt_calendar/calendar_day_view.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCalendar/skins/zpt_calendar/calendar_day_view.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,9 +1,9 @@
##parameters=
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
-caltool = getToolByName(script, 'portal_calendar')
+caltool = getToolByInterfaceName('Products.CMFCalendar.interfaces.ICalendarTool')
options = {}
base_url = script.absolute_url()
Modified: CMF/trunk/CMFCalendar/skins/zpt_calendar/getMonthAndYear.py
===================================================================
--- CMF/trunk/CMFCalendar/skins/zpt_calendar/getMonthAndYear.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCalendar/skins/zpt_calendar/getMonthAndYear.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,9 +1,9 @@
# Get the year and month that the calendar should display.
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
-caltool = getToolByName(script, 'portal_calendar')
+caltool = getToolByInterfaceName('Products.CMFCalendar.interfaces.ICalendarTool')
current = DateTime()
session = None
Modified: CMF/trunk/CMFCalendar/testing.py
===================================================================
--- CMF/trunk/CMFCalendar/testing.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCalendar/testing.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -53,3 +53,4 @@
app._delObject('site')
transaction.commit()
ZopeTestCase.close(app)
+
Modified: CMF/trunk/CMFCalendar/tests/test_Calendar.py
===================================================================
--- CMF/trunk/CMFCalendar/tests/test_Calendar.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCalendar/tests/test_Calendar.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -24,6 +24,7 @@
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.User import UnrestrictedUser
from DateTime import DateTime
+from zope.app.component.hooks import setSite
from Products.CMFCalendar.testing import FunctionalLayer
@@ -107,6 +108,7 @@
layer = FunctionalLayer
def afterSetUp(self):
+ setSite(self.app.site)
newSecurityManager(None, UnrestrictedUser('god', '', ['Manager'], ''))
# sessioning setup
Modified: CMF/trunk/CMFCore/ActionInformation.py
===================================================================
--- CMF/trunk/CMFCore/ActionInformation.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/ActionInformation.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -24,6 +24,8 @@
from OFS.OrderedFolder import OrderedFolder
from OFS.PropertyManager import PropertyManager
from OFS.SimpleItem import SimpleItem
+
+from zope.component import getUtility
from zope.i18nmessageid import Message
from zope.interface import implements
@@ -31,11 +33,11 @@
from interfaces import IAction
from interfaces import IActionCategory
from interfaces import IActionInfo
+from interfaces import IMembershipTool
from interfaces.portal_actions import ActionInfo as z2IActionInfo
from permissions import View
from utils import _checkPermission
from utils import _wwwdir
-from utils import getToolByName
_unchanged = [] # marker
@@ -502,7 +504,7 @@
def __init__( self, tool, folder, object=None ):
self.portal = portal = aq_parent(aq_inner(tool))
- membership = getToolByName(tool, 'portal_membership')
+ membership = getUtility(IMembershipTool)
self.isAnonymous = membership.isAnonymousUser()
self.user_id = membership.getAuthenticatedMember().getId()
self.portal_url = portal.absolute_url()
Modified: CMF/trunk/CMFCore/ActionsTool.py
===================================================================
--- CMF/trunk/CMFCore/ActionsTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/ActionsTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -30,6 +30,7 @@
from interfaces.portal_actions import portal_actions as z2IActionsTool
from permissions import ManagePortal
from utils import _dtmldir
+from utils import registerToolInterface
from utils import UniqueObject
@@ -183,3 +184,4 @@
return filtered_actions
InitializeClass(ActionsTool)
+registerToolInterface('portal_actions', IActionsTool)
Modified: CMF/trunk/CMFCore/CMFCatalogAware.py
===================================================================
--- CMF/trunk/CMFCore/CMFCatalogAware.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/CMFCatalogAware.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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
@@ -33,9 +35,10 @@
from permissions import ModifyPortalContent
from utils import _dtmldir
from utils import _getAuthenticatedUser
-from utils import getToolByName
from interfaces import ICallableOpaqueItem
+from interfaces import ICatalogTool
+from interfaces import IConfigurableWorkflowTool
from interfaces.IOpaqueItems \
import ICallableOpaqueItem as z2ICallableOpaqueItem
@@ -55,10 +58,10 @@
# 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)
+ return queryUtility(IConfigurableWorkflowTool)
# Cataloging methods
# ------------------
Modified: CMF/trunk/CMFCore/CachingPolicyManager.py
===================================================================
--- CMF/trunk/CMFCore/CachingPolicyManager.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/CachingPolicyManager.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -29,7 +29,9 @@
from OFS.SimpleItem import SimpleItem
from Products.PageTemplates.Expressions import getEngine
from Products.PageTemplates.Expressions import SecureModuleImporter
+
from zope.app.container.interfaces import IObjectMovedEvent
+from zope.component import queryUtility
from zope.interface import implements
from permissions import ManagePortal
@@ -37,12 +39,13 @@
from Expression import Expression
from interfaces import ICachingPolicy
from interfaces import ICachingPolicyManager
+from interfaces import IMembershipTool
from interfaces.CachingPolicyManager \
import CachingPolicyManager as z2ICachingPolicyManager
from utils import _dtmldir
from utils import _setCacheHeaders
from utils import _ViewEmulator
-from utils import getToolByName
+from utils import registerToolInterface
# This is lame :(
# This listing is used to decide whether to wrap an object inside a "fake view"
@@ -61,7 +64,7 @@
Construct an expression context for TALES expressions,
for use by CachingPolicy objects.
"""
- pm = getToolByName( content, 'portal_membership', None )
+ pm = queryUtility(IMembershipTool)
if not pm or pm.isAnonymousUser():
member = None
else:
@@ -876,8 +879,8 @@
InitializeClass( CachingPolicyManager )
+registerToolInterface('caching_policy_manager', ICachingPolicyManager)
-
def handleCachingPolicyManagerEvent(ob, event):
""" Event subscriber for (un)registering a CPM as CacheManager
"""
Modified: CMF/trunk/CMFCore/CatalogTool.py
===================================================================
--- CMF/trunk/CMFCore/CatalogTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/CatalogTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -24,6 +24,8 @@
from Globals import InitializeClass
from Products.PluginIndexes.common import safe_callable
from Products.ZCatalog.ZCatalog import ZCatalog
+
+from zope.component import queryUtility
from zope.interface import implements
from zope.interface import providedBy
from zope.interface.declarations import getObjectSpecification
@@ -33,6 +35,7 @@
from ActionProviderBase import ActionProviderBase
from interfaces import ICatalogTool
from interfaces import IIndexableObjectWrapper
+from interfaces import IConfigurableWorkflowTool
from interfaces.portal_catalog \
import IndexableObjectWrapper as z2IIndexableObjectWrapper
from interfaces.portal_catalog import portal_catalog as z2ICatalogTool
@@ -43,7 +46,7 @@
from utils import _dtmldir
from utils import _getAuthenticatedUser
from utils import _mergedLocalRoles
-from utils import getToolByName
+from utils import registerToolInterface
from utils import UniqueObject
@@ -250,7 +253,7 @@
pghandler=None):
# Wraps the object with workflow and accessibility
# information just before cataloging.
- wftool = getToolByName(self, 'portal_workflow', None)
+ wftool = queryUtility(IConfigurableWorkflowTool)
if wftool is not None:
vars = wftool.getCatalogVariablesFor(obj)
else:
@@ -295,3 +298,4 @@
self.catalog_object(object, uid, idxs, update_metadata)
InitializeClass(CatalogTool)
+registerToolInterface('portal_catalog', ICatalogTool)
Modified: CMF/trunk/CMFCore/ContentTypeRegistry.py
===================================================================
--- CMF/trunk/CMFCore/ContentTypeRegistry.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/ContentTypeRegistry.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -23,17 +23,20 @@
from Globals import PersistentMapping
from OFS.SimpleItem import SimpleItem
from ZPublisher.mapply import mapply
+
+from zope.component import getUtility
from zope.interface import implements
from interfaces import IContentTypeRegistry
from interfaces import IContentTypeRegistryPredicate
+from interfaces import ITypesTool
from interfaces.ContentTypeRegistry \
import ContentTypeRegistry as z2IContentTypeRegistry
from interfaces.ContentTypeRegistry \
import ContentTypeRegistryPredicate as z2IContentTypeRegistryPredicate
from permissions import ManagePortal
from utils import _dtmldir
-from utils import getToolByName
+from utils import registerToolInterface
class MajorMinorPredicate( SimpleItem ):
@@ -436,7 +439,7 @@
if typeName is None:
typeName = '<unknown>'
else:
- types_tool = getToolByName(self, 'portal_types')
+ types_tool = getUtility(ITypesTool)
typeName = types_tool.getTypeInfo(typeName).Title()
REQUEST[ 'RESPONSE' ].redirect( self.absolute_url()
+ '/manage_testRegistry'
@@ -549,6 +552,7 @@
return None
InitializeClass( ContentTypeRegistry )
+registerToolInterface('content_type_registry', IContentTypeRegistry)
def manage_addRegistry( self, REQUEST=None ):
"""
Modified: CMF/trunk/CMFCore/CookieCrumbler.py
===================================================================
--- CMF/trunk/CMFCore/CookieCrumbler.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/CookieCrumbler.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -32,6 +32,7 @@
from OFS.interfaces import IObjectWillBeMovedEvent
from interfaces import ICookieCrumbler
+from utils import registerToolInterface
# Constants.
@@ -382,6 +383,7 @@
return id
Globals.InitializeClass(CookieCrumbler)
+registerToolInterface('cookie_authentication', ICookieCrumbler)
def handleCookieCrumblerEvent(ob, event):
""" Event subscriber for (un)registering a CC as a before traverse hook.
Modified: CMF/trunk/CMFCore/DiscussionTool.py
===================================================================
--- CMF/trunk/CMFCore/DiscussionTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/DiscussionTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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,13 +28,15 @@
from permissions import ManagePortal
from permissions import ReplyToItem
from permissions import View
+from interfaces import ICatalogTool
+from interfaces import IMembershipTool
from interfaces import IOldstyleDiscussable
from interfaces import IOldstyleDiscussionTool
+from interfaces import ITypesTool
from interfaces.Discussions import OldDiscussable as z2IOldstyleDiscussable
from interfaces.portal_discussion \
import oldstyle_portal_discussion as z2IOldstyleDiscussionTool
from utils import _dtmldir
-from utils import getToolByName
from utils import UniqueObject
@@ -68,7 +72,7 @@
# It is not yet clear to me what the correct location for this hook is
# Find the folder designated for replies, creating if missing
- membershiptool = getToolByName(self.content, 'portal_membership')
+ membershiptool = getUtility(IMembershipTool)
home = membershiptool.getHomeFolder()
if not hasattr(home, 'Correspondence'):
home.manage_addPortalFolder('Correspondence')
@@ -91,7 +95,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 +105,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)
@@ -155,7 +159,7 @@
'''
if hasattr( content, 'allow_discussion' ):
return content.allow_discussion
- typeInfo = getToolByName(self, 'portal_types').getTypeInfo( content )
+ typeInfo = getUtility(ITypesTool).getTypeInfo( content )
if typeInfo:
return typeInfo.allowDiscussion()
return 0
Modified: CMF/trunk/CMFCore/DynamicType.py
===================================================================
--- CMF/trunk/CMFCore/DynamicType.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/DynamicType.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -19,11 +19,17 @@
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
+
+from zope.app.publication.zopepublication import BeforeTraverseEvent
+from zope.component import getUtility
+from zope.component import queryUtility
+from zope.event import notify
from zope.interface import implements
from interfaces import IDynamicType
+from interfaces import ITypesTool
+from interfaces import IURLTool
from interfaces.Dynamic import DynamicType as z2IDynamicType
-from utils import getToolByName
from zope.component import queryMultiAdapter
from zope.app.publisher.browser import queryDefaultViewName
@@ -66,7 +72,7 @@
def getTypeInfo(self):
""" Get the TypeInformation object specified by the portal type.
"""
- tool = getToolByName(self, 'portal_types', None)
+ tool = queryUtility(ITypesTool)
if tool is None:
return None
return tool.getTypeInfo(self) # Can return None.
@@ -102,7 +108,7 @@
return icon
else:
# Relative to REQUEST['BASEPATH1']
- portal_url = getToolByName( self, 'portal_url' )
+ portal_url = getUtility(IURLTool)
res = portal_url(relative=1) + '/' + icon
while res[:1] == '/':
res = res[1:]
@@ -118,6 +124,8 @@
# XXX hack around a bug(?) in BeforeTraverse.MultiHook
REQUEST = arg2 or arg1
+ notify(BeforeTraverseEvent(self, REQUEST))
+
if REQUEST['REQUEST_METHOD'] not in ('GET', 'POST'):
return
Modified: CMF/trunk/CMFCore/Expression.py
===================================================================
--- CMF/trunk/CMFCore/Expression.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/Expression.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -19,10 +19,14 @@
from Acquisition import aq_base, aq_inner, aq_parent
from Globals import InitializeClass
from Globals import Persistent
+
+from zope.component import getUtility
+
from Products.PageTemplates.Expressions import getEngine
from Products.PageTemplates.Expressions import SecureModuleImporter
-from utils import getToolByName
+from interfaces import IMembershipTool
+from interfaces import IURLTool
class Expression(Persistent):
@@ -63,7 +67,7 @@
else:
ec = None
if ec is None:
- utool = getToolByName(context, 'portal_url')
+ utool = getUtility(IURLTool)
portal = utool.getPortalObject()
if object is None or not hasattr(object, 'aq_base'):
folder = portal
@@ -87,7 +91,7 @@
'''
An expression context provides names for TALES expressions.
'''
- pm = getToolByName(portal, 'portal_membership')
+ pm = getUtility(IMembershipTool)
if object is None:
object_url = ''
else:
Copied: CMF/trunk/CMFCore/Extensions/migrateToCMF21.py (from rev 73020, CMF/branches/jens_tools_as_utilities/CMFCore/Extensions/migrateToCMF21.py)
Modified: CMF/trunk/CMFCore/FSObject.py
===================================================================
--- CMF/trunk/CMFCore/FSObject.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/FSObject.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFCore/MemberDataTool.py
===================================================================
--- CMF/trunk/CMFCore/MemberDataTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/MemberDataTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -23,12 +23,17 @@
from OFS.PropertyManager import PropertyManager
from OFS.SimpleItem import SimpleItem
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
from exceptions import BadRequest
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
@@ -36,7 +41,7 @@
from permissions import SetOwnProperties
from permissions import ViewManagementScreens
from utils import _dtmldir
-from utils import getToolByName
+from utils import registerToolInterface
from utils import UniqueObject
@@ -99,7 +104,7 @@
Return the number of members stored in the _members
BTree and some other useful info
'''
- membertool = getToolByName(self, 'portal_membership')
+ membertool = getUtility(IMembershipTool)
members = self._members
user_list = membertool.listMemberIds()
member_list = members.keys()
@@ -121,7 +126,7 @@
if not search_param:
return res
- membership = getToolByName(self, 'portal_membership')
+ membership = getUtility(IMembershipTool)
if len(attributes) == 0:
attributes = ('id', 'email')
@@ -157,7 +162,7 @@
if search_param == 'username':
search_param = 'id'
- mtool = getToolByName(self, 'portal_membership')
+ mtool = getUtility(IMembershipTool)
for member_id in self._members.keys():
@@ -179,7 +184,7 @@
def pruneMemberDataContents(self):
""" Delete data contents of all members not listet in acl_users.
"""
- membertool= getToolByName(self, 'portal_membership')
+ membertool= getUtility(IMembershipTool)
members = self._members
user_list = membertool.listMemberIds()
@@ -235,6 +240,7 @@
return 0
InitializeClass(MemberDataTool)
+registerToolInterface('portal_memberdata', IMemberDataTool)
class CleanupTemp:
@@ -301,8 +307,8 @@
'''
if properties is None:
properties = kw
- membership = getToolByName(self, 'portal_membership')
- registration = getToolByName(self, 'portal_registration', None)
+ membership = getUtility(IMembershipTool)
+ registration = queryUtility(IRegistrationTool)
if not membership.isAnonymousUser():
member = membership.getAuthenticatedMember()
if registration:
Modified: CMF/trunk/CMFCore/MembershipTool.py
===================================================================
--- CMF/trunk/CMFCore/MembershipTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/MembershipTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -27,12 +27,18 @@
from Globals import PersistentMapping
from OFS.Folder import Folder
from ZODB.POSException import ConflictError
+
+from zope.component import getUtility
+from zope.component import queryUtility
from zope.interface import implements
from ActionProviderBase import ActionProviderBase
from exceptions import AccessControl_Unauthorized
from exceptions import BadRequest
+from interfaces import IMemberDataTool
from interfaces import IMembershipTool
+from interfaces import IRegistrationTool
+from interfaces import IURLTool
from interfaces.portal_membership \
import portal_membership as z2IMembershipTool
from permissions import AccessContentsInformation
@@ -45,7 +51,6 @@
from utils import _checkPermission
from utils import _dtmldir
from utils import _getAuthenticatedUser
-from utils import getToolByName
from utils import UniqueObject
@@ -94,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:
@@ -141,7 +146,7 @@
portal_role not in u.roles):
u.roles.append(portal_role)
- mdtool = getToolByName(self, 'portal_memberdata', None)
+ mdtool = queryUtility(IMemberDataTool)
if mdtool is not None:
try:
u = mdtool.wrapUser(u)
@@ -403,7 +408,7 @@
security.declareProtected(ListPortalMembers, 'searchMembers')
def searchMembers( self, search_param, search_term ):
""" Search the membership """
- md = getToolByName( self, 'portal_memberdata' )
+ md = getUtility(IMemberDataTool)
return md.searchMemberData( search_param, search_term )
@@ -505,7 +510,7 @@
'permission for the underlying User Folder.')
# Delete member data in portal_memberdata.
- mdtool = getToolByName(self, 'portal_memberdata', None)
+ mdtool = queryUtility(IMemberDataTool)
if mdtool is not None:
for member_id in member_ids:
mdtool.deleteMemberData(member_id)
@@ -517,7 +522,7 @@
# Delete members' local roles.
if delete_localroles:
- utool = getToolByName(self, 'portal_url', None)
+ utool = getUtility(IURLTool)
self.deleteLocalRoles( utool.getPortalObject(), member_ids,
reindex=1, recursive=1 )
Modified: CMF/trunk/CMFCore/PortalFolder.py
===================================================================
--- CMF/trunk/CMFCore/PortalFolder.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/PortalFolder.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -25,6 +25,9 @@
from Globals import InitializeClass
from OFS.OrderSupport import OrderSupport
from OFS.Folder import Folder
+
+from zope.component import getUtility
+from zope.component import queryUtility
from zope.component.factory import Factory
from zope.interface import implements
@@ -33,8 +36,10 @@
from exceptions import AccessControl_Unauthorized
from exceptions import BadRequest
from exceptions import zExceptions_Unauthorized
+from interfaces import IContentTypeRegistry
from interfaces import IFolderish
from interfaces import IMutableMinimalDublinCore
+from interfaces import ITypesTool
from interfaces.Folderish import Folderish as z2IFolderish
from permissions import AddPortalContent
from permissions import AddPortalFolders
@@ -44,7 +49,6 @@
from permissions import ManageProperties
from permissions import View
from utils import _checkPermission
-from utils import getToolByName
class PortalFolderBase(DynamicType, CMFCatalogAware, Folder):
@@ -121,7 +125,7 @@
this folder.
"""
result = []
- portal_types = getToolByName(self, 'portal_types')
+ portal_types = getUtility(ITypesTool)
myType = portal_types.getTypeInfo(self)
if myType is not None:
@@ -149,7 +153,7 @@
pt = filt.get('portal_type', [])
if isinstance(pt, basestring):
pt = [pt]
- types_tool = getToolByName(self, 'portal_types')
+ types_tool = getUtility(ITypesTool)
allowed_types = types_tool.listContentTypes()
if not pt:
pt = allowed_types
@@ -280,7 +284,7 @@
Returns -- Bare and empty object of the appropriate type (or None, if
we don't know what to do)
"""
- registry = getToolByName(self, 'content_type_registry', None)
+ registry = queryUtility(IContentTypeRegistry)
if registry is None:
return None
@@ -299,7 +303,7 @@
def invokeFactory(self, type_name, id, RESPONSE=None, *args, **kw):
""" Invokes the portal_types tool.
"""
- pt = getToolByName(self, 'portal_types')
+ pt = getUtility(ITypesTool)
myType = pt.getTypeInfo(self)
if myType is not None:
@@ -419,7 +423,7 @@
if type_name is not None:
- pt = getToolByName(self, 'portal_types')
+ pt = getUtility(ITypesTool)
myType = pt.getTypeInfo(self)
if myType is not None and not myType.allowType(type_name):
Modified: CMF/trunk/CMFCore/PortalObject.py
===================================================================
--- CMF/trunk/CMFCore/PortalObject.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/PortalObject.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -15,7 +15,13 @@
$Id$
"""
+from warnings import warn
+
+from five.localsitemanager import find_next_sitemanager
+from five.localsitemanager.registry import PersistentComponents
from Globals import InitializeClass
+from Products.Five.component.interfaces import IObjectManagerSite
+from zope.component.globalregistry import base
from zope.interface import implements
from interfaces import ISiteRoot
@@ -33,7 +39,7 @@
class PortalObjectBase(PortalFolder, SkinnableObjectManager):
- implements(ISiteRoot)
+ implements(ISiteRoot, IObjectManagerSite)
meta_type = 'Portal Site'
_isPortalRoot = 1
@@ -53,6 +59,18 @@
)
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
+ def getSiteManager(self):
+ if self._components is None:
+ next = find_next_sitemanager(self)
+ if next is None:
+ next = base
+ name = '/'.join(self.getPhysicalPath())
+ self._components = PersistentComponents(name, (next,))
+ return self._components
+
InitializeClass(PortalObjectBase)
Modified: CMF/trunk/CMFCore/RegistrationTool.py
===================================================================
--- CMF/trunk/CMFCore/RegistrationTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/RegistrationTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -22,9 +22,12 @@
from Globals import DTMLFile
from Globals import InitializeClass
from OFS.SimpleItem import SimpleItem
+
+from zope.component import getUtility
from zope.interface import implements
from ActionProviderBase import ActionProviderBase
+from interfaces import IMembershipTool
from interfaces import IRegistrationTool
from interfaces.portal_registration \
import portal_registration as z2IRegistrationTool
@@ -34,7 +37,6 @@
from utils import _checkPermission
from utils import _dtmldir
from utils import _limitGrantedRoles
-from utils import getToolByName
from utils import Message as _
from utils import UniqueObject
@@ -157,7 +159,7 @@
# Anyone is always allowed to grant the 'Member' role.
_limitGrantedRoles(roles, self, ('Member',))
- membership = getToolByName(self, 'portal_membership')
+ membership = getUtility(IMembershipTool)
membership.addMember(id, password, roles, domains, properties)
member = membership.getMemberById(id)
@@ -172,7 +174,7 @@
return 0
if not self._ALLOWED_MEMBER_ID_PATTERN.match( id ):
return 0
- membership = getToolByName(self, 'portal_membership')
+ membership = getUtility(IMembershipTool)
if membership.getMemberById(id) is not None:
return 0
return 1
Modified: CMF/trunk/CMFCore/Skinnable.py
===================================================================
--- CMF/trunk/CMFCore/Skinnable.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/Skinnable.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -20,6 +20,8 @@
import logging
from thread import get_ident
+from warnings import warn
+from zope.component import getSiteManager
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
@@ -28,7 +30,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 +69,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 +107,34 @@
"""Returns the requested skin.
"""
skinob = None
- sfn = self.getSkinsFolderName()
+ sf = queryUtility(ISkinsTool)
+ if sf is None:
+ # XXX: Maybe we can set up the skin *after* the sm?
+ # try again with self as explicit site
+ sm = getSiteManager(self)
+ sf = sm.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 None:
+ # XXX: Maybe we can set up the skin *after* the sm?
+ # try again with self as explicit site
+ sm = getSiteManager(self)
+ sf = sm.queryUtility(ISkinsTool)
+ if sf is not None:
+ return REQUEST.get(sf.getRequestVarname(), None)
security.declarePublic('changeSkin')
def changeSkin(self, skinname):
@@ -146,11 +161,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/trunk/CMFCore/SkinsTool.py
===================================================================
--- CMF/trunk/CMFCore/SkinsTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/SkinsTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -27,20 +27,24 @@
from OFS.ObjectManager import REPLACEABLE
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
from Products.PythonScripts.PythonScript import PythonScript
+
+from zope.component import getUtility
from zope.interface import implements
from ActionProviderBase import ActionProviderBase
from DirectoryView import base_ignore
from DirectoryView import ignore
from DirectoryView import ignore_re
+from interfaces import IMembershipTool
from interfaces import ISkinsTool
+from interfaces import IURLTool
from interfaces.portal_skins import portal_skins as z2ISkinsTool
from permissions import AccessContentsInformation
from permissions import ManagePortal
from permissions import View
from SkinsContainer import SkinsContainer
from utils import _dtmldir
-from utils import getToolByName
+from utils import registerToolInterface
from utils import UniqueObject
@@ -305,8 +309,8 @@
def updateSkinCookie(self):
""" If needed, updates the skin cookie based on the member preference.
"""
- mtool = getToolByName(self, 'portal_membership')
- utool = getToolByName(self, 'portal_url')
+ mtool = getUtility(IMembershipTool)
+ utool = getUtility(IURLTool)
member = mtool.getAuthenticatedMember()
if hasattr(aq_base(member), 'portal_skin'):
mskin = member.portal_skin
@@ -341,7 +345,7 @@
"""
req = self.REQUEST
resp = req.RESPONSE
- utool = getToolByName(self, 'portal_url')
+ utool = getUtility(IURLTool)
portal_path = req['BASEPATH1'] + '/' + utool(1)
resp.expireCookie(self.request_varname, path=portal_path)
@@ -371,3 +375,5 @@
self.default_skin = skinname
InitializeClass(SkinsTool)
+registerToolInterface('portal_skins', ISkinsTool)
+
Modified: CMF/trunk/CMFCore/TypesTool.py
===================================================================
--- CMF/trunk/CMFCore/TypesTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/TypesTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -49,7 +49,7 @@
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
@@ -744,3 +744,5 @@
return rval
InitializeClass(TypesTool)
+registerToolInterface('portal_types', ITypesTool)
+
Modified: CMF/trunk/CMFCore/URLTool.py
===================================================================
--- CMF/trunk/CMFCore/URLTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/URLTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -21,14 +21,18 @@
from Globals import DTMLFile
from Globals import InitializeClass
from OFS.SimpleItem import SimpleItem
+
+from zope.component import getUtility
from zope.interface import implements
from ActionProviderBase import ActionProviderBase
+from interfaces import ISiteRoot
from interfaces import IURLTool
from interfaces.portal_url import portal_url as z2IURLTool
from permissions import ManagePortal
from permissions import View
from utils import _dtmldir
+from utils import registerToolInterface
from utils import UniqueObject
@@ -73,7 +77,7 @@
def getPortalObject(self):
""" Get the portal object itself.
"""
- return aq_parent( aq_inner(self) )
+ return getUtility(ISiteRoot)
security.declarePublic('getRelativeContentPath')
def getRelativeContentPath(self, content):
@@ -99,3 +103,4 @@
return '/'.join( self.getPortalObject().getPhysicalPath() )
InitializeClass(URLTool)
+registerToolInterface('portal_url', IURLTool)
Modified: CMF/trunk/CMFCore/UndoTool.py
===================================================================
--- CMF/trunk/CMFCore/UndoTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/UndoTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -30,6 +30,7 @@
from utils import _checkPermission
from utils import _dtmldir
from utils import _getAuthenticatedUser
+from utils import registerToolInterface
from utils import UniqueObject
@@ -112,3 +113,5 @@
object.manage_undo_transactions(transaction_info)
InitializeClass(UndoTool)
+registerToolInterface('portal_undo', IUndoTool)
+
Modified: CMF/trunk/CMFCore/WorkflowTool.py
===================================================================
--- CMF/trunk/CMFCore/WorkflowTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/WorkflowTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -24,18 +24,21 @@
from Globals import PersistentMapping
from OFS.Folder import Folder
from OFS.ObjectManager import IFAwareObjectManager
+
+from zope.component import queryUtility
from zope.interface import implements
from zope.event import notify
from ActionProviderBase import ActionProviderBase
from interfaces import IConfigurableWorkflowTool
+from interfaces import ITypesTool
from interfaces import IWorkflowDefinition
from interfaces import IWorkflowTool
from interfaces.portal_workflow import portal_workflow as z2IWorkflowTool
from permissions import ManagePortal
from utils import _dtmldir
-from utils import getToolByName
from utils import Message as _
+from utils import registerToolInterface
from utils import UniqueObject
from WorkflowCore import ObjectDeleted
from WorkflowCore import ObjectMoved
@@ -467,7 +470,7 @@
def getDefaultChainFor(self, ob):
""" Get the default chain, if applicable, for ob.
"""
- types_tool = getToolByName( self, 'portal_types', None )
+ types_tool = queryUtility(ITypesTool)
if ( types_tool is not None
and types_tool.getTypeInfo( ob ) is not None ):
return self._default_chain
@@ -507,7 +510,7 @@
""" List the portal types which are available.
"""
- pt = getToolByName(self, 'portal_types', None)
+ pt = queryUtility(ITypesTool)
if pt is None:
return ()
else:
@@ -614,3 +617,5 @@
ob.reindexObjectSecurity()
InitializeClass(WorkflowTool)
+registerToolInterface('portal_workflow', IWorkflowTool)
+
Modified: CMF/trunk/CMFCore/__init__.py
===================================================================
--- CMF/trunk/CMFCore/__init__.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/__init__.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -15,6 +15,14 @@
$Id$
"""
+try:
+ import five.localsitemanager
+except ImportError, e:
+ import sys
+ import os
+ sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
+ import five.localsitemanager
+
import PortalFolder
import MembershipTool, WorkflowTool, CatalogTool, DiscussionTool
import ActionsTool, UndoTool, RegistrationTool, SkinsTool
@@ -69,7 +77,6 @@
)
def initialize(context):
-
context.registerClass(
DirectoryView.DirectoryView,
constructors=(('manage_addDirectoryViewForm',
Modified: CMF/trunk/CMFCore/browser/actions.py
===================================================================
--- CMF/trunk/CMFCore/browser/actions.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/browser/actions.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFCore/browser/typeinfo.py
===================================================================
--- CMF/trunk/CMFCore/browser/typeinfo.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/browser/typeinfo.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFCore/configure.zcml
===================================================================
--- CMF/trunk/CMFCore/configure.zcml 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/configure.zcml 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,6 +1,8 @@
<configure
xmlns="http://namespaces.zope.org/zope">
+ <include package="five.localsitemanager" />
+
<include package=".browser"/>
<include package=".exportimport"/>
Modified: CMF/trunk/CMFCore/exportimport/actions.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/actions.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/actions.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -15,8 +15,6 @@
$Id$
"""
-from zope.component import adapts
-
from Products.GenericSetup.interfaces import ISetupEnviron
from Products.GenericSetup.utils import exportObjects
from Products.GenericSetup.utils import I18NURI
@@ -32,8 +30,13 @@
from Products.CMFCore.interfaces import IActionsTool
from Products.CMFCore.interfaces.portal_actions \
import ActionProvider as z2IActionProvider
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolInterface
+from zope.component import adapts
+from zope.component import getUtility
+from zope.component import getSiteManager
+from zope.component import queryUtility
+
_SPECIAL_PROVIDERS = ('portal_actions', 'portal_types', 'portal_workflow')
@@ -145,8 +148,9 @@
def _extractOldstyleActions(self, provider_id):
# BBB: for CMF 1.6 profiles
fragment = self._doc.createDocumentFragment()
+ provider_iface = getToolInterface(provider_id)
+ provider = getUtility(provider_iface)
- provider = getToolByName(self.context, provider_id)
if not (IActionProvider.providedBy(provider) or
z2IActionProvider.isImplementedBy(provider)):
return fragment
@@ -246,16 +250,16 @@
def importActionProviders(context):
"""Import actions tool.
"""
- site = context.getSite()
- tool = getToolByName(site, 'portal_actions')
+ sm = getSiteManager(context.getSite())
+ tool = sm.getUtility(IActionsTool)
importObjects(tool, '', context)
def exportActionProviders(context):
"""Export actions tool.
"""
- site = context.getSite()
- tool = getToolByName(site, 'portal_actions', None)
+ sm = getSiteManager(context.getSite())
+ tool = sm.queryUtility(IActionsTool)
if tool is None:
logger = context.getLogger('actions')
logger.info('Nothing to export.')
Modified: CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -16,7 +16,10 @@
"""
from zope.component import adapts
+from zope.component import getUtility
+from zope.component import getSiteManager
from zope.component import queryMultiAdapter
+from zope.component import queryUtility
from Products.GenericSetup.interfaces import INode
from Products.GenericSetup.interfaces import ISetupEnviron
@@ -27,7 +30,6 @@
from Products.CMFCore.interfaces import ICachingPolicy
from Products.CMFCore.interfaces import ICachingPolicyManager
-from Products.CMFCore.utils import getToolByName
class CachingPolicyNodeAdapter(NodeAdapterBase):
@@ -172,16 +174,16 @@
def importCachingPolicyManager(context):
"""Import caching policy manager settings from an XML file.
"""
- site = context.getSite()
- tool = getToolByName(site, 'caching_policy_manager')
+ sm = getSiteManager(context.getSite())
+ tool = sm.getUtility(ICachingPolicyManager)
importObjects(tool, '', context)
def exportCachingPolicyManager(context):
"""Export caching policy manager settings as an XML file.
"""
- site = context.getSite()
- tool = getToolByName(site, 'caching_policy_manager', None)
+ sm = getSiteManager(context.getSite())
+ tool = sm.queryUtility(ICachingPolicyManager)
if tool is None:
logger = context.getLogger('cachingpolicies')
logger.info('Nothing to export.')
Modified: CMF/trunk/CMFCore/exportimport/catalog.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/catalog.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/catalog.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFCore/exportimport/content.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/content.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/content.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -21,14 +21,14 @@
from ConfigParser import ConfigParser
from StringIO import StringIO
+from zope.component import getUtility
from zope.interface import implements
from zope.interface import directlyProvides
from Products.GenericSetup.interfaces import IFilesystemExporter
from Products.GenericSetup.interfaces import IFilesystemImporter
from Products.GenericSetup.content import _globtest
-from Products.CMFCore.utils import getToolByName
-
+from Products.CMFCore.interfaces import ITypesTool
#
# setup_tool handlers
#
@@ -181,7 +181,7 @@
context = self.context
properties = import_context.readDataFile('.properties',
'%s/%s' % (subdir, id))
- tool = getToolByName(context, 'portal_types')
+ tool = getUtility(ITypesTool)
try:
tool.constructContent(portal_type, context, id)
Modified: CMF/trunk/CMFCore/exportimport/contenttyperegistry.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/contenttyperegistry.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/contenttyperegistry.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -16,14 +16,17 @@
"""
from zope.component import adapts
+from zope.component import getSiteManager
+from zope.component import getUtility
+from zope.component import queryUtility
+from Products.CMFCore.interfaces import IContentTypeRegistry
from Products.GenericSetup.interfaces import ISetupEnviron
from Products.GenericSetup.utils import exportObjects
from Products.GenericSetup.utils import importObjects
from Products.GenericSetup.utils import XMLAdapterBase
from Products.CMFCore.interfaces import IContentTypeRegistry
-from Products.CMFCore.utils import getToolByName
class ContentTypeRegistryXMLAdapter(XMLAdapterBase):
@@ -111,16 +114,16 @@
def importContentTypeRegistry(context):
"""Import content type registry settings from an XML file.
"""
- site = context.getSite()
- tool = getToolByName(site, 'content_type_registry')
+ sm = getSiteManager(context.getSite())
+ tool = sm.getUtility(IContentTypeRegistry)
importObjects(tool, '', context)
def exportContentTypeRegistry(context):
"""Export content type registry settings as an XML file.
"""
- site = context.getSite()
- tool = getToolByName(site, 'content_type_registry', None)
+ sm = getSiteManager(context.getSite())
+ tool = sm.queryUtility(IContentTypeRegistry)
if tool is None:
logger = context.getLogger('contenttypes')
logger.info('Nothing to export.')
Modified: CMF/trunk/CMFCore/exportimport/cookieauth.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/cookieauth.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/cookieauth.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -16,6 +16,9 @@
"""
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
@@ -24,7 +27,6 @@
from Products.GenericSetup.utils import XMLAdapterBase
from Products.CMFCore.interfaces import ICookieCrumbler
-from Products.CMFCore.utils import getToolByName
class CookieCrumblerXMLAdapter(XMLAdapterBase, PropertyManagerHelpers):
@@ -61,16 +63,16 @@
def importCookieCrumbler(context):
"""Import cookie crumbler settings from an XML file.
"""
- site = context.getSite()
- tool = getToolByName(site, 'cookie_authentication')
+ sm = getSiteManager(context.getSite())
+ tool = sm.getUtility(ICookieCrumbler)
importObjects(tool, '', context)
def exportCookieCrumbler(context):
"""Export cookie crumbler settings as an XML file.
"""
- site = context.getSite()
- tool = getToolByName(site, 'cookie_authentication', None)
+ sm = getSiteManager(context.getSite())
+ tool = queryUtility(ICookieCrumbler)
if tool is None:
logger = context.getLogger('cookies')
logger.info('Nothing to export.')
Modified: CMF/trunk/CMFCore/exportimport/mailhost.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/mailhost.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/mailhost.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFCore/exportimport/skins.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/skins.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/skins.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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):
@@ -206,16 +209,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/trunk/CMFCore/exportimport/tests/test_actions.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_actions.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/tests/test_actions.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -20,15 +20,18 @@
from Acquisition import Implicit
from Acquisition import aq_parent
-from OFS.Folder import Folder
from OFS.OrderedFolder import OrderedFolder
+
+from zope.component import getSiteManager
from zope.interface import implements
+from zope.interface import Interface
from Products.CMFCore.ActionProviderBase import ActionProviderBase
from Products.CMFCore.interfaces import IActionsTool
from Products.CMFCore.interfaces.portal_actions \
import ActionProvider as IActionProvider
from Products.CMFCore.tests.base.dummy import DummySite
+from Products.CMFCore.utils import registerToolInterface
from Products.GenericSetup.testing import BodyAdapterTestCase
from Products.GenericSetup.testing import NodeAdapterTestCase
from Products.GenericSetup.tests.common import BaseRegistryTests
@@ -199,7 +202,15 @@
</object>
"""
+class IFoo(Interface):
+ """ Foo interface """
+registerToolInterface('portal_foo', IFoo)
+class IBar(Interface):
+ """ Bar interface """
+registerToolInterface('portal_bar', IBar)
+
+
class DummyTool(OrderedFolder, ActionProviderBase):
__implements__ = IActionProvider
@@ -330,6 +341,7 @@
self.assertEqual(obj.action_providers[0], 'portal_actions')
def setUp(self):
+ from Products.CMFCore.interfaces import IActionsTool
from Products.CMFCore.ActionsTool import ActionsTool
BodyAdapterTestCase.setUp(self)
@@ -338,19 +350,29 @@
self._obj = site.portal_actions
self._BODY = _ACTIONSTOOL_BODY
+ # utility registration
+ sm = getSiteManager()
+ sm.registerUtility(self._obj, IActionsTool)
+
class _ActionSetup(BaseRegistryTests):
def _initSite(self, foo=2, bar=2):
- self.root.site = Folder(id='site')
+ from zope.component import getSiteManager
+
+ self.root.site = DummySite('site')
site = self.root.site
site.portal_membership = DummyMembershipTool()
site.portal_actions = DummyActionsTool()
site.portal_actions.addActionProvider('portal_actions')
+ sm = getSiteManager(site)
+ sm.registerUtility(site.portal_actions, IActionsTool)
+
if foo > 0:
site.portal_foo = DummyTool()
+ sm.registerUtility(site.portal_foo, IFoo)
if foo > 1:
site.portal_foo.addAction(id='foo',
@@ -364,6 +386,7 @@
if bar > 0:
site.portal_bar = DummyTool()
+ sm.registerUtility(site.portal_bar, IBar)
if bar > 1:
site.portal_bar.addAction(id='bar',
Modified: CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -26,8 +26,11 @@
from Products.GenericSetup.tests.common import DummyExportContext
from Products.GenericSetup.tests.common import DummyImportContext
+from Products.CMFCore.interfaces import ICachingPolicyManager
from Products.CMFCore.testing import ExportImportZCMLLayer
+from zope.component import getSiteManager
+
_CP_XML = """\
<caching-policy name="foo_policy" enable_304s="False" etag_func=""
last_modified="True" max_age_secs="0" mtime_func="object/modified"
@@ -128,6 +131,9 @@
mgr = CachingPolicyManager()
site._setObject( mgr.getId(), mgr )
+ sm = getSiteManager(site)
+ sm.registerUtility(site.caching_policy_manager, ICachingPolicyManager)
+
if with_policy:
mgr.addPolicy( policy_id=self.POLICY_ID
, predicate=self.PREDICATE
Modified: CMF/trunk/CMFCore/exportimport/tests/test_catalog.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_catalog.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/tests/test_catalog.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFCore/exportimport/tests/test_content.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_content.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/tests/test_content.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -22,8 +22,10 @@
from ConfigParser import ConfigParser
from StringIO import StringIO
+from zope.component import getSiteManager
from zope.testing.cleanup import cleanUp
+from Products.CMFCore.interfaces import ITypesTool
from Products.GenericSetup.tests.common import DummyExportContext
from Products.GenericSetup.tests.common import DummyImportContext
@@ -750,7 +752,9 @@
folder = PortalFolder(id)
folder.portal_type = TEST_FOLDER
if site_folder:
+ sm = getSiteManager()
tool = folder.portal_types = TypesTool()
+ sm.registerUtility(tool, ITypesTool)
tool._setObject(TEST_CSV_AWARE, _TypeInfo(TEST_CSV_AWARE))
tool._setObject(TEST_INI_AWARE, _TypeInfo(TEST_INI_AWARE))
tool._setObject(TEST_CONTENT, _TypeInfo(TEST_CONTENT))
Modified: CMF/trunk/CMFCore/exportimport/tests/test_contenttyperegistry.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_contenttyperegistry.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/tests/test_contenttyperegistry.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -20,6 +20,9 @@
from OFS.Folder import Folder
+from zope.component import getSiteManager
+
+from Products.CMFCore.interfaces import IContentTypeRegistry
from Products.GenericSetup.testing import BodyAdapterTestCase
from Products.GenericSetup.tests.common import BaseRegistryTests
from Products.GenericSetup.tests.common import DummyExportContext
@@ -155,6 +158,9 @@
ctr = ContentTypeRegistry()
site._setObject( ctr.getId(), ctr )
+ sm = getSiteManager(site)
+ sm.registerUtility(site.content_type_registry, IContentTypeRegistry)
+
if mit_predikat:
for (predicate_id, predicate_type, edit_args, content_type_name
) in _TEST_PREDICATES:
Modified: CMF/trunk/CMFCore/exportimport/tests/test_cookieauth.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_cookieauth.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/tests/test_cookieauth.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -20,12 +20,15 @@
from OFS.Folder import Folder
+from zope.component import getSiteManager
+
from Products.GenericSetup.testing import BodyAdapterTestCase
from Products.GenericSetup.tests.common import BaseRegistryTests
from Products.GenericSetup.tests.common import DummyExportContext
from Products.GenericSetup.tests.common import DummyImportContext
from Products.CMFCore.CookieCrumbler import CookieCrumbler
+from Products.CMFCore.interfaces import ICookieCrumbler
from Products.CMFCore.testing import ExportImportZCMLLayer
_COOKIECRUMBLER_BODY = """\
@@ -101,6 +104,9 @@
self.root.site = Folder(id='site')
site = self.root.site
cc = site.cookie_authentication = CookieCrumbler('foo_cookiecrumbler')
+
+ sm = getSiteManager()
+ sm.registerUtility(site.cookie_authentication, ICookieCrumbler)
if use_changed:
cc.auth_cookie = 'value1'
Modified: CMF/trunk/CMFCore/exportimport/tests/test_mailhost.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_mailhost.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/tests/test_mailhost.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFCore/exportimport/tests/test_skins.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_skins.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/tests/test_skins.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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
@@ -269,6 +271,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/trunk/CMFCore/exportimport/tests/test_typeinfo.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/tests/test_typeinfo.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -20,11 +20,14 @@
from OFS.Folder import Folder
+from zope.component import getSiteManager
+
from Products.GenericSetup.testing import BodyAdapterTestCase
from Products.GenericSetup.tests.common import BaseRegistryTests
from Products.GenericSetup.tests.common import DummyExportContext
from Products.GenericSetup.tests.common import DummyImportContext
+from Products.CMFCore.interfaces import ITypesTool
from Products.CMFCore.permissions import View
from Products.CMFCore.permissions import AccessContentsInformation
from Products.CMFCore.permissions import ModifyPortalContent
@@ -325,6 +328,9 @@
site = self.root.site
ttool = site.portal_types = TypesTool()
+ sm = getSiteManager()
+ sm.registerUtility(ttool, ITypesTool)
+
if foo == 1:
fti = _TI_LIST[0].copy()
ttool._setObject(fti['id'], FactoryTypeInformation(**fti))
Modified: CMF/trunk/CMFCore/exportimport/tests/test_workflow.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_workflow.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/tests/test_workflow.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -19,6 +19,8 @@
import Testing
from OFS.Folder import Folder
+
+from zope.component import getSiteManager
from zope.interface import implements
from Products.GenericSetup.testing import BodyAdapterTestCase
@@ -163,6 +165,10 @@
self.root.site = Folder(id='site')
site = self.root.site
self.root.site.portal_workflow = DummyWorkflowTool()
+ sm = getSiteManager()
+ sm.registerUtility( self.root.site.portal_workflow
+ , IConfigurableWorkflowTool
+ )
return site
Modified: CMF/trunk/CMFCore/exportimport/typeinfo.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/typeinfo.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/typeinfo.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -16,6 +16,7 @@
"""
from zope.component import adapts
+from zope.component import getSiteManager
from Products.GenericSetup.interfaces import ISetupEnviron
from Products.GenericSetup.utils import exportObjects
@@ -27,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):
@@ -177,16 +177,16 @@
def importTypesTool(context):
"""Import types tool and content types from XML files.
"""
- site = context.getSite()
- tool = getToolByName(site, 'portal_types')
+ sm = getSiteManager(context.getSite())
+ tool = sm.getUtility(ITypesTool)
importObjects(tool, '', context)
def exportTypesTool(context):
"""Export types tool content types as a set of XML files.
"""
- site = context.getSite()
- tool = getToolByName(site, 'portal_types', None)
+ sm = getSiteManager(context.getSite())
+ tool = sm.queryUtility(ITypesTool)
if tool is None:
logger = context.getLogger('types')
logger.info('Nothing to export.')
Modified: CMF/trunk/CMFCore/exportimport/workflow.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/workflow.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/exportimport/workflow.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -16,6 +16,7 @@
"""
from zope.component import adapts
+from zope.component import getSiteManager
from Products.GenericSetup.interfaces import ISetupEnviron
from Products.GenericSetup.utils import exportObjects
@@ -25,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,
@@ -120,16 +120,16 @@
def importWorkflowTool(context):
"""Import workflow tool and contained workflow definitions from XML files.
"""
- site = context.getSite()
- tool = getToolByName(site, 'portal_workflow')
+ sm = getSiteManager(context.getSite())
+ tool = sm.getUtility(IConfigurableWorkflowTool)
importObjects(tool, '', context)
def exportWorkflowTool(context):
"""Export workflow tool and contained workflow definitions as XML files.
"""
- site = context.getSite()
- tool = getToolByName(site, 'portal_workflow', None)
+ sm = getSiteManager(context.getSite())
+ tool = sm.queryUtility(IConfigurableWorkflowTool)
if tool is None:
logger = context.getLogger('workflow')
logger.info('Nothing to export.')
Modified: CMF/trunk/CMFCore/interfaces/_tools.py
===================================================================
--- CMF/trunk/CMFCore/interfaces/_tools.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/interfaces/_tools.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1243,7 +1243,103 @@
o Permission: Public
"""
+#
+# Syndication tool interface
+#
+class ISyndicationTool(Interface):
+ """ An object that provides content syndication facilities
+ """
+
+ id = Attribute('id',
+ """ The ID of the tool.
+
+ o BBB: for use in 'getToolByName'; in the future, prefer
+ 'zapi.getUtility(ISyndicationTool)'.
+
+ o Must be set to "portal_syndication"
+ """,
+ )
+
+ def enableSyndication(obj):
+ """ Enable syndication for the passed-in object
+
+ o raises 'Syndication is Disabled' if syndication is now allowed
+
+ o raises 'Syndication Information Exists' if used repeatedly
+ """
+
+ def disableSyndication(obj):
+ """ Disable syndication for the passed-in object
+
+ o raises 'This object does not have Syndication Information' if
+ syndication has already been disabled
+ """
+
+ def getSyndicatableContent(obj):
+ """ Retrieve all syndicatable content from the passed-in object
+
+ o will call the hool "synContentValues" if it exists to allow
+ individual customization
+
+ o falls back to calling contentValues
+ """
+
+ def isSiteSyndicationAllowed():
+ """ Return the site-wide syndication flag
+ """
+
+ def isSyndicationAllowed(obj=None):
+ """ Return the syndication flag for the passed-in object
+
+ o falls back to retrieving the site-wide syndication flag
+ """
+
+ def getUpdatePeriod(obj=None):
+ """ Return the update period for the syndicated feed
+
+ o falls back to the site-wide value if no object is passed in
+
+ o raises 'Syndication is not Allowed' if the site-wide policy
+ does not allow syndication
+ """
+
+ def getUpdateFrequency(obj=None):
+ """ Return the syndicated feed update frequency
+
+ o falls back to the site-wide value if no object is passed in
+
+ o raises 'Syndication is not Allowed' if the site-wide policy
+ does not allow syndication
+ """
+
+ def getUpdateBase(obj=None):
+ """ Return the syndication feed base date for the publishing schedule
+
+ o falls back to the site-wide value if no object is passed in
+
+ o raises 'Syndication is not Allowed' if the site-wide policy
+ does not allow syndication
+ """
+
+ def getHTML4UpdateBase(obj=None):
+ """ return the HTML-formatted feed publishing base date
+
+ o falls back to the site-wide value if no object is passed in
+
+ o raises 'Syndication is not Allowed' if the site-wide policy
+ does not allow syndication
+ """
+
+ def getMaxItems(obj=None):
+ """ Return the number of items published at any one time in the feed
+
+ o falls back to the site-wide value if no object is passed in
+
+ o raises 'Syndication is not Allowed' if the site-wide policy
+ does not allow syndication
+ """
+
#
# Types tool interfaces
#
Copied: CMF/trunk/CMFCore/overrides.zcml (from rev 73020, CMF/branches/jens_tools_as_utilities/CMFCore/overrides.zcml)
Copied: CMF/trunk/CMFCore/src (from rev 73020, CMF/branches/jens_tools_as_utilities/CMFCore/src)
Modified: CMF/trunk/CMFCore/testing.py
===================================================================
--- CMF/trunk/CMFCore/testing.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/testing.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -17,6 +17,7 @@
from OFS.SimpleItem import SimpleItem
from Products.Five import zcml
+from zope.app.component.hooks import setHooks
from zope.component import adapts
from zope.i18n.interfaces import IUserPreferredLanguages
from zope.interface import implements
@@ -108,32 +109,51 @@
class EventZCMLLayer:
@classmethod
- def setUp(cls):
+ def testSetUp(cls):
import Products
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):
+ def testTearDown(cls):
cleanUp()
class TraversingZCMLLayer:
@classmethod
- def setUp(cls):
+ def testSetUp(cls):
import Products.Five
zcml.load_config('meta.zcml', Products.Five)
zcml.load_config('traversing.zcml', Products.Five)
+ setHooks()
@classmethod
- def tearDown(cls):
+ def testTearDown(cls):
cleanUp()
+class TraversingEventZCMLLayer:
+
+ @classmethod
+ def testSetUp(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 testTearDown(cls):
+ cleanUp()
+
+
class FunctionalZCMLLayer:
@classmethod
@@ -141,6 +161,7 @@
import Products
zcml.load_config('testing.zcml', Products.CMFCore)
+ setHooks()
@classmethod
def tearDown(cls):
@@ -191,7 +212,7 @@
class ExportImportZCMLLayer:
@classmethod
- def setUp(cls):
+ def testSetUp(cls):
import Products.Five
import Products.GenericSetup
import Products.CMFCore
@@ -203,9 +224,10 @@
zcml.load_config('tool.zcml', Products.CMFCore)
zcml.load_config('configure.zcml', Products.CMFCore.exportimport)
zcml.load_string(_DUMMY_ZCML)
+ setHooks()
@classmethod
- def tearDown(cls):
+ def testTearDown(cls):
cleanUp()
Modified: CMF/trunk/CMFCore/tests/base/dummy.py
===================================================================
--- CMF/trunk/CMFCore/tests/base/dummy.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/base/dummy.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -29,6 +29,7 @@
from zope.interface import implements
from Products.CMFCore.interfaces import IContentish
+from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.ActionProviderBase import ActionProviderBase
from Products.CMFCore.PortalContent import PortalContent
@@ -269,6 +270,7 @@
_domain = 'http://www.foobar.com'
_path = 'bar'
_isPortalRoot = 1
+ implements(ISiteRoot)
def absolute_url(self, relative=0):
return '/'.join( (self._domain, self._path, self._id) )
@@ -291,7 +293,10 @@
def userdefined_roles(self):
return ('Member', 'Reviewer')
+ def getProperty(self, id, default=None):
+ return getattr(self, id, default)
+
class DummyUser(Implicit):
""" A dummy User.
"""
@@ -401,7 +406,10 @@
def notifyCreated(self, ob):
self.test_notified = ob
+ def getCatalogVariablesFor(self, obj):
+ return {}
+
class DummyCachingManager:
def getHTTPCachingHeaders( self, content, view_name, keywords, time=None ):
Modified: CMF/trunk/CMFCore/tests/test_ActionInformation.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_ActionInformation.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_ActionInformation.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -21,8 +21,11 @@
from OFS.Folder import manage_addFolder
from Products.PythonScripts.PythonScript import manage_addPythonScript
+from zope.component import getSiteManager
+
from Products.CMFCore.Expression import createExprContext
from Products.CMFCore.Expression import Expression
+from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.testing import FunctionalZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFCore.tests.base.dummy import DummySite
@@ -216,7 +219,9 @@
def setUp(self):
SecurityTest.setUp(self)
self.site = DummySite('site').__of__(self.root)
+ sm = getSiteManager()
self.site._setObject( 'portal_membership', DummyMembershipTool() )
+ sm.registerUtility(self.site.portal_membership, IMembershipTool)
def _makeOne(self, *args, **kw):
from Products.CMFCore.ActionInformation import ActionInfo
@@ -330,7 +335,9 @@
root = self.root
root._setObject('portal', DummyContent('portal', 'url_portal'))
portal = self.portal = root.portal
+ sm = getSiteManager(portal)
portal.portal_membership = DummyMembershipTool()
+ sm.registerUtility(portal.portal_membership, IMembershipTool)
self.folder = DummyContent('foo', 'url_foo')
self.object = DummyContent('bar', 'url_bar')
Modified: CMF/trunk/CMFCore/tests/test_ActionProviderBase.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_ActionProviderBase.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_ActionProviderBase.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,6 +18,10 @@
import unittest
import Testing
+from zope.component import getSiteManager
+
+from Products.CMFCore.interfaces import IMembershipTool
+from Products.CMFCore.interfaces import IURLTool
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
from Products.CMFCore.tests.base.testcase import SecurityRequestTest
@@ -62,8 +66,11 @@
def setUp( self ):
SecurityRequestTest.setUp(self)
self.site = DummySite('site').__of__(self.root)
+ sm = getSiteManager()
utool = self.site._setObject( 'portal_url', DummyTool() )
+ sm.registerUtility(self.site.portal_url, IURLTool)
mtool = self.site._setObject( 'portal_membership', DummyTool() )
+ sm.registerUtility(self.site.portal_membership, IMembershipTool)
def _makeProvider( self, dummy=0 ):
Modified: CMF/trunk/CMFCore/tests/test_ActionsTool.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_ActionsTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_ActionsTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,13 +18,19 @@
import unittest
import Testing
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+
from Products.CMFCore.ActionInformation import Action
from Products.CMFCore.ActionInformation import ActionCategory
from Products.CMFCore.ActionInformation import ActionInformation
from Products.CMFCore.Expression import Expression
from Products.CMFCore.MembershipTool import MembershipTool
+from Products.CMFCore.interfaces import IURLTool
from Products.CMFCore.tests.base.testcase import SecurityRequestTest
from Products.CMFCore.URLTool import URLTool
+from Products.CMFCore.interfaces import IMembershipTool
+from Products.CMFCore.interfaces import ISiteRoot
class ActionsToolTests(unittest.TestCase):
@@ -107,10 +113,14 @@
SecurityRequestTest.setUp(self)
root = self.root
+ sm = getSiteManager()
+ sm.registerUtility(root, ISiteRoot)
root._setObject( 'portal_actions', self._makeOne() )
root._setObject( 'portal_url', URLTool() )
+ sm.registerUtility(root.portal_url, IURLTool)
root._setObject( 'foo', URLTool() )
root._setObject('portal_membership', MembershipTool())
+ sm.registerUtility(root.portal_membership, IMembershipTool)
self.tool = root.portal_actions
self.tool.action_providers = ('portal_actions',)
@@ -145,7 +155,11 @@
'category': 'folder'}],
'global': []})
+ def tearDown(self):
+ cleanUp()
+ SecurityRequestTest.tearDown(self)
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(ActionsToolTests),
Modified: CMF/trunk/CMFCore/tests/test_CMFCatalogAware.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_CMFCatalogAware.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_CMFCatalogAware.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -22,12 +22,17 @@
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 IConfigurableWorkflowTool
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,12 +120,17 @@
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())
+ sm.registerUtility(self.site.portal_workflow, IConfigurableWorkflowTool)
self.site.foo = TheClass('foo')
def tearDown(self):
@@ -219,8 +229,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/trunk/CMFCore/tests/test_CachingPolicyManager.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_CachingPolicyManager.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_CachingPolicyManager.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -28,8 +28,12 @@
from DateTime.DateTime import DateTime
from OFS.Cache import Cacheable
+from zope.app.component.hooks import setHooks
+from zope.component import getSiteManager
+
from Products.CMFCore.FSPageTemplate import FSPageTemplate
from Products.CMFCore.FSDTMLMethod import FSDTMLMethod
+from Products.CMFCore.interfaces import ITypesTool
from Products.CMFCore.testing import FunctionalZCMLLayer
from Products.CMFCore.testing import TraversingZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyContent
@@ -38,6 +42,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 import ICachingPolicyManager
ACCLARK = DateTime( '2001/01/01' )
portal_owner = 'portal_owner'
@@ -652,8 +657,10 @@
now = DateTime()
# Create a fake portal and the tools we need
+ sm = getSiteManager()
self.portal = DummySite(id='portal').__of__(self.root)
self.portal._setObject('portal_types', DummyTool())
+ sm.registerUtility(self.portal.portal_types, ITypesTool)
# This is a FSPageTemplate that will be used as the View for
# our content objects. It doesn't matter what it returns.
@@ -680,6 +687,9 @@
CachingPolicyManager.manage_addCachingPolicyManager(self.portal)
cpm = self.portal.caching_policy_manager
+ sm = getSiteManager(self.portal)
+ sm.registerUtility(cpm, ICachingPolicyManager)
+
# This policy only applies to doc1. It will not emit any ETag header
# but it enables If-modified-since handling.
cpm.addPolicy(policy_id = 'policy_no_etag',
@@ -903,6 +913,11 @@
from Products.CMFCore import CachingPolicyManager
CachingPolicyManager.manage_addCachingPolicyManager(self.portal)
+ sm = getSiteManager(self.portal)
+ sm.registerUtility( self.portal.caching_policy_manager
+ , ICachingPolicyManager
+ )
+
def tearDown(self):
RequestTest.tearDown(self)
FSObjMaker.tearDown(self)
@@ -1223,6 +1238,9 @@
CachingPolicyManager.manage_addCachingPolicyManager(self.portal)
cpm = self.portal.caching_policy_manager
+ sm = getSiteManager(self.portal)
+ sm.registerUtility(cpm, ICachingPolicyManager)
+
# This policy only applies to doc1. It will not emit any ETag header
# but it enables If-modified-since handling.
cpm.addPolicy(policy_id = 'policy_1',
Modified: CMF/trunk/CMFCore/tests/test_DynamicType.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_DynamicType.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_DynamicType.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -24,7 +24,12 @@
from ZPublisher.HTTPRequest import HTTPRequest
from ZPublisher.HTTPResponse import HTTPResponse
+from zope.component import getSiteManager
+
from Products.CMFCore.DynamicType import DynamicType
+from Products.CMFCore.interfaces import IMembershipTool
+from Products.CMFCore.interfaces import ITypesTool
+from Products.CMFCore.interfaces import IURLTool
from Products.CMFCore.tests.base.dummy import DummyObject
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
@@ -58,6 +63,15 @@
class DynamicTypeTests(unittest.TestCase):
+ def setUp(self):
+ sm = getSiteManager()
+ self.site = DummySite('site')
+ self.site._setObject( 'portal_types', TypesTool() )
+ sm.registerUtility(self.site.portal_types, ITypesTool)
+ fti = FTIDATA_CMF15[0].copy()
+ self.site.portal_types._setObject( 'Dummy Content 15', FTI(**fti) )
+ self.site._setObject( 'foo', DummyContent() )
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from Products.CMFCore.interfaces.Dynamic \
@@ -152,9 +166,13 @@
def setUp(self):
SecurityRequestTest.setUp(self)
self.site = DummySite('site').__of__(self.root)
+ sm = getSiteManager()
self.site._setObject( 'portal_membership', DummyTool() )
+ sm.registerUtility(self.site.portal_membership, IMembershipTool)
self.site._setObject( 'portal_types', TypesTool() )
+ sm.registerUtility(self.site.portal_types, ITypesTool)
self.site._setObject( 'portal_url', DummyTool() )
+ sm.registerUtility(self.site.portal_url, IURLTool)
fti = FTIDATA_CMF15[0].copy()
self.site.portal_types._setObject( 'Dummy Content 15', FTI(**fti) )
self.site._setObject( 'foo', DummyContent() )
Modified: CMF/trunk/CMFCore/tests/test_Expression.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_Expression.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_Expression.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,9 +18,12 @@
import unittest
import Testing
+from zope.component import getSiteManager
+
from Products.CMFCore.ActionInformation import ActionInformation
from Products.CMFCore.Expression import createExprContext
from Products.CMFCore.Expression import Expression
+from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFCore.tests.base.dummy import DummyTool as DummyMembershipTool
from Products.CMFCore.tests.base.testcase import SecurityTest
@@ -46,19 +49,25 @@
, visible=1)
def test_anonymous_ec(self):
+ sm = getSiteManager()
self.portal.portal_membership = DummyMembershipTool()
+ sm.registerUtility(self.portal.portal_membership, IMembershipTool)
ec = createExprContext(self.folder, self.portal, self.object)
member = ec.contexts['member']
self.failIf(member)
def test_authenticatedUser_ec(self):
+ sm = getSiteManager()
self.portal.portal_membership = DummyMembershipTool(anon=0)
+ sm.registerUtility(self.portal.portal_membership, IMembershipTool)
ec = createExprContext(self.folder, self.portal, self.object)
member = ec.contexts['member']
self.assertEqual(member.getId(), 'dummy')
def test_ec_context(self):
+ sm = getSiteManager()
self.portal.portal_membership = DummyMembershipTool()
+ sm.registerUtility(self.portal.portal_membership, IMembershipTool)
ec = createExprContext(self.folder, self.portal, self.object)
object = ec.contexts['object']
portal = ec.contexts['portal']
Modified: CMF/trunk/CMFCore/tests/test_FSDTMLMethod.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSDTMLMethod.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_FSDTMLMethod.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -26,6 +26,8 @@
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
@@ -33,7 +35,10 @@
from Products.CMFCore.tests.base.testcase import SecurityTest
from Products.CMFCore.tests.base.dummy import DummyContent
+from zope.app.component.hooks import setHooks
+from zope.component import getSiteManager
+
class FSDTMLMaker(FSDVTest):
def _makeOne( self, id, filename ):
@@ -48,11 +53,19 @@
def setUp(self):
FSDTMLMaker.setUp(self)
RequestTest.setUp(self)
+ setHooks()
def tearDown(self):
RequestTest.tearDown(self)
FSDTMLMaker.tearDown(self)
+ def _setupCachingPolicyManager(self, cpm_object):
+ self.root.caching_policy_manager = cpm_object
+ sm = getSiteManager(self.root)
+ sm.registerUtility( self.root.caching_policy_manager
+ , ICachingPolicyManager
+ )
+
def test_Call( self ):
script = self._makeOne( 'testDTML', 'testDTML.dtml' )
script = script.__of__(self.app)
@@ -60,7 +73,7 @@
def test_caching( self ):
# Test HTTP caching headers.
- self.root.caching_policy_manager = DummyCachingManager()
+ self._setupCachingPolicyManager(DummyCachingManager())
original_len = len( self.RESPONSE.headers )
script = self._makeOne('testDTML', 'testDTML.dtml')
script = script.__of__(self.root)
@@ -87,7 +100,7 @@
from webdav.common import rfc1123_date
mod_time = DateTime()
- self.root.caching_policy_manager = DummyCachingManagerWithPolicy()
+ self._setupCachingPolicyManager(DummyCachingManagerWithPolicy())
content = DummyContent(id='content')
content.modified_date = mod_time
content = content.__of__(self.root)
@@ -108,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/trunk/CMFCore/tests/test_FSPageTemplate.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSPageTemplate.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_FSPageTemplate.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -24,10 +24,15 @@
from OFS.Folder import Folder
from Products.StandardCacheManagers import RAMCacheManager
+
+from zope.component import getSiteManager
from zope.tales.tales import Undefined
+from zope.testing.cleanup import cleanUp
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
@@ -56,6 +61,13 @@
RequestTest.tearDown(self)
FSPTMaker.tearDown(self)
+ def _setupCachingPolicyManager(self, cpm_object):
+ self.root.caching_policy_manager = cpm_object
+ sm = getSiteManager()
+ sm.registerUtility( self.root.caching_policy_manager
+ , ICachingPolicyManager
+ )
+
def test_Call( self ):
script = self._makeOne( 'testPT', 'testPT.pt' )
script = script.__of__(self.app)
@@ -123,7 +135,7 @@
def test_caching( self ):
# Test HTTP caching headers.
- self.root.caching_policy_manager = DummyCachingManager()
+ self._setupCachingPolicyManager(DummyCachingManager())
original_len = len( self.RESPONSE.headers )
script = self._makeOne('testPT', 'testPT.pt')
script = script.__of__(self.root)
@@ -146,14 +158,17 @@
script = script.__of__(self.root)
self.assertEqual(script(), 'foo bar spam eggs\n')
+
class FSPageTemplateCustomizationTests( SecurityTest, FSPTMaker ):
- def setUp( self ):
+ def setUp(self):
FSPTMaker.setUp(self)
- SecurityTest.setUp( self )
+ SecurityTest.setUp(self)
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
@@ -166,6 +181,11 @@
self.fsPT = self.fsdir.testPT
+ def tearDown(self):
+ cleanUp()
+ SecurityTest.tearDown(self)
+ FSPTMaker.tearDown(self)
+
def test_customize( self ):
self.fsPT.manage_doCustomize( folder_path='custom' )
@@ -197,11 +217,7 @@
customized = self.custom.testPT
self.failIf( customized.expand )
- def tearDown(self):
- SecurityTest.tearDown(self)
- FSPTMaker.tearDown(self)
-
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(FSPageTemplateTests),
Modified: CMF/trunk/CMFCore/tests/test_FSPropertiesObject.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSPropertiesObject.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_FSPropertiesObject.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFCore/tests/test_FSPythonScript.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSPythonScript.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_FSPythonScript.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFCore/tests/test_FSReSTMethod.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSReSTMethod.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_FSReSTMethod.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -15,15 +15,20 @@
$Id$
"""
import unittest
+import Testing
+
import os
import re
-from zope.component.testing import PlacelessSetup
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+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
from Products.CMFCore.tests.base.testcase import SecurityTest
-from Products.CMFCore.tests.base.utils import _setUpDefaultTraversable
class FSReSTMaker(FSDVTest):
@@ -75,22 +80,21 @@
return ' '.join(WS.split(text.rstrip()))
-class FSReSTMethodTests(RequestTest, FSReSTMaker, PlacelessSetup):
+class FSReSTMethodTests(RequestTest, FSReSTMaker):
+ layer = TraversingZCMLLayer
+
def setUp(self):
RequestTest.setUp(self)
FSReSTMaker.setUp(self)
- PlacelessSetup.setUp(self)
def tearDown(self):
- PlacelessSetup.tearDown(self)
FSReSTMaker.tearDown(self)
RequestTest.tearDown(self)
def test___call__( self ):
script = self._makeOne( 'testReST', 'testReST.rst' )
script = script.__of__(self.app)
- _setUpDefaultTraversable()
self.assertEqual(_normalize_whitespace(script(self.REQUEST)),
_normalize_whitespace(_EXPECTED_HTML))
@@ -98,10 +102,15 @@
# Test HTTP caching headers.
from Products.CMFCore.tests.base.dummy import DummyCachingManager
self.root.caching_policy_manager = DummyCachingManager()
+
+ sm = getSiteManager(self.root)
+ sm.registerUtility( self.root.caching_policy_manager
+ , ICachingPolicyManager
+ )
+
original_len = len( self.RESPONSE.headers )
script = self._makeOne('testReST', 'testReST.rst')
script = script.__of__(self.root)
- _setUpDefaultTraversable()
script(self.REQUEST, self.RESPONSE)
self.failUnless( len( self.RESPONSE.headers ) >= original_len + 2 )
self.failUnless( 'foo' in self.RESPONSE.headers.keys() )
@@ -129,6 +138,12 @@
mod_time = DateTime()
self.root.caching_policy_manager = DummyCachingManagerWithPolicy()
+
+ sm = getSiteManager(self.root)
+ sm.registerUtility( self.root.caching_policy_manager
+ , ICachingPolicyManager
+ )
+
script = self._makeOne('testReST', 'testReST.rst')
script = script.__of__(self.root)
self.REQUEST.environ[ 'IF_MODIFIED_SINCE'
@@ -138,6 +153,7 @@
self.assertEqual( data, '' )
self.assertEqual( self.RESPONSE.getStatus(), 304 )
+
ADD_ZPT = 'Add page templates'
ZPT_META_TYPES = ( { 'name' : 'Page Template'
, 'action' : 'manage_addPageTemplate'
@@ -146,19 +162,19 @@
,
)
-class FSReSTMethodCustomizationTests(SecurityTest,
- FSReSTMaker,
- PlacelessSetup,
- ):
- def setUp( self ):
+class FSReSTMethodCustomizationTests(SecurityTest, FSReSTMaker):
+
+ def setUp(self):
from OFS.Folder import Folder
- SecurityTest.setUp( self )
+
+ SecurityTest.setUp(self)
FSReSTMaker.setUp(self)
- PlacelessSetup.setUp(self)
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
@@ -171,10 +187,10 @@
self.fsReST = self.fsdir.testReST
- def tearDown( self ):
- PlacelessSetup.tearDown(self)
- FSReSTMaker.tearDown( self )
- SecurityTest.tearDown( self )
+ def tearDown(self):
+ cleanUp()
+ FSReSTMaker.tearDown(self)
+ SecurityTest.tearDown(self)
def test_customize( self ):
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
@@ -215,11 +231,7 @@
self.assertEqual(custom_pt.ZCacheable_getManagerId(), cache_id)
- def tearDown(self):
- SecurityTest.tearDown(self)
- FSReSTMaker.tearDown(self)
-
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(FSReSTMethodTests),
@@ -227,4 +239,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFCore/tests/test_FSSTXMethod.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSSTXMethod.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_FSSTXMethod.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -15,16 +15,22 @@
$Id$
"""
import unittest
+import Testing
+
import os
import re
-from zope.component.testing import PlacelessSetup
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+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
from Products.CMFCore.tests.base.testcase import SecurityTest
-from Products.CMFCore.tests.base.utils import _setUpDefaultTraversable
+
class FSSTXMaker(FSDVTest):
def _makeOne( self, id, filename ):
@@ -93,19 +99,18 @@
class FSSTXMethodTests(RequestTest,
FSSTXMaker,
_TemplateSwitcher,
- PlacelessSetup,
):
+ layer = TraversingZCMLLayer
+
def setUp(self):
_TemplateSwitcher.setUp(self)
+ RequestTest.setUp(self)
FSSTXMaker.setUp(self)
- RequestTest.setUp(self)
- PlacelessSetup.setUp(self)
def tearDown(self):
- PlacelessSetup.tearDown(self)
+ FSSTXMaker.tearDown(self)
RequestTest.tearDown(self)
- FSSTXMaker.tearDown(self)
_TemplateSwitcher.tearDown(self)
def test___call___with_DTML( self ):
@@ -119,7 +124,6 @@
self._setWhichTemplate('ZPT')
script = self._makeOne( 'testSTX', 'testSTX.stx' )
script = script.__of__(self.app)
- _setUpDefaultTraversable()
self.assertEqual(_normalize_whitespace(script(self.REQUEST)),
_normalize_whitespace(_EXPECTED_HTML))
@@ -128,6 +132,12 @@
from Products.CMFCore.tests.base.dummy import DummyCachingManager
self._setWhichTemplate('DTML')
self.root.caching_policy_manager = DummyCachingManager()
+
+ sm = getSiteManager(self.root)
+ sm.registerUtility( self.root.caching_policy_manager
+ , ICachingPolicyManager
+ )
+
original_len = len( self.RESPONSE.headers )
script = self._makeOne('testSTX', 'testSTX.stx')
script = script.__of__(self.root)
@@ -158,6 +168,12 @@
mod_time = DateTime()
self.root.caching_policy_manager = DummyCachingManagerWithPolicy()
+
+ sm = getSiteManager(self.root)
+ sm.registerUtility( self.root.caching_policy_manager
+ , ICachingPolicyManager
+ )
+
script = self._makeOne('testSTX', 'testSTX.stx')
script = script.__of__(self.root)
self.REQUEST.environ[ 'IF_MODIFIED_SINCE'
@@ -167,6 +183,7 @@
self.assertEqual( data, '' )
self.assertEqual( self.RESPONSE.getStatus(), 304 )
+
ADD_ZPT = 'Add page templates'
ZPT_META_TYPES = ( { 'name' : 'Page Template'
, 'action' : 'manage_addPageTemplate'
@@ -175,21 +192,23 @@
,
)
+
class FSSTXMethodCustomizationTests(SecurityTest,
FSSTXMaker,
_TemplateSwitcher,
- PlacelessSetup,
):
- def setUp( self ):
+ def setUp(self):
from OFS.Folder import Folder
+
+ _TemplateSwitcher.setUp(self)
+ SecurityTest.setUp(self)
FSSTXMaker.setUp(self)
- SecurityTest.setUp( self )
- _TemplateSwitcher.setUp( self )
- PlacelessSetup.setUp(self)
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
@@ -202,11 +221,11 @@
self.fsSTX = self.fsdir.testSTX
- def tearDown( self ):
- PlacelessSetup.tearDown(self)
- _TemplateSwitcher.tearDown( self )
- FSSTXMaker.tearDown( self )
- SecurityTest.tearDown( self )
+ def tearDown(self):
+ cleanUp()
+ FSSTXMaker.tearDown(self)
+ SecurityTest.tearDown(self)
+ _TemplateSwitcher.tearDown(self)
def test_customize_with_DTML( self ):
from OFS.DTMLDocument import DTMLDocument
@@ -269,11 +288,7 @@
self.assertEqual(custom_pt.ZCacheable_getManagerId(), cache_id)
- def tearDown(self):
- SecurityTest.tearDown(self)
- FSSTXMaker.tearDown(self)
-
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(FSSTXMethodTests),
@@ -281,4 +296,5 @@
))
if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
+ from Products.CMFCore.testing import run
+ run(test_suite())
Modified: CMF/trunk/CMFCore/tests/test_FSZSQLMethod.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSZSQLMethod.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_FSZSQLMethod.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFCore/tests/test_MemberDataTool.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_MemberDataTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_MemberDataTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -20,7 +20,13 @@
import Acquisition
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+from Products.CMFCore.interfaces import IMemberDataTool
+from Products.CMFCore.interfaces import IMembershipTool
+
+
class DummyUserFolder(Acquisition.Implicit):
def __init__(self):
@@ -70,6 +76,9 @@
return MemberDataTool(*args, **kw)
+ def tearDown(self):
+ cleanUp()
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from Products.CMFCore.interfaces.portal_actions \
@@ -103,8 +112,11 @@
from OFS.Folder import Folder
from Products.CMFCore.MembershipTool import MembershipTool
folder = Folder('test')
+ sm = getSiteManager()
folder._setObject('portal_memberdata', self._makeOne())
+ sm.registerUtility(folder.portal_memberdata, IMemberDataTool)
folder._setObject('portal_membership', MembershipTool())
+ sm.registerUtility(folder.portal_membership, IMembershipTool)
folder._setObject('acl_users', DummyUserFolder())
tool = folder.portal_memberdata
Modified: CMF/trunk/CMFCore/tests/test_MembershipTool.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_MembershipTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_MembershipTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -21,8 +21,13 @@
from AccessControl.SecurityManagement import newSecurityManager
from OFS.Folder import Folder
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+
from Products.CMFCore.MemberDataTool import MemberDataTool
from Products.CMFCore.PortalFolder import PortalFolder
+from Products.CMFCore.interfaces import IMemberDataTool
+from Products.CMFCore.interfaces import IURLTool
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
from Products.CMFCore.tests.base.dummy import DummyUserFolder
@@ -135,12 +140,15 @@
def test_deleteMembers(self):
site = self._makeSite()
+ sm = getSiteManager()
mtool = site.portal_membership
members = site._setObject( 'Members', PortalFolder('Members') )
acl_users = site._setObject( 'acl_users', DummyUserFolder() )
utool = site._setObject( 'portal_url', DummyTool() )
+ sm.registerUtility(utool, IURLTool)
wtool = site._setObject( 'portal_workflow', DummyTool() )
mdtool = site._setObject( 'portal_memberdata', MemberDataTool() )
+ sm.registerUtility(mdtool, IMemberDataTool)
newSecurityManager(None, acl_users.all_powerful_Oz)
self.assertEqual( acl_users.getUserById('user_foo'),
@@ -156,6 +164,8 @@
self.failIf( mdtool._members.has_key('user_foo') )
self.failIf( hasattr(members.aq_self, 'user_foo') )
+ cleanUp()
+
def test_getMemberById_nonesuch(self):
INVALID_USER_ID = 'nonesuch'
Modified: CMF/trunk/CMFCore/tests/test_OpaqueItems.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_OpaqueItems.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_OpaqueItems.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,17 +18,19 @@
import unittest
import Testing
+from zope.component import getSiteManager
from zope.interface import implements
from Products.CMFCore.interfaces import ICallableOpaqueItem
from Products.CMFCore.interfaces import ICallableOpaqueItemEvents
from Products.CMFCore.interfaces import IContentish
+from Products.CMFCore.interfaces import ITypesTool
from Products.CMFCore.interfaces.IOpaqueItems \
import ICallableOpaqueItem as z2ICallableOpaqueItem
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,15 +142,17 @@
class ManageBeforeAfterTests(SecurityTest):
- layer = EventZCMLLayer
+ layer = TraversingEventZCMLLayer
def setUp(self):
SecurityTest.setUp(self)
root = self.root
+ sm = getSiteManager()
# setting up types tool
root._setObject( 'portal_types', TypesTool() )
+ sm.registerUtility(root.portal_types, ITypesTool)
# setup portal
try:
Modified: CMF/trunk/CMFCore/tests/test_PortalContent.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_PortalContent.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_PortalContent.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -22,8 +22,12 @@
from Acquisition import aq_base
from OFS.Folder import Folder
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+
from Products.CMFCore.exceptions import NotFound
-from Products.CMFCore.testing import EventZCMLLayer
+from Products.CMFCore.interfaces import ITypesTool
+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
@@ -34,6 +38,9 @@
class PortalContentTests(unittest.TestCase):
+ def tearDown(self):
+ cleanUp()
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from Products.CMFCore.interfaces.Contentish \
@@ -55,11 +62,14 @@
verifyClass(IDynamicType, PortalContent)
def _setupCallTests(self, aliases):
+ sm = getSiteManager()
+
# root
root = Folder( 'root' )
# set up dummy type info with problematic double-default alias
root._setObject( 'portal_types', DummyTool() )
+ sm.registerUtility(root.portal_types, ITypesTool)
root.portal_types._type_actions = aliases
# dummy content and skin
@@ -95,7 +105,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/trunk/CMFCore/tests/test_PortalFolder.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_PortalFolder.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_PortalFolder.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -26,14 +26,18 @@
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 zope.interface import implements
from Products.CMFCore.CatalogTool import CatalogTool
from Products.CMFCore.exceptions import BadRequest
+from Products.CMFCore.interfaces import ICatalogTool
+from Products.CMFCore.interfaces import ITypesTool
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 +59,7 @@
class PortalFolderFactoryTests(SecurityTest):
- layer = EventZCMLLayer
+ layer = TraversingEventZCMLLayer
_PORTAL_TYPE = 'Test Folder'
def _getTargetObject(self):
@@ -67,13 +71,14 @@
from Products.CMFCore.PortalFolder import PortalFolder
SecurityTest.setUp(self)
- gsm = getGlobalSiteManager()
- gsm.registerUtility(self._getTargetObject(), IFactory, 'cmf.folder')
+ sm = getSiteManager()
+ sm.registerUtility(self._getTargetObject(), IFactory, 'cmf.folder')
self.site = DummySite('site').__of__(self.root)
acl_users = self.site._setObject('acl_users', DummyUserFolder())
newSecurityManager(None, acl_users.all_powerful_Oz)
ttool = self.site._setObject('portal_types', TypesTool())
+ sm.registerUtility(self.site.portal_types, ITypesTool)
ttool._setObject(self._PORTAL_TYPE,
FTI(id=self._PORTAL_TYPE,
title='Folder or Directory',
@@ -125,11 +130,7 @@
self._getTargetClass()(id, *args, **kw))
def setUp(self):
- from Products.CMFCore.PortalFolder import PortalFolderFactory
-
SecurityTest.setUp(self)
- gsm = getGlobalSiteManager()
- gsm.registerUtility(PortalFolderFactory, IFactory, 'cmf.folder')
self.site = DummySite('site').__of__(self.root)
def test_z2interfaces(self):
@@ -145,7 +146,9 @@
verifyClass(IOrderedContainer, self._getTargetClass())
def test_contents_methods(self):
+ sm = getSiteManager(self.site)
ttool = self.site._setObject( 'portal_types', TypesTool() )
+ sm.registerUtility(ttool, ITypesTool)
f = self._makeOne('foo')
self.assertEqual( f.objectValues(), [] )
self.assertEqual( f.contentIds(), [] )
@@ -217,9 +220,12 @@
# 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() )
+ sm.registerUtility(ttool, ITypesTool)
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 +245,11 @@
# 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() )
+ sm.registerUtility(ttool, ITypesTool)
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 +263,12 @@
#
from Products.CMFCore.PortalFolder import PortalFolder
+ sm = getSiteManager(self.site)
test = self._makeOne('test')
ttool = self.site._setObject( 'portal_types', TypesTool() )
+ sm.registerUtility(ttool, ITypesTool)
ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
+ sm.registerUtility(ctool, ICatalogTool)
self.assertEqual( len(ctool), 0 )
test._setObject( 'sub', PortalFolder( 'sub', '' ) )
@@ -281,9 +293,11 @@
#
from Products.CMFCore.PortalFolder import PortalFolder
+ sm = getSiteManager(self.site)
test = self._makeOne('test')
ttool = self.site._setObject( 'portal_types', TypesTool() )
+ sm.registerUtility(ttool, ITypesTool)
ttool._setObject( 'Folder'
, FTI( id='Folder'
, title='Folder or Directory'
@@ -334,7 +348,9 @@
#
# _verifyObjectPaste() should honor allowed content types
#
+ sm = getSiteManager(self.site)
ttool = self.site._setObject( 'portal_types', TypesTool() )
+ sm.registerUtility(ttool, ITypesTool)
fti = FTIDATA_DUMMY[0].copy()
ttool._setObject( 'Dummy Content', FTI(**fti) )
ttool._setObject( 'Folder', FTI(**fti) )
@@ -382,9 +398,11 @@
self.assertRaises(BadRequest, test._checkId, 'acl_users')
def test__checkId_MethodAlias(self):
+ sm = getSiteManager(self.site)
test = self._makeOne('test')
test._setPortalTypeName('Dummy Content 15')
ttool = self.site._setObject('portal_types', TypesTool())
+ sm.registerUtility(self.site.portal_types, ITypesTool)
ttool._setObject('Dummy Content 15', FTI(**FTIDATA_CMF15[0]))
acl_users = self.site._setObject('acl_users', DummyUserFolder())
test._checkId('view.html')
@@ -425,7 +443,7 @@
class PortalFolderMoveTests(SecurityTest):
- layer = EventZCMLLayer
+ layer = TraversingEventZCMLLayer
def setUp(self):
SecurityTest.setUp(self)
@@ -443,8 +461,11 @@
#
from Products.CMFCore.PortalFolder import PortalFolder
+ sm = getSiteManager(self.site)
ttool = self.site._setObject( 'portal_types', TypesTool() )
+ sm.registerUtility(ttool, ITypesTool)
ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
+ sm.registerUtility(ctool, ICatalogTool)
ctool.addIndex('getId', 'FieldIndex')
self.assertEqual( len(ctool), 0 )
@@ -489,8 +510,11 @@
#
# 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() )
+ sm.registerUtility(ttool, ITypesTool)
fti = FTIDATA_DUMMY[0].copy()
ttool._setObject( 'Dummy Content', FTI(**fti) )
sub1 = self._makeOne('sub1')
@@ -1056,6 +1080,7 @@
from AccessControl.Permissions import delete_objects as DeleteObjects
from Products.CMFCore.PortalFolder import PortalFolder
+ sm = getSiteManager()
folder1, folder2 = self._initFolders()
folder1.manage_permission( DeleteObjects, roles=(), acquire=0 )
@@ -1063,6 +1088,7 @@
transaction.savepoint(optimistic=True) # get a _p_jar for 'sub'
self.app.portal_types = DummyTypesTool()
+ sm.registerUtility(self.app.portal_types, ITypesTool)
def _no_delete_objects(permission, object, context):
return permission != DeleteObjects
@@ -1089,11 +1115,13 @@
folder1, folder2 = self._initFolders()
folder1.portal_type = UNRESTRICTED_TYPE
folder2.portal_type = RESTRICTED_TYPE
+ sm = getSiteManager()
self._initPolicyAndUser() # ensure that sec. machinery allows paste
self.app._setObject( 'portal_types', TypesTool() )
types_tool = self.app.portal_types
+ sm.registerUtility(types_tool, ITypesTool)
types_tool._setObject( RESTRICTED_TYPE
, FTI( id=RESTRICTED_TYPE
, title=RESTRICTED_TYPE
@@ -1134,11 +1162,13 @@
folder1, folder2 = self._initFolders()
folder1.portal_type = UNRESTRICTED_TYPE
folder2.portal_type = RESTRICTED_TYPE
+ sm = getSiteManager()
self._initPolicyAndUser() # ensure that sec. machinery allows paste
self.app._setObject( 'portal_types', TypesTool() )
types_tool = self.app.portal_types
+ sm.registerUtility(types_tool, ITypesTool)
types_tool._setObject( RESTRICTED_TYPE
, FTI( id=RESTRICTED_TYPE
, title=RESTRICTED_TYPE
@@ -1178,11 +1208,13 @@
folder1, folder2 = self._initFolders()
folder1.portal_type = RESTRICTED_TYPE
folder2.portal_type = UNRESTRICTED_TYPE
+ sm = getSiteManager()
self._initPolicyAndUser() # ensure that sec. machinery allows paste
self.app._setObject( 'portal_types', TypesTool() )
types_tool = self.app.portal_types
+ sm.registerUtility(types_tool, ITypesTool)
types_tool._setObject( RESTRICTED_TYPE
, FTI( id=RESTRICTED_TYPE
, title=RESTRICTED_TYPE
@@ -1218,6 +1250,8 @@
class DummyTypesTool( Implicit ):
+ implements(ITypesTool)
+
def getTypeInfo( self, portal_type ):
return DummyTypeInfo()
Modified: CMF/trunk/CMFCore/tests/test_SkinsTool.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_SkinsTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_SkinsTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFCore/tests/test_TypesTool.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_TypesTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_TypesTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -26,7 +26,7 @@
from Products.PythonScripts.PythonScript import PythonScript
from Products.PythonScripts.standard import html_quote
from webdav.NullResource import NullResource
-from zope.component import getGlobalSiteManager
+from zope.component import getSiteManager
from zope.component.interfaces import IFactory
from zope.testing.cleanup import cleanUp
@@ -447,8 +447,8 @@
def setUp(self):
SecurityTest.setUp(self)
- gsm = getGlobalSiteManager()
- gsm.registerUtility(DummyFactory, IFactory, 'test.dummy')
+ sm = getSiteManager()
+ sm.registerUtility(DummyFactory, IFactory, 'test.dummy')
self.f = DummyFolder()
self.ti = self._makeOne('Foo', meta_type='Dummy',
@@ -456,8 +456,8 @@
newSecurityManager(None, UserWithRoles('FooAdder').__of__(self.f))
def tearDown(self):
+ cleanUp()
SecurityTest.tearDown(self)
- cleanUp()
def test_suite():
Modified: CMF/trunk/CMFCore/tests/test_URLTool.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_URLTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_URLTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,6 +18,9 @@
import unittest
import Testing
+from zope.component import getSiteManager
+
+from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFCore.tests.base.dummy import DummyFolder
from Products.CMFCore.tests.base.dummy import DummySite
@@ -27,6 +30,8 @@
def setUp(self):
self.site = DummySite(id='foo')
+ sm = getSiteManager()
+ sm.registerUtility(self.site, ISiteRoot)
def _makeOne(self, *args, **kw):
from Products.CMFCore.URLTool import URLTool
Modified: CMF/trunk/CMFCore/tests/test_WorkflowTool.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_WorkflowTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/tests/test_WorkflowTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -20,11 +20,16 @@
from OFS.SimpleItem import SimpleItem
-from zope.component import adapter, provideHandler
+from zope.component import adapter
+from zope.component import getSiteManager
+from zope.component import provideHandler
from Products.CMFCore.interfaces import IActionWillBeInvokedEvent
from Products.CMFCore.interfaces import IActionRaisedExceptionEvent
from Products.CMFCore.interfaces import IActionSucceededEvent
+from Products.CMFCore.interfaces import ITypesTool
+
+
class Dummy( SimpleItem ):
def __init__( self, id ):
@@ -161,9 +166,11 @@
def _makeRoot( self ):
from OFS.Folder import Folder
+ sm = getSiteManager()
root = Folder( 'root' )
tt = DummyTypesTool()
root._setObject( 'portal_types', tt )
+ sm.registerUtility(root.portal_types, ITypesTool)
return root
def _makeWithTypes( self ):
Modified: CMF/trunk/CMFCore/utils.py
===================================================================
--- CMF/trunk/CMFCore/utils.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFCore/utils.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -47,10 +47,15 @@
from OFS.SimpleItem import SimpleItem
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.dottedname.resolve import resolve as resolve_dotted_name
from zope.i18nmessageid import MessageFactory
from exceptions import AccessControl_Unauthorized
from exceptions import NotFound
+from interfaces import ICachingPolicyManager
SUBTEMPLATE = '__SUBTEMPLATE__'
@@ -65,6 +70,24 @@
#
_marker = [] # Create a new marker object.
+_tool_interface_registry = {}
+
+security.declarePrivate('registerToolInterface')
+def registerToolInterface(tool_id, tool_interface):
+ """ Register a tool ID for an interface
+
+ This method can go away when getToolByName is going away (CMF 2.3).
+ """
+ global _tool_interface_registry
+ _tool_interface_registry[tool_id] = tool_interface
+
+security.declarePrivate('getToolInterface')
+def getToolInterface(tool_id):
+ """ Get the interface registered for a tool ID
+ """
+ global _tool_interface_registry
+ return _tool_interface_registry.get(tool_id, None)
+
security.declarePublic('getToolByName')
def getToolByName(obj, name, default=_marker):
@@ -74,6 +97,20 @@
acquiring the tool by name, to ease forward migration (e.g.,
to Zope3).
"""
+ tool_interface = _tool_interface_registry.get(name)
+
+ if tool_interface is not None:
+ warn('getToolByName is deprecated and will be removed in '
+ 'CMF 2.3, please use "getUtility(%s)"' % (
+ tool_interface.__name__), DeprecationWarning, stacklevel=2)
+
+ try:
+ return getUtility(tool_interface)
+ except ComponentLookupError:
+ # behave in backwards-compatible way
+ # fall through to old implementation
+ pass
+
try:
tool = aq_get(obj, name, default, 1)
except AttributeError:
@@ -85,6 +122,27 @@
raise AttributeError, name
return tool
+security.declarePublic('getToolByInterfaceName')
+def getToolByInterfaceName(dotted_name, default=_marker):
+ """ Get a tool by its fully-qualified dotted interface path
+
+ This method replaces getToolByName for use in untrusted code.
+ Trusted code should use zope.component.getUtility instead.
+ """
+ try:
+ iface = resolve_dotted_name(dotted_name)
+ except ImportError:
+ if default is _marker:
+ raise ComponentLookupError, dotted_name
+ return default
+
+ try:
+ return getUtility(iface)
+ except ComponentLookupError:
+ if default is _marker:
+ raise
+ return default
+
security.declarePublic('cookString')
def cookString(text):
@@ -304,7 +362,7 @@
# not a conditional GET
return False
- manager = getToolByName(obj, 'caching_policy_manager', None)
+ manager = queryUtility(ICachingPolicyManager)
if manager is None:
return False
@@ -384,23 +442,25 @@
delattr(REQUEST, SUBTEMPLATE)
content = aq_parent(obj)
- manager = getToolByName(obj, 'caching_policy_manager', None)
- if manager is not None:
- view_name = obj.getId()
- headers = manager.getHTTPCachingHeaders(
- content, view_name, extra_context
- )
- RESPONSE = REQUEST['RESPONSE']
- for key, value in headers:
- if key == 'ETag':
- RESPONSE.setHeader(key, value, literal=1)
- else:
- RESPONSE.setHeader(key, value)
- if headers:
- RESPONSE.setHeader('X-Cache-Headers-Set-By',
- 'CachingPolicyManager: %s' %
- '/'.join(manager.getPhysicalPath()))
+ manager = queryUtility(ICachingPolicyManager)
+ if manager is None:
+ return
+ view_name = obj.getId()
+ headers = manager.getHTTPCachingHeaders(
+ content, view_name, extra_context
+ )
+ RESPONSE = REQUEST['RESPONSE']
+ for key, value in headers:
+ if key == 'ETag':
+ RESPONSE.setHeader(key, value, literal=1)
+ else:
+ RESPONSE.setHeader(key, value)
+ if headers:
+ RESPONSE.setHeader('X-Cache-Headers-Set-By',
+ 'CachingPolicyManager: %s' %
+ '/'.join(manager.getPhysicalPath()))
+
class _ViewEmulator(Implicit):
"""Auxiliary class used to adapt FSFile and FSImage
for caching_policy_manager
Modified: CMF/trunk/CMFDefault/DefaultWorkflow.py
===================================================================
--- CMF/trunk/CMFDefault/DefaultWorkflow.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/DefaultWorkflow.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -21,14 +21,18 @@
from AccessControl import ClassSecurityInfo
from DateTime import DateTime
from Globals import InitializeClass
+
+from zope.component import getUtility
+from zope.component import queryUtility
from zope.interface import implements
+from Products.CMFCore.interfaces import ICatalogTool
+from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.interfaces import IWorkflowDefinition
from Products.CMFCore.interfaces.portal_workflow \
import WorkflowDefinition as z2IWorkflowDefinition
from Products.CMFCore.utils import _checkPermission
from Products.CMFCore.utils import _modifyPermissionMappings
-from Products.CMFCore.utils import getToolByName
from Products.CMFCore.utils import SimpleItemWithProperties
from exceptions import AccessControl_Unauthorized
@@ -99,7 +103,7 @@
content = info.object
content_url = info.object_url
content_creator = content.Creator()
- pm = getToolByName(self, 'portal_membership')
+ pm = getUtility(IMembershipTool)
current_user = pm.getAuthenticatedMember().getId()
review_state = self.getReviewStateOf(content)
actions = []
@@ -156,18 +160,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 = queryUtility(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')
@@ -201,7 +207,7 @@
elif review_state == 'private':
raise AccessControl_Unauthorized('Already private')
content_creator = ob.Creator()
- pm = getToolByName(self, 'portal_membership')
+ pm = getUtility(IMembershipTool)
current_user = pm.getAuthenticatedMember().getId()
if (content_creator != current_user) and not allow_review:
raise AccessControl_Unauthorized('Not creator or reviewer')
@@ -248,7 +254,7 @@
security.declarePrivate('setReviewStateOf')
def setReviewStateOf(self, ob, review_state, action, comment):
tool = aq_parent(aq_inner(self))
- pm = getToolByName(self, 'portal_membership')
+ pm = getUtility(IMembershipTool)
current_user = pm.getAuthenticatedMember().getId()
status = {
'actor': current_user,
Modified: CMF/trunk/CMFDefault/DiscussionItem.py
===================================================================
--- CMF/trunk/CMFDefault/DiscussionItem.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/DiscussionItem.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -22,16 +22,18 @@
from Globals import Persistent
from Globals import PersistentMapping
from OFS.Traversable import Traversable
+
+from zope.component import getUtility
from zope.interface import implements
from Products.CMFCore.interfaces import ICallableOpaqueItemEvents
from Products.CMFCore.interfaces import IDiscussable
from Products.CMFCore.interfaces import IDiscussionResponse
+from Products.CMFCore.interfaces import IDiscussionTool
from Products.CMFCore.interfaces.Discussions \
import Discussable as z2IDiscussable
from Products.CMFCore.interfaces.Discussions \
import DiscussionResponse as z2IDiscussionResponse
-from Products.CMFCore.utils import getToolByName
from Document import Document
from permissions import AccessContentsInformation
@@ -113,7 +115,7 @@
- We are a nested reply; in this case, our 'in_reply_to'
field will be the ID of the parent DiscussionItem.
"""
- tool = getToolByName( self, 'portal_discussion' )
+ tool = getUtility(IDiscussionTool)
talkback = tool.getDiscussionFor( self )
return talkback._getReplyParent( self.in_reply_to )
Modified: CMF/trunk/CMFDefault/DiscussionTool.py
===================================================================
--- CMF/trunk/CMFDefault/DiscussionTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/DiscussionTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -20,16 +20,20 @@
from Globals import DTMLFile
from Globals import InitializeClass
from OFS.SimpleItem import SimpleItem
+
+from zope.component import getUtility
from zope.interface import implements
from Products.CMFCore.ActionProviderBase import ActionProviderBase
from Products.CMFCore.interfaces import IDiscussionResponse
from Products.CMFCore.interfaces import IDiscussionTool
+from Products.CMFCore.interfaces import IMembershipTool
+from Products.CMFCore.interfaces import ITypesTool
from Products.CMFCore.interfaces.Discussions \
import DiscussionResponse as z2IDiscussionResponse
from Products.CMFCore.interfaces.portal_discussion \
import portal_discussion as z2IDiscussionTool
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import registerToolInterface
from Products.CMFCore.utils import UniqueObject
from DiscussionItem import DiscussionItemContainer
@@ -75,7 +79,7 @@
def overrideDiscussionFor(self, content, allowDiscussion):
""" Override discussability for the given object or clear the setting.
"""
- mtool = getToolByName( self, 'portal_membership' )
+ mtool = getUtility(IMembershipTool)
if not mtool.checkPermission(ModifyPortalContent, content):
raise AccessControl_Unauthorized
@@ -107,7 +111,7 @@
"""
if hasattr( aq_base(content), 'allow_discussion' ):
return bool(content.allow_discussion)
- typeInfo = getToolByName(self, 'portal_types').getTypeInfo( content )
+ typeInfo = getUtility(ITypesTool).getTypeInfo( content )
if typeInfo:
return bool( typeInfo.allowDiscussion() )
return False
@@ -126,3 +130,5 @@
return content.talkback
InitializeClass( DiscussionTool )
+registerToolInterface('portal_discussion', IDiscussionTool)
+
Modified: CMF/trunk/CMFDefault/DublinCore.py
===================================================================
--- CMF/trunk/CMFDefault/DublinCore.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/DublinCore.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -21,10 +21,14 @@
from Globals import DTMLFile
from Globals import InitializeClass
from OFS.PropertyManager import PropertyManager
+
+from zope.component import queryUtility
from zope.interface import implements
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
@@ -32,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
@@ -106,7 +109,7 @@
""" Add creator to Dublin Core creators.
"""
if creator is None:
- mtool = getToolByName(self, 'portal_membership', None)
+ mtool = queryUtility(IMembershipTool)
creator = mtool and mtool.getAuthenticatedMember().getId()
# call self.listCreators() to make sure self.creators exists
@@ -169,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/trunk/CMFDefault/Extensions/update_catalogIndexes.py
===================================================================
--- CMF/trunk/CMFDefault/Extensions/update_catalogIndexes.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/Extensions/update_catalogIndexes.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFDefault/Favorite.py
===================================================================
--- CMF/trunk/CMFDefault/Favorite.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/Favorite.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -20,12 +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.utils import getToolByName
+from Products.CMFCore.interfaces import IURLTool
+from Products.CMFUid.interfaces import IUniqueIdAnnotationManagement
from DublinCore import DefaultDublinCoreImpl
from interfaces import IFavorite
@@ -68,11 +72,11 @@
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
- portal = getToolByName(self, 'portal_url').getPortalObject()
+ portal = getUtility(IURLTool).getPortalObject()
obj = portal.restrictedTraverse(self.remote_url)
return handler.register(obj)
@@ -81,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
@@ -112,7 +116,7 @@
def _getRemoteUrlTheOldWay(self):
"""Build the url without having taking the uid into account
"""
- portal_url = getToolByName(self, 'portal_url')
+ portal_url = getUtility(IURLTool)
if self.remote_url:
return portal_url() + '/' + self.remote_url
else:
@@ -139,7 +143,7 @@
if remote_obj is not None:
return remote_obj
- portal_url = getToolByName(self, 'portal_url')
+ portal_url = getUtility(IURLTool)
return portal_url.getPortalObject().restrictedTraverse(self.remote_url)
security.declarePrivate('_edit')
@@ -155,7 +159,7 @@
t=('', '') + tokens[2:]
remote_url=urlparse.urlunparse(t)
# if URL begins with site URL, remove site URL
- portal_url = getToolByName(self, 'portal_url').getPortalPath()
+ portal_url = getUtility(IURLTool).getPortalPath()
i = remote_url.find(portal_url)
if i==0:
remote_url=remote_url[len(portal_url):]
Modified: CMF/trunk/CMFDefault/MembershipTool.py
===================================================================
--- CMF/trunk/CMFDefault/MembershipTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/MembershipTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -27,7 +27,7 @@
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
from interfaces import IMembershipTool
@@ -216,3 +216,5 @@
return None
InitializeClass(MembershipTool)
+registerToolInterface('portal_membership', IMembershipTool)
+
Modified: CMF/trunk/CMFDefault/MetadataTool.py
===================================================================
--- CMF/trunk/CMFDefault/MetadataTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/MetadataTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFDefault/PropertiesTool.py
===================================================================
--- CMF/trunk/CMFDefault/PropertiesTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/PropertiesTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -19,12 +19,17 @@
from Acquisition import aq_inner, aq_parent
from Globals import InitializeClass, DTMLFile
from OFS.SimpleItem import SimpleItem
+from Products.MailHost.interfaces import IMailHost
+from zope.app.component.hooks import getSite
+from zope.component import getUtility
from zope.interface import implements
from Products.CMFCore.ActionProviderBase import ActionProviderBase
from Products.CMFCore.interfaces import IPropertiesTool
+from Products.CMFCore.interfaces import ISiteRoot
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
@@ -59,17 +64,19 @@
security.declareProtected(ManagePortal, 'editProperties')
def editProperties(self, props):
'''Change portal settings'''
- aq_parent(aq_inner(self)).manage_changeProperties(props)
- self.MailHost.smtp_host = props['smtp_server']
+ site = getUtility(ISiteRoot)
+ site.manage_changeProperties(props)
+ getUtility(IMailHost).smtp_host = props['smtp_server']
if hasattr(self, 'propertysheets'):
ps = self.propertysheets
if hasattr(ps, 'props'):
ps.props.manage_changeProperties(props)
def title(self):
- return self.aq_inner.aq_parent.title
+ return getUtility(ISiteRoot).title
def smtp_server(self):
- return self.MailHost.smtp_host
+ return getUtility(IMailHost).smtp_host
InitializeClass(PropertiesTool)
+registerToolInterface('portal_properties', IPropertiesTool)
Modified: CMF/trunk/CMFDefault/RegistrationTool.py
===================================================================
--- CMF/trunk/CMFDefault/RegistrationTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/RegistrationTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,11 +18,16 @@
from AccessControl import ClassSecurityInfo
from Acquisition import aq_base
from Globals import InitializeClass
+from Products.MailHost.interfaces import IMailHost
+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 getToolByName
+from Products.CMFCore.utils import registerToolInterface
from permissions import ManagePortal
from utils import checkEmailAddress
@@ -34,6 +39,7 @@
""" Manage through-the-web signup policies.
"""
+ implements(IRegistrationTool)
__implements__ = BaseTool.__implements__
meta_type = 'Default Registration Tool'
@@ -126,7 +132,7 @@
o Raise an exception if user ID is not found.
"""
- membership = getToolByName(self, 'portal_membership')
+ membership = getUtility(IMembershipTool)
member = membership.getMemberById(forgotten_userid)
if member is None:
@@ -146,7 +152,7 @@
else:
mail_text = method(**kw)
- host = self.MailHost
+ host = getUtility(IMailHost)
host.send( mail_text )
return self.mail_password_response( self, REQUEST )
@@ -155,7 +161,7 @@
def registeredNotify( self, new_member_id, password=None ):
""" Handle mailing the registration / welcome message.
"""
- membership = getToolByName( self, 'portal_membership' )
+ membership = getUtility(IMembershipTool)
member = membership.getMemberById( new_member_id )
if member is None:
@@ -178,7 +184,7 @@
else:
mail_text = method(**kw)
- host = self.MailHost
+ host = getUtility(IMailHost)
host.send( mail_text )
security.declareProtected(ManagePortal, 'editMember')
@@ -195,7 +201,7 @@
testPropertiesValidity and testPasswordValidity
"""
- mtool = getToolByName(self, 'portal_membership')
+ mtool = getUtility(IMembershipTool)
member = mtool.getMemberById(member_id)
member.setMemberProperties(properties)
member.setSecurityProfile(password,roles,domains)
@@ -203,3 +209,5 @@
return member
InitializeClass(RegistrationTool)
+registerToolInterface('portal_registration', IRegistrationTool)
+
Modified: CMF/trunk/CMFDefault/SyndicationTool.py
===================================================================
--- CMF/trunk/CMFDefault/SyndicationTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/SyndicationTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -24,9 +24,13 @@
from Globals import InitializeClass
from OFS.SimpleItem import SimpleItem
+from zope.interface import implements
+
from Products.CMFCore.ActionProviderBase import ActionProviderBase
+from Products.CMFCore.interfaces import ISyndicationTool
from Products.CMFCore.PortalFolder import PortalFolderBase
from Products.CMFCore.utils import _checkPermission
+from Products.CMFCore.utils import registerToolInterface
from Products.CMFCore.utils import UniqueObject
from exceptions import AccessControl_Unauthorized
@@ -43,6 +47,7 @@
syndication of folder content as RSS.
"""
+ implements(ISyndicationTool)
__implements__ = ActionProviderBase.__implements__
id = 'portal_syndication'
@@ -348,7 +353,7 @@
return 'Syndication is not Allowed'
security.declarePublic('getHTML4UpdateBase')
- def getHTML4UpdateBase(self, obj):
+ def getHTML4UpdateBase(self, obj=None):
"""
Return HTML4 formated UpdateBase DateTime
"""
@@ -385,3 +390,5 @@
return 'Syndication is not Allowed'
InitializeClass(SyndicationTool)
+registerToolInterface('portal_syndication', ISyndicationTool)
+
Modified: CMF/trunk/CMFDefault/__init__.py
===================================================================
--- CMF/trunk/CMFDefault/__init__.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/__init__.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -60,6 +60,14 @@
, SyndicationTool.SyndicationTool
)
+# 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/trunk/CMFDefault/browser/favorite.py
===================================================================
--- CMF/trunk/CMFDefault/browser/favorite.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/browser/favorite.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -19,13 +19,14 @@
from zope.app.form.browser import BytesWidget
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
from zope.schema import BytesLine
from zope.schema import TextLine
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.interfaces import IURLTool
from Products.CMFDefault.formlib.form import ContentEditFormBase
from Products.CMFDefault.formlib.schema import ProxyFieldProperty
from Products.CMFDefault.formlib.schema import SchemaAdapterBase
@@ -82,7 +83,7 @@
value = urlparse.urlunparse(tokens)
# if URL begins with site URL, remove site URL
obj = self.context.context.context
- portal_url = getToolByName(obj, 'portal_url').getPortalPath()
+ portal_url = getUtility(IURLTool)
if value.startswith(portal_url):
value = value[len(portal_url):]
# if site is still absolute, make it relative
Modified: CMF/trunk/CMFDefault/browser/folder.py
===================================================================
--- CMF/trunk/CMFDefault/browser/folder.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/browser/folder.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -20,6 +20,7 @@
from ZTUtils import make_query
from Products.CMFCore.interfaces import IDynamicType
+from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFDefault.exceptions import CopyError
from Products.CMFDefault.exceptions import zExceptions_Unauthorized
from Products.CMFDefault.permissions import AddPortalContent
@@ -66,73 +67,86 @@
'title': _(u'New...'),
'permissions': (ViewManagementScreens, AddPortalContent),
'conditions': ('checkAllowedContentTypes',),
- 'redirect': ('portal_types', 'object/new')},
+ 'redirect': ('Products.CMFCore.interfaces.ITypesTool',
+ 'object/new')},
{'id': 'items_rename',
'title': _(u'Rename...'),
'permissions': (ViewManagementScreens, AddPortalContent),
'conditions': ('checkItems', 'checkAllowedContentTypes'),
'transform': ('validateItemIds',),
- 'redirect': ('portal_types', 'object/rename_items',
+ 'redirect': ('Products.CMFCore.interfaces.ITypesTool',
+ 'object/rename_items',
'b_start, ids, key, reverse')},
{'id': 'items_cut',
'title': _(u'Cut'),
'permissions': (ViewManagementScreens,),
'conditions': ('checkItems',),
'transform': ('validateItemIds', 'cut_control'),
- 'redirect': ('portal_types', 'object/folderContents',
+ 'redirect': ('Products.CMFCore.interfaces.ITypesTool',
+ 'object/folderContents',
'b_start, key, reverse')},
{'id': 'items_copy',
'title': _(u'Copy'),
'permissions': (ViewManagementScreens,),
'conditions': ('checkItems',),
'transform': ('validateItemIds', 'copy_control'),
- 'redirect': ('portal_types', 'object/folderContents',
+ 'redirect': ('Products.CMFCore.interfaces.ITypesTool',
+ 'object/folderContents',
'b_start, key, reverse')},
{'id': 'items_paste',
'title': _(u'Paste'),
'permissions': (ViewManagementScreens, AddPortalContent),
'conditions': ('checkClipboardData',),
'transform': ('validateClipboardData', 'paste_control'),
- 'redirect': ('portal_types', 'object/folderContents',
+ 'redirect': ('Products.CMFCore.interfaces.ITypesTool',
+ 'object/folderContents',
'b_start, key, reverse')},
{'id': 'items_delete',
'title': _(u'Delete'),
'permissions': (ViewManagementScreens, DeleteObjects),
'conditions': ('checkItems',),
'transform': ('validateItemIds', 'delete_control'),
- 'redirect': ('portal_types', 'object/folderContents',
+ 'redirect': ('Products.CMFCore.interfaces.ITypesTool',
+ 'object/folderContents',
'b_start, key, reverse')},
{'id': 'items_sort',
'permissions': (ManageProperties,),
'transform': ('sort_control',),
- 'redirect': ('portal_types', 'object/folderContents',
+ 'redirect': ('Products.CMFCore.interfaces.ITypesTool',
+ 'object/folderContents',
'b_start')},
{'id': 'items_up',
'permissions': (ManageProperties,),
'transform': ('validateItemIds', 'up_control'),
- 'redirect': ('portal_types', 'object/folderContents',
+ 'redirect': ('Products.CMFCore.interfaces.ITypesTool',
+ 'object/folderContents',
'b_start, key, reverse')},
{'id': 'items_down',
'permissions': (ManageProperties,),
'transform': ('validateItemIds', 'down_control'),
- 'redirect': ('portal_types', 'object/folderContents',
+ 'redirect': ('Products.CMFCore.interfaces.ITypesTool',
+ 'object/folderContents',
'b_start, key, reverse')},
{'id': 'items_top',
'permissions': (ManageProperties,),
'transform': ('validateItemIds', 'top_control'),
- 'redirect': ('portal_types', 'object/folderContents',
+ 'redirect': ('Products.CMFCore.interfaces.ITypesTool',
+ 'object/folderContents',
'b_start, key, reverse')},
{'id': 'items_bottom',
'permissions': (ManageProperties,),
'transform': ('validateItemIds', 'bottom_control'),
- 'redirect': ('portal_types', 'object/folderContents',
+ 'redirect': ('Products.CMFCore.interfaces.ITypesTool',
+ 'object/folderContents',
'b_start, key, reverse')},
{'id': 'set_view_filter',
'transform': ('set_filter_control',),
- 'redirect': ('portal_types', 'object/folderContents')},
+ 'redirect': ('Products.CMFCore.interfaces.ITypesTool',
+ 'object/folderContents')},
{'id': 'clear_view_filter',
'transform': ('clear_filter_control',),
- 'redirect': ('portal_types', 'object/folderContents')})
+ 'redirect': ('Products.CMFCore.interfaces.ITypesTool',
+ 'object/folderContents')})
# helpers
@@ -169,7 +183,7 @@
@memoize
@decode
def up_info(self):
- mtool = self._getTool('portal_membership')
+ mtool = self._getToolByInterface(IMembershipTool)
allowed = mtool.checkPermission(ListFolderContents, self.context,
'aq_parent')
if allowed:
Modified: CMF/trunk/CMFDefault/browser/folder.txt
===================================================================
--- CMF/trunk/CMFDefault/browser/folder.txt 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/browser/folder.txt 2007-03-07 16:41:03 UTC (rev 73035)
@@ -9,10 +9,20 @@
>>> site = DummySite('site')
>>> from Products.CMFCore.tests.base.dummy import DummyTool
+ >>> from zope.component import getSiteManager
+ >>> from Products.CMFCore.interfaces import IMembershipTool
+ >>> from Products.CMFCore.interfaces import IPropertiesTool
+ >>> from Products.CMFCore.interfaces import ITypesTool
+ >>> from Products.CMFCore.interfaces import IURLTool
+ >>> sm = getSiteManager()
>>> mtool = site._setObject('portal_membership', DummyTool())
+ >>> sm.registerUtility(mtool, IMembershipTool)
>>> ptool = site._setObject('portal_properties', DummyTool())
+ >>> sm.registerUtility(ptool, IPropertiesTool)
>>> ttool = site._setObject('portal_types', DummyTool())
+ >>> sm.registerUtility(ttool, ITypesTool)
>>> utool = site._setObject('portal_url', DummyTool())
+ >>> sm.registerUtility(utool, IURLTool)
Basic functionality without security setup:
@@ -98,3 +108,8 @@
>>> view.validateClipboardData()
(False, u'Please copy or cut one or more items to paste first.')
+
+ Finally we have to clean up::
+
+ >>> from zope.testing.cleanup import cleanUp
+ >>> cleanUp()
Modified: CMF/trunk/CMFDefault/browser/metadata.py
===================================================================
--- CMF/trunk/CMFDefault/browser/metadata.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/browser/metadata.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,6 +18,7 @@
from Acquisition import aq_self
from zope.app.form.browser import DatetimeI18nWidget
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
@@ -29,9 +30,9 @@
from zope.schema import Tuple
from zope.schema import URI
+from Products.CMFCore.interfaces import IDiscussionTool
from Products.CMFCore.interfaces import IMutableDublinCore
from Products.CMFCore.interfaces import IMutableMinimalDublinCore
-from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.formlib.form import ContentEditFormBase
from Products.CMFDefault.formlib.schema import ProxyFieldProperty
from Products.CMFDefault.formlib.schema import SchemaAdapterBase
@@ -172,7 +173,7 @@
return getattr(context, 'allow_discussion', None)
def _setAllowDiscussion(self, value):
- dtool = getToolByName(self.context, 'portal_discussion')
+ dtool = getUtility(IDiscussionTool)
dtool.overrideDiscussionFor(self.context, value)
allow_discussion = property(_getAllowDiscussion, _setAllowDiscussion)
@@ -260,8 +261,12 @@
def handle_change_success(self, action, data):
self._handle_success(action, data)
- return self._setRedirect('portal_types', 'object/metadata')
+ return self._setRedirect( 'Products.CMFCore.interfaces.ITypesTool'
+ , 'object/metadata'
+ )
def handle_change_and_edit_success(self, action, data):
self._handle_success(action, data)
- return self._setRedirect('portal_types', 'object/edit')
+ return self._setRedirect( 'Products.CMFCore.interfaces.ITypesTool'
+ , 'object/edit'
+ )
Modified: CMF/trunk/CMFDefault/browser/utils.py
===================================================================
--- CMF/trunk/CMFDefault/browser/utils.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/browser/utils.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -22,6 +22,12 @@
from ZTUtils import Batch
from ZTUtils import make_query
+from zope.component import getUtility
+
+from Products.CMFCore.interfaces import IMembershipTool
+from Products.CMFCore.interfaces import IPropertiesTool
+from Products.CMFCore.interfaces import IURLTool
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.permissions import View
from Products.CMFDefault.utils import getBrowserCharset
@@ -74,13 +80,21 @@
return getToolByName(self.context, name)
@memoize
+ def _getToolByInterface(self, iface):
+ return getUtility(iface)
+
+ @memoize
+ def _getToolByInterfaceName(self, dotted_name):
+ return getToolByInterfaceName(dotted_name)
+
+ @memoize
def _checkPermission(self, permission):
- mtool = self._getTool('portal_membership')
+ mtool = self._getToolByInterface(IMembershipTool)
return mtool.checkPermission(permission, self.context)
@memoize
def _getPortalURL(self):
- utool = self._getTool('portal_url')
+ utool = self._getToolByInterface(IURLTool)
return utool()
@memoize
@@ -89,7 +103,7 @@
@memoize
def _getDefaultCharset(self):
- ptool = self._getTool('portal_properties')
+ ptool = self._getToolByInterface(IPropertiesTool)
return ptool.getProperty('default_charset', None)
@memoize
@@ -113,8 +127,8 @@
# helpers
- def _setRedirect(self, provider_id, action_path, keys=''):
- provider = self._getTool(provider_id)
+ def _setRedirect(self, provider_iface, action_path, keys=''):
+ provider = self._getToolByInterfaceName(provider_iface)
try:
target = provider.getActionInfo(action_path, self.context)['url']
except ValueError:
Modified: CMF/trunk/CMFDefault/factory.py
===================================================================
--- CMF/trunk/CMFDefault/factory.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/factory.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -16,9 +16,9 @@
"""
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from zope.app.component.hooks import setSite
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
@@ -53,9 +53,10 @@
site = CMFSite( site_id )
dispatcher._setObject( site_id, site )
site = dispatcher._getOb( site_id )
+ setSite(site)
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/trunk/CMFDefault/formlib/form.py
===================================================================
--- CMF/trunk/CMFDefault/formlib/form.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/formlib/form.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -62,8 +62,8 @@
self.request = request
self.request.locale = getLocale(request)
- def _setRedirect(self, provider_id, action_path, keys=''):
- provider = self._getTool(provider_id)
+ def _setRedirect(self, provider_iface, action_path, keys=''):
+ provider = self._getToolByInterfaceName(provider_iface)
try:
target = provider.getActionInfo(action_path, self.context)['url']
except ValueError:
@@ -147,11 +147,15 @@
def handle_change_success(self, action, data):
self._handle_success(action, data)
- return self._setRedirect('portal_types', 'object/edit')
+ return self._setRedirect( 'Products.CMFCore.interfaces.ITypesTool'
+ , 'object/edit'
+ )
def handle_change_and_view_success(self, action, data):
self._handle_success(action, data)
- return self._setRedirect('portal_types', 'object/view')
+ return self._setRedirect( 'Products.CMFCore.interfaces.ITypesTool'
+ , 'object/view'
+ )
class DisplayFormBase(PageDisplayForm, ViewBase):
Modified: CMF/trunk/CMFDefault/formlib/schema.py
===================================================================
--- CMF/trunk/CMFDefault/formlib/schema.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/formlib/schema.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -19,12 +19,14 @@
from DateTime.DateTime import DateTime
from OFS.Image import Pdata
+
+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
@@ -32,7 +34,7 @@
def __init__(self, context):
self.context = context
- ptool = getToolByName(context, 'portal_properties')
+ ptool = getUtility(IPropertiesTool)
self.encoding = ptool.getProperty('default_charset', None)
Modified: CMF/trunk/CMFDefault/formlib/widgets.py
===================================================================
--- CMF/trunk/CMFDefault/formlib/widgets.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/formlib/widgets.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -25,6 +25,7 @@
from zope.app.form.interfaces import IInputWidget
from zope.app.form.interfaces import WidgetInputError
from zope.component import adapts
+from zope.component import getUtility
from zope.interface import implementsOnly
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.schema import Set
@@ -33,7 +34,7 @@
from zope.schema.interfaces import ITuple
from zope.schema.interfaces import ITextLine
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.interfaces import IMetadataTool
from Products.CMFDefault.exceptions import IllegalHTML
from Products.CMFDefault.utils import scrubHTML
from Products.CMFDefault.utils import Message as _
@@ -119,7 +120,7 @@
self.vocabulary = ()
context = getattr(self.context.context, 'context',
self.context.context)
- mdtool = getToolByName(context, 'portal_metadata')
+ mdtool = getUtility(IMetadataTool)
allowed_subjects = mdtool.listAllowedSubjects(context)
if allowed_subjects:
items = [ (str(v), unicode(v), unicode(v))
Modified: CMF/trunk/CMFDefault/formlib/widgets.txt
===================================================================
--- CMF/trunk/CMFDefault/formlib/widgets.txt 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/formlib/widgets.txt 2007-03-07 16:41:03 UTC (rev 73035)
@@ -67,11 +67,14 @@
Set one up::
+ >>> from zope.component import getSiteManager
+ >>> from Products.CMFCore.interfaces import IMetadataTool
>>> class DummyTool:
... def listAllowedSubjects(self, context): return ('SPAM', 'EGGS')
>>> class DummyView: pass
>>> view = DummyView()
>>> view.portal_metadata = DummyTool()
+ >>> getSiteManager().registerUtility(view.portal_metadata, IMetadataTool)
>>> request = DummyRequest()
>>> request.form['PREFIX.NAME.1'] = ['EGGS']
Copied: CMF/trunk/CMFDefault/profiles/default/componentregistry.xml (from rev 73020, CMF/branches/jens_tools_as_utilities/CMFDefault/profiles/default/componentregistry.xml)
Modified: CMF/trunk/CMFDefault/profiles/default/export_steps.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/export_steps.xml 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/profiles/default/export_steps.xml 2007-03-07 16:41:03 UTC (rev 73035)
@@ -15,6 +15,11 @@
title="Catalog Tool">
Export catalog tool's sub-objects, indexes and columns.
</export-step>
+ <export-step id="componentregistry"
+ handler="Products.GenericSetup.components.exportComponentRegistry"
+ title="Local Component Registry">
+ Export local component registry configuration.
+ </export-step>
<export-step id="content_type_registry"
handler="Products.CMFCore.exportimport.contenttyperegistry.exportContentTypeRegistry"
title="Content Type Registry">
Modified: CMF/trunk/CMFDefault/profiles/default/import_steps.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/import_steps.xml 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/profiles/default/import_steps.xml 2007-03-07 16:41:03 UTC (rev 73035)
@@ -3,7 +3,7 @@
<import-step id="actions" version="20040630-01"
handler="Products.CMFCore.exportimport.actions.importActionProviders"
title="Action Providers">
- <dependency step="toolset"/>
+ <dependency step="componentregistry"/>
Import actions tool's action providers and their actions.
</import-step>
<import-step id="caching_policy_mgr" version="20051011-01"
@@ -18,11 +18,18 @@
<dependency step="toolset"/>
Import catalog tool's sub-objects, indexes and columns.
</import-step>
+ <import-step id="componentregistry"
+ version="20061025-01"
+ handler="Products.GenericSetup.components.importComponentRegistry"
+ title="Local Component Registry">
+ <dependency step="various"/>
+ Import local component registry configuration.
+ </import-step>
<import-step id="content_type_registry"
version="20051013-01"
handler="Products.CMFCore.exportimport.contenttyperegistry.importContentTypeRegistry"
title="Content Type Registry">
- <dependency step="toolset"/>
+ <dependency step="componentregistry"/>
Import content type registry's predicates and bindings.
</import-step>
<import-step id="cookie_authentication"
@@ -51,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/trunk/CMFDefault/skins/zpt_content/content_status_modify.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_content/content_status_modify.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_content/content_status_modify.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,11 +1,12 @@
##parameters=workflow_action, comment=''
##title=Modify the status of a content object
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.exceptions import WorkflowException
from Products.CMFDefault.utils import Message as _
-wtool = getToolByName(script, 'portal_workflow')
+wtool_iface = 'Products.CMFCore.interfaces.IConfigurableWorkflowTool'
+wtool = getToolByInterfaceName(wtool_iface)
try:
wtool.doActionFor(context, workflow_action, comment=comment)
Modified: CMF/trunk/CMFDefault/skins/zpt_content/metadata_edit_control.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_content/metadata_edit_control.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_content/metadata_edit_control.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,10 +1,10 @@
##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('Products.CMFCore.interfaces.IDiscussionTool')
def tuplify( value ):
Modified: CMF/trunk/CMFDefault/skins/zpt_content/metadata_edit_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_content/metadata_edit_form.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_content/metadata_edit_form.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,10 +1,10 @@
##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('Products.CMFCore.interfaces.IMetadataTool')
form = context.REQUEST.form
Modified: CMF/trunk/CMFDefault/skins/zpt_control/addtoFavorites.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/addtoFavorites.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_control/addtoFavorites.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,8 +1,8 @@
##parameters=
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
-mtool = getToolByName(script, 'portal_membership')
+mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
home = mtool.getHomeFolder()
if not hasattr(home, 'Favorites'):
Modified: CMF/trunk/CMFDefault/skins/zpt_control/change_password.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/change_password.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_control/change_password.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,11 +1,11 @@
##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('Products.CMFCore.interfaces.IMembershipTool')
+rtool = getToolByInterfaceName('Products.CMFCore.interfaces.IRegistrationTool')
result = rtool.testPasswordValidity(password, confirm)
if result:
Modified: CMF/trunk/CMFDefault/skins/zpt_control/folder_localrole_edit.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/folder_localrole_edit.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_control/folder_localrole_edit.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,10 +1,10 @@
##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('Products.CMFCore.interfaces.IMembershipTool')
if change_type == 'add':
mtool.setLocalRoles(obj=context,
Modified: CMF/trunk/CMFDefault/skins/zpt_control/members_add_control.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/members_add_control.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_control/members_add_control.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,13 +1,13 @@
##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('Products.CMFCore.interfaces.IMembershipTool')
+ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
+rtool = getToolByInterfaceName('Products.CMFCore.interfaces.IRegistrationTool')
try:
rtool.addMember( id=member_id, password=password,
Modified: CMF/trunk/CMFDefault/skins/zpt_control/members_delete_control.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/members_delete_control.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_control/members_delete_control.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,10 +1,10 @@
##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('Products.CMFCore.interfaces.IMembershipTool')
mtool.deleteMembers(ids)
Modified: CMF/trunk/CMFDefault/skins/zpt_control/portal_config_control.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/portal_config_control.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_control/portal_config_control.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,9 +1,9 @@
##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('Products.CMFCore.interfaces.IPropertiesTool')
if not ptool.hasProperty('default_charset'):
ptool.manage_addProperty('default_charset', '', 'string')
Modified: CMF/trunk/CMFDefault/skins/zpt_control/setRedirect.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/setRedirect.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_control/setRedirect.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,10 +1,10 @@
##parameters=provider, action_path, **kw
##
from ZTUtils import make_query
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import getBrowserCharset
-utool = getToolByName(script, 'portal_url')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()
Modified: CMF/trunk/CMFDefault/skins/zpt_control/undo.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/undo.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_control/undo.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,10 +1,10 @@
##parameters=transaction_info
##title=Undo transactions
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import Message as _
-utool = getToolByName(script, 'portal_undo')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IUndoTool')
utool.undo(context, transaction_info)
Modified: CMF/trunk/CMFDefault/skins/zpt_control/validatePassword.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/validatePassword.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_control/validatePassword.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -2,10 +2,10 @@
##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('Products.CMFCore.interfaces.IPropertiesTool')
+rtool = getToolByInterfaceName('Products.CMFCore.interfaces.IRegistrationTool')
if ptool.getProperty('validate_email'):
password = rtool.generatePassword()
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/RSS.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/RSS.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/RSS.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -2,10 +2,10 @@
##
from ZTUtils import Batch
from ZTUtils import LazyFilter
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
-stool = getToolByName(script, 'portal_syndication')
+stool = getToolByInterfaceName('Products.CMFCore.interfaces.ISyndicationTool')
if not stool.isSyndicationAllowed(context):
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/breadcrumbs.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/breadcrumbs.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/breadcrumbs.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,11 +1,11 @@
##parameters=include_root=1
##title=Return breadcrumbs
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import Message as _
-ptool = getToolByName(script, 'portal_properties')
-utool = getToolByName(script, 'portal_url')
+ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()
result = []
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/discitem_delete.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/discitem_delete.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/discitem_delete.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,10 +1,10 @@
##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('Products.CMFCore.interfaces.IDiscussionTool')
parent = context.inReplyTo()
talkback = dtool.getDiscussionFor(parent)
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,10 +1,10 @@
##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('Products.CMFCore.interfaces.IDiscussionTool')
talkback = dtool.getDiscussionFor(context)
replyID = talkback.createReply(title=title, text=text)
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/discussion_reply_form.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,12 +1,12 @@
##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('Products.CMFCore.interfaces.IActionsTool')
form = context.REQUEST.form
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/expanded_title.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/expanded_title.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/expanded_title.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -2,10 +2,10 @@
##parameters=
##title=Build title which includes site title
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
-utool = getToolByName(script, 'portal_url')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
site_title = utool.getPortalObject().Title()
page_title = context.Title()
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/folder_contents.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/folder_contents.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/folder_contents.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -2,7 +2,7 @@
##
from ZTUtils import Batch
from ZTUtils import make_query
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.permissions import AddPortalContent
from Products.CMFDefault.permissions import DeleteObjects
from Products.CMFDefault.permissions import ListFolderContents
@@ -12,8 +12,8 @@
from Products.CMFDefault.utils import html_marshal
from Products.CMFDefault.utils import Message as _
-mtool = getToolByName(script, 'portal_membership')
-utool = getToolByName(script, 'portal_url')
+mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/folder_rename_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/folder_rename_form.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/folder_rename_form.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,11 +1,11 @@
##parameters=b_start=0, key='', reverse=0, ids=(), new_ids=(), rename='', 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 _
-utool = getToolByName(script, 'portal_url')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/getBatchItemInfos.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/getBatchItemInfos.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/getBatchItemInfos.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -2,9 +2,9 @@
##parameters=batch_obj
##title=
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
-utool = getToolByName(script, 'portal_url')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()
items = []
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/getMainGlobals.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/getMainGlobals.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/getMainGlobals.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,14 +1,16 @@
##parameters=
##
-from Products.CMFCore.utils import getToolByName
+
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import getBrowserCharset
-atool = getToolByName(script, 'portal_actions')
-mtool = getToolByName(script, 'portal_membership')
-ptool = getToolByName(script, 'portal_properties')
-utool = getToolByName(script, 'portal_url')
-wtool = getToolByName(script, 'portal_workflow')
+atool = getToolByInterfaceName('Products.CMFCore.interfaces.IActionsTool')
+mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
+wtool_iface = 'Products.CMFCore.interfaces.IConfigurableWorkflowTool'
+wtool = getToolByInterfaceName(wtool_iface)
portal_object = utool.getPortalObject()
if not 'charset' in context.REQUEST.RESPONSE.getHeader('content-type'):
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/get_permalink.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/get_permalink.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/get_permalink.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -7,19 +7,22 @@
##parameters=
##title=Returns the permalink url or None
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
# 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( 'Products.CMFUid.interfaces.IUniqueIdHandler'
+ , default=None
+ )
+
if uidtool is not None:
- proptool = getToolByName(context, 'portal_properties', None)
- showPermalink = getattr(proptool, 'enable_permalink', None)
+ ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
+ showPermalink = getattr(ptool, 'enable_permalink', None)
isFolderish = getattr(context.aq_explicit, 'isPrincipiaFolderish', None)
if showPermalink and not isFolderish:
# returns the uid (generates one if necessary)
- urltool = getToolByName(context, 'portal_url')
+ utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
uid = uidtool.register(context)
- url = "%s/permalink/%s" % (urltool(), uid)
+ url = "%s/permalink/%s" % (utool(), uid)
return url
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/join_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/join_form.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/join_form.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,14 +1,14 @@
##parameters=b_start=0, member_id='', member_email='', password='', confirm='', send_password='', add='', cancel=''
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
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')
-utool = getToolByName(script, 'portal_url')
+atool = getToolByInterfaceName('Products.CMFCore.interfaces.IActionsTool')
+mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()
validate_email = ptool.getProperty('validate_email')
is_anon = mtool.isAnonymousUser()
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,13 +1,13 @@
##parameters=
##
-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 _
-mtool = getToolByName(script, 'portal_membership')
-ptool = getToolByName(script, 'portal_properties')
-stool = getToolByName(script, 'portal_skins')
-utool = getToolByName(script, 'portal_url')
+mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
+stool = getToolByInterfaceName('Products.CMFCore.interfaces.ISkinsTool')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/members_delete_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/members_delete_form.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/members_delete_form.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,11 +1,11 @@
##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('Products.CMFCore.interfaces.IActionsTool')
form = context.REQUEST.form
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/members_manage_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/members_manage_form.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/members_manage_form.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,13 +1,13 @@
##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('Products.CMFCore.interfaces.IActionsTool')
+mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
form = context.REQUEST.form
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/news_box.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/news_box.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/news_box.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,10 +1,10 @@
##parameters=
##
from ZTUtils import Batch
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
-ctool = getToolByName(script, 'portal_catalog')
+ctool = getToolByInterfaceName('Products.CMFCore.interfaces.ICatalogTool')
options = {}
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/password_email.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/password_email.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/password_email.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,13 +1,13 @@
##parameters=member=None, password='secret'
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import makeEmail
from Products.CMFDefault.utils import Message as _
-atool = getToolByName(script, 'portal_actions')
-ptool = getToolByName(script, 'portal_properties')
-utool = getToolByName(script, 'portal_url')
+atool = getToolByInterfaceName('Products.CMFCore.interfaces.IActionsTool')
+ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/password_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/password_form.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/password_form.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,13 +1,13 @@
##parameters=change='', cancel=''
##
-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')
-mtool = getToolByName(script, 'portal_membership')
-ptool = getToolByName(script, 'portal_properties')
-utool = getToolByName(script, 'portal_url')
+atool = getToolByInterfaceName('Products.CMFCore.interfaces.IActionsTool')
+mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
member = mtool.getAuthenticatedMember()
portal_url = utool()
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/permalink.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/permalink.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/permalink.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -7,10 +7,10 @@
##parameters=
##title=Returns an object by unique id
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
subpath = traverse_subpath[0]
-uid_handler = getToolByName(context, 'portal_uidhandler', None)
+uid_handler=getToolByInterfaceName('Products.CMFUid.interfaces.UniqueIDHandler')
# appending 'isAvailable' instead of a unique id returns if
# the site permalink feature is available.
@@ -18,8 +18,8 @@
# 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('Products.CMFCore.interfaces.IPropertiesTool')
+ isAvailable = getattr(ptool, 'enable_permalink', 0)
return str(int(isAvailable))
obj = uid_handler.getObject(subpath)
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/recent_news.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/recent_news.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/recent_news.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -2,11 +2,11 @@
##
from Products.PythonScripts.standard import structured_text
from ZTUtils import Batch
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
-ctool = getToolByName(script, 'portal_catalog')
-utool = getToolByName(script, 'portal_url')
+ctool = getToolByInterfaceName('Products.CMFCore.interfaces.ICatalogTool')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/reconfig_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/reconfig_form.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/reconfig_form.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,11 +1,11 @@
##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('Products.CMFCore.interfaces.IActionsTool')
+ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
form = context.REQUEST.form
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/registered_email.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/registered_email.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/registered_email.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,13 +1,13 @@
##parameters=member=None, password='secret', email='foo at example.org'
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import makeEmail
from Products.CMFDefault.utils import Message as _
-atool = getToolByName(script, 'portal_actions')
-ptool = getToolByName(script, 'portal_properties')
-utool = getToolByName(script, 'portal_url')
+atool = getToolByInterfaceName('Products.CMFCore.interfaces.IActionsTool')
+ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/rejectItems.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/rejectItems.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/rejectItems.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -7,10 +7,15 @@
##parameters=items, comment=''
##title=
##
-wf_tool = context.portal_workflow # XXX getToolByName
+
+from Products.CMFCore.utils import getToolByInterfaceName
+
+wtool_iface = 'Products.CMFCore.interfaces.IConfigurableWorkflowTool'
+wtool = getToolByInterfaceName(wtool_iface)
+
for path in items:
object = context.restrictedTraverse( path )
- wf_tool.doActionFor( object, 'reject', comment=comment )
+ wtool.doActionFor( object, 'reject', comment=comment )
context.REQUEST[ 'RESPONSE' ].redirect( '%s/review?%s'
% ( context.portal_url()
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/search.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/search.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/search.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -2,12 +2,12 @@
##
from Products.PythonScripts.standard import thousands_commas
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 Message as _
-ctool = getToolByName(script, 'portal_catalog')
-utool = getToolByName(script, 'portal_url')
+ctool = getToolByInterfaceName('Products.CMFCore.interfaces.ICatalogTool')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()
epoch = DateTime('1970/01/01 00:00:01 GMT')
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/search_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/search_form.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/search_form.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,14 +1,14 @@
##parameters=search=''
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.permissions import ReviewPortalContent
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import Message as _
-ctool = getToolByName(script, 'portal_catalog')
-mtool = getToolByName(script, 'portal_membership')
-ttool = getToolByName(script, 'portal_types')
-utool = getToolByName(script, 'portal_url')
+ctool = getToolByInterfaceName('Products.CMFCore.interfaces.ICatalogTool')
+mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+ttool = getToolByInterfaceName('Products.CMFCore.interfaces.ITypesTool')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/setup_talkback_tree.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/setup_talkback_tree.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/setup_talkback_tree.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -2,12 +2,12 @@
##title=Standard Tree
##
from ZTUtils import SimpleTreeMaker
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.permissions import ManagePortal
from Products.CMFDefault.utils import decode
-mtool = getToolByName(script, 'portal_membership')
-utool = getToolByName(script, 'portal_url')
+mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+utool = getToolByInterfaceName('Products.CMFCore.interfaces.IURLTool')
portal_url = utool()
tm = SimpleTreeMaker('tb_tree')
Modified: CMF/trunk/CMFDefault/skins/zpt_generic/synPropertiesForm.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/synPropertiesForm.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/synPropertiesForm.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -1,11 +1,9 @@
##parameters=
##
-from Products.CMFCore.utils import getToolByName
+from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFDefault.utils import decode
-stool = getToolByName(script, 'portal_syndication')
-
-
+stool = getToolByInterfaceName('Products.CMFCore.interfaces.ISyndicationTool')
options = {}
s_site_allowed = stool.isSiteSyndicationAllowed()
Modified: CMF/trunk/CMFDefault/testing.py
===================================================================
--- CMF/trunk/CMFDefault/testing.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/testing.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -50,3 +50,4 @@
app._delObject('site')
transaction.commit()
ZopeTestCase.close(app)
+
Modified: CMF/trunk/CMFDefault/tests/RegistrationTool.txt
===================================================================
--- CMF/trunk/CMFDefault/tests/RegistrationTool.txt 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/tests/RegistrationTool.txt 2007-03-07 16:41:03 UTC (rev 73035)
@@ -8,7 +8,8 @@
... def getProperty(self, id): return 'foo at example.org'
... def getPassword(self): return 'secret'
- >>> class MembershipTool:
+ >>> from Acquisition import Implicit
+ >>> class MembershipTool(Implicit):
... def getMemberById(self, id): return Member()
>>> class MailHost:
@@ -25,10 +26,16 @@
Now we can set up a RegistrationTool with dummy context::
- >>> from Products.CMFDefault.RegistrationTool import RegistrationTool
- >>> rtool = RegistrationTool()
- >>> rtool.MailHost = MailHost()
- >>> rtool.portal_membership = MembershipTool()
+ >>> from zope.app.component.hooks import setSite
+ >>> from zope.component import getSiteManager
+ >>> from zope.component import getUtility
+ >>> from Products.CMFCore.interfaces import IMembershipTool
+ >>> from Products.MailHost.interfaces import IMailHost
+ >>> setSite(app.site)
+ >>> sm = getSiteManager()
+ >>> sm.registerUtility(MembershipTool(), IMembershipTool)
+ >>> sm.registerUtility(MailHost(), IMailHost)
+ >>> rtool = app.site.portal_registration
>>> rtool.password_email = password_email
>>> rtool.mail_password_response = mail_password_response
>>> rtool.registered_email = registered_email
@@ -38,72 +45,34 @@
>>> rtool.mailPassword('foo', None)
'done'
- >>> rtool.MailHost.lastMessage
+ >>> getUtility(IMailHost).lastMessage
'Reminder: foo, secret'
registeredNotify sends a welcome message::
>>> rtool.registeredNotify('foo')
- >>> rtool.MailHost.lastMessage
+ >>> getUtility(IMailHost).lastMessage
'Welcome: foo, secret, foo at example.org'
+ Now we have to restore the normal MembershipTool::
+
+ >>> sm.registerUtility(app.site.portal_membership, IMembershipTool)
+
password_email and registered_email
-----------------------------------
- First we need some dummy code::
+ First we have to set up some site properties::
- >>> from os.path import join
- >>> from OFS.Folder import Folder
- >>> from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
- >>> from Products.PythonScripts.PythonScript import PythonScript
- >>> class DummySite(Folder):
- ... def getPhysicalRoot(self): return self
- ... def getPhysicalPath(self): return ('root',)
- ... def addResource(self, dir, f_name):
- ... r_name, f_type = f_name.split('.')
- ... if f_type == 'pt': r = ZopePageTemplate(r_name)
- ... if f_type == 'py': r = PythonScript(r_name)
- ... f = file(join(dir, f_name), 'r')
- ... r.write(f.read())
- ... f.close()
- ... setattr(self, r_name, r)
-
- >>> class DummyTool(Folder):
- ... def getActionInfo(self, action_chain): return self.login_action
- ... def getProperty(self, id, d=None): return getattr(self, id, d)
- ... def title(self): return self.Title
- ... def __call__(self): return self.url
-
- And have to set up security::
-
- >>> from AccessControl.SecurityManagement import newSecurityManager
- >>> from AccessControl.User import UnrestrictedUser
- >>> newSecurityManager(None, UnrestrictedUser('god', '', ['Manager'], ''))
-
- Now we can set up password_email and registered_email with dummy context::
-
- >>> from Testing.makerequest import makerequest
- >>> s = makerequest(DummySite())
+ >>> s = app.site
>>> s.REQUEST.environ['HTTP_X_FORWARDED_FOR'] = 'NNN.NNN.NNN.NNN'
- >>> s.portal_actions = s.portal_properties = s.portal_url = DummyTool()
>>> s.ZopeTime = 'NNNN/NN/NN'
>>> s.description = 'THE SITE DESCRIPTION.'
>>> s.default_charset = 'utf-8'
>>> s.email_from_name = u'WEBMASTER \xc4\xd6\xdc'.encode('utf-8')
>>> s.email_from_address = 'WEBMASTER at EXAMPLE.ORG'
- >>> s.Title = 'WWW.EXAMPLE.ORG'
- >>> s.url = 'PORTAL_URL'
- >>> s.login_action = {'url': 'LOGIN_URL'}
+ >>> s.title = 'WWW.EXAMPLE.ORG'
- >>> from os.path import dirname
- >>> from Products import CMFDefault
- >>> dir = join(dirname(CMFDefault.__file__), 'skins', 'zpt_generic')
- >>> s.addResource(dir, 'password_email.py')
- >>> s.addResource(dir, 'password_email_template.pt')
- >>> s.addResource(dir, 'registered_email.py')
- >>> s.addResource(dir, 'registered_email_template.pt')
-
password_email creates a complete reminder email::
>>> s.email_charset = 'iso-8859-1'
@@ -153,7 +122,7 @@
<BLANKLINE>
THE SITE DESCRIPTION.
<BLANKLINE>
- [[cmf_default][Visit us at PORTAL_URL]]
+ [[cmf_default][Visit us at http://nohost/site]]
<BLANKLINE>
[[cmf_default][Here is your login data (mind upper and lower case):]]
<BLANKLINE>
@@ -162,7 +131,7 @@
<BLANKLINE>
[[cmf_default][You can use this URL to log in:]]
<BLANKLINE>
- LOGIN_URL
+ http://nohost/site/login_form
<BLANKLINE>
<BLANKLINE>
WEBMASTER =C4=D6=DC
@@ -180,8 +149,3 @@
<BLANKLINE>
W1tj...
<BLANKLINE>
-
- Finally we have to clean up::
-
- >>> from AccessControl.SecurityManagement import noSecurityManager
- >>> noSecurityManager()
Modified: CMF/trunk/CMFDefault/tests/test_DiscussionReply.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_DiscussionReply.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/tests/test_DiscussionReply.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -19,6 +19,7 @@
from Testing import ZopeTestCase
from AccessControl.SecurityManagement import newSecurityManager
+from zope.app.component.hooks import setSite
from Products.CMFDefault.testing import FunctionalLayer
@@ -28,6 +29,7 @@
layer = FunctionalLayer
def afterSetUp(self):
+ setSite(self.app.site)
self.portal = self.app.site
# Become a Manager
self.uf = self.portal.acl_users
Modified: CMF/trunk/CMFDefault/tests/test_DiscussionTool.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_DiscussionTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/tests/test_DiscussionTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,6 +18,12 @@
import unittest
import Testing
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+
+from Products.CMFCore.interfaces import IDiscussionTool
+from Products.CMFCore.interfaces import IMembershipTool
+from Products.CMFCore.interfaces import ITypesTool
from Products.CMFCore.tests.base.dummy import DummyFolder
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
@@ -32,10 +38,17 @@
def setUp(self):
self.site = DummySite('site')
+ sm = getSiteManager()
self.site._setObject( 'portal_discussion', self._makeOne() )
+ sm.registerUtility(self.site.portal_discussion, IDiscussionTool)
self.site._setObject( 'portal_membership', DummyTool() )
+ sm.registerUtility(self.site.portal_membership, IMembershipTool)
self.site._setObject( 'portal_types', DummyTool() )
+ sm.registerUtility(self.site.portal_types, ITypesTool)
+ def tearDown(self):
+ cleanUp()
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from Products.CMFCore.interfaces.portal_actions \
Modified: CMF/trunk/CMFDefault/tests/test_Discussions.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Discussions.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/tests/test_Discussions.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,7 +18,13 @@
import unittest
import Testing
+from zope.component import getSiteManager
+
from Products.CMFCore.CatalogTool import CatalogTool
+from Products.CMFCore.interfaces import ICatalogTool
+from Products.CMFCore.interfaces import IDiscussionTool
+from Products.CMFCore.interfaces import IMembershipTool
+from Products.CMFCore.interfaces import ITypesTool
from Products.CMFCore.testing import EventZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFCore.tests.base.dummy import DummySite
@@ -28,7 +34,6 @@
from Products.CMFCore.tests.base.utils import has_path
from Products.CMFCore.TypesTool import FactoryTypeInformation as FTI
from Products.CMFCore.TypesTool import TypesTool
-from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.DiscussionTool import DiscussionTool
from Products.CMFDefault.exceptions import DiscussionNotAllowed
@@ -106,9 +111,13 @@
def setUp(self):
SecurityTest.setUp(self)
self.site = DummySite('site').__of__(self.root)
+ sm = getSiteManager()
self.site._setObject( 'portal_discussion', DiscussionTool() )
+ sm.registerUtility(self.site.portal_discussion, IDiscussionTool)
self.site._setObject( 'portal_membership', DummyTool() )
+ sm.registerUtility(self.site.portal_membership, IMembershipTool)
self.site._setObject( 'portal_types', TypesTool() )
+ sm.registerUtility(self.site.portal_types, ITypesTool)
def _makeDummyContent(self, id, *args, **kw):
return self.site._setObject( id, DummyContent(id, *args, **kw) )
@@ -196,7 +205,9 @@
assert parents[ 0 ] == reply1
def test_itemCataloguing( self ):
+ sm = getSiteManager()
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 +269,9 @@
DiscussionItem.notifyWorkflowCreated = old_method
def test_deletePropagation( self ):
+ sm = getSiteManager()
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 +285,10 @@
self.assertEqual( len(ctool), 0 )
def test_deleteReplies(self):
+ sm = getSiteManager()
dtool = self.site.portal_discussion
ctool = self.site._setObject( 'portal_catalog', CatalogTool() )
+ sm.registerUtility(ctool, ICatalogTool)
test = self._makeDummyContent('test')
test.allow_discussion = 1
@@ -325,7 +340,7 @@
talkback = dtool.getDiscussionFor(test)
self.failUnless(hasattr(talkback, 'aq_base'))
# Acquire a portal tool
- self.failUnless(getToolByName(talkback, 'portal_discussion'))
+ self.failUnless(getattr(talkback, 'portal_discussion', None))
def test_existingTalkbackIsWrapped(self):
test = self._makeDummyContent('test')
@@ -335,7 +350,7 @@
talkback = dtool.getDiscussionFor(test)
self.failUnless(hasattr(talkback, 'aq_base'))
# Acquire a portal tool
- self.failUnless(getToolByName(talkback, 'portal_discussion'))
+ self.failUnless(getattr(talkback, 'portal_discussion', None))
def test_suite():
Modified: CMF/trunk/CMFDefault/tests/test_DublinCore.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_DublinCore.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/tests/test_DublinCore.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -22,13 +22,17 @@
from Acquisition import Implicit
from DateTime.DateTime import DateTime
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+
+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
from Products.CMFDefault.MembershipTool import MembershipTool
-
def _DateIndexConvert(value):
# Duplicate date conversion done by DateIndex._convert
t_tup = value.toZone('UTC').parts()
@@ -66,6 +70,10 @@
return DummyContent(id, *args, **kw)
+ def tearDown(self):
+ cleanUp()
+ SecurityTest.tearDown(self)
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from Products.CMFCore.interfaces.DublinCore \
@@ -93,8 +101,10 @@
def test_notifyModified(self):
site = DummySite('site').__of__(self.root)
+ sm = getSiteManager()
acl_users = site._setObject( 'acl_users', DummyUserFolder() )
site._setObject( 'portal_membership', MembershipTool() )
+ sm.registerUtility(site.portal_membership, IMembershipTool)
newSecurityManager(None, acl_users.user_foo)
item = self._makeDummyContent('item').__of__(site)
self.assertEqual( item.listCreators(), () )
@@ -107,8 +117,10 @@
def test_creators_methods(self):
site = DummySite('site').__of__(self.root)
+ sm = getSiteManager()
acl_users = site._setObject( 'acl_users', DummyUserFolder() )
site._setObject( 'portal_membership', MembershipTool() )
+ sm.registerUtility(site.portal_membership, IMembershipTool)
newSecurityManager(None, acl_users.user_foo)
item = self._makeDummyContent('item').__of__(site)
self.assertEqual( item.listCreators(), () )
@@ -130,8 +142,10 @@
def test_creators_upgrade(self):
site = DummySite('site').__of__(self.root)
+ sm = getSiteManager()
acl_users = site._setObject( 'acl_users', DummyUserFolder() )
site._setObject( 'portal_membership', MembershipTool() )
+ sm.registerUtility(site.portal_membership, IMembershipTool)
newSecurityManager(None, acl_users.user_foo)
item = self._makeDummyContent('item').__of__(site)
item.manage_fixupOwnershipAfterAdd()
@@ -163,7 +177,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/trunk/CMFDefault/tests/test_Favorite.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Favorite.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/tests/test_Favorite.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,6 +18,11 @@
import unittest
import Testing
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+
+from Products.CMFCore.interfaces import IMembershipTool
+from Products.CMFCore.interfaces import IURLTool
from Products.CMFCore.testing import ConformsToContent
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
@@ -34,10 +39,16 @@
return self._getTargetClass()(*args, **kw)
def setUp(self):
+ sm = getSiteManager()
self.site = DummySite('site')
self.site._setObject( 'portal_membership', DummyTool() )
+ sm.registerUtility(self.site.portal_membership, IMembershipTool)
self.site._setObject( 'portal_url', DummyTool() )
+ sm.registerUtility(self.site.portal_url, IURLTool)
+ def tearDown(self):
+ cleanUp()
+
def test_z3interfaces(self):
from zope.interface.verify import verifyClass
from Products.CMFDefault.interfaces import IFavorite
Modified: CMF/trunk/CMFDefault/tests/test_File.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_File.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/tests/test_File.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -20,6 +20,10 @@
from os.path import join as path_join
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+
+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
@@ -101,8 +105,19 @@
return TEST_SWF, data
+ def _setupCachingPolicyManager(self, cpm_object):
+ self.root.caching_policy_manager = cpm_object
+ sm = getSiteManager()
+ sm.registerUtility( self.root.caching_policy_manager
+ , ICachingPolicyManager
+ )
+
+ def tearDown(self):
+ cleanUp()
+ RequestTest.tearDown(self)
+
def test_index_html_with_304_from_cpm( self ):
- self.root.caching_policy_manager = DummyCachingManagerWithPolicy()
+ self._setupCachingPolicyManager(DummyCachingManagerWithPolicy())
path, ref = self._extractFile()
from webdav.common import rfc1123_date
@@ -124,7 +139,7 @@
def test_index_html_200_with_cpm( self ):
# should behave the same as without cpm installed
- self.root.caching_policy_manager = DummyCachingManager()
+ self._setupCachingPolicyManager(DummyCachingManager())
path, ref = self._extractFile()
from webdav.common import rfc1123_date
@@ -147,7 +162,7 @@
, rfc1123_date( mod_time ) )
def test_caching( self ):
- self.root.caching_policy_manager = DummyCachingManager()
+ self._setupCachingPolicyManager(DummyCachingManager())
original_len = len(self.RESPONSE.headers)
file = self._makeOne('test_file', 'test_file.swf')
file = file.__of__(self.root)
Modified: CMF/trunk/CMFDefault/tests/test_Image.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Image.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/tests/test_Image.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -21,10 +21,15 @@
from os.path import join as path_join
from cStringIO import StringIO
+from zope.app.component.hooks import setSite
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+
import transaction
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.User import UnrestrictedUser
+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
@@ -119,6 +124,7 @@
layer = FunctionalLayer
def afterSetUp(self):
+ setSite(self.app.site)
newSecurityManager(None, UnrestrictedUser('god', '', ['Manager'], ''))
self.site = self.app.site
@@ -204,8 +210,19 @@
def _makeOne(self, *args, **kw):
return self._getTargetClass()(*args, **kw)
+ def _setupCachingPolicyManager(self, cpm_object):
+ self.root.caching_policy_manager = cpm_object
+ sm = getSiteManager()
+ sm.registerUtility( self.root.caching_policy_manager
+ , ICachingPolicyManager
+ )
+
+ def tearDown(self):
+ cleanUp()
+ RequestTest.tearDown(self)
+
def test_index_html_with_304_from_cpm( self ):
- self.root.caching_policy_manager = DummyCachingManagerWithPolicy()
+ self._setupCachingPolicyManager(DummyCachingManagerWithPolicy())
path, ref = self._extractFile()
from webdav.common import rfc1123_date
@@ -226,7 +243,7 @@
self.assertEqual( self.RESPONSE.getStatus(), 304 )
def test_caching( self ):
- self.root.caching_policy_manager = DummyCachingManager()
+ self._setupCachingPolicyManager(DummyCachingManager())
original_len = len(self.RESPONSE.headers)
image = self._makeOne('test_image', 'test_image.jpg')
image = image.__of__(self.root)
@@ -238,7 +255,7 @@
self.assertEqual(headers['test_path'], '/test_image')
def test_index_html_200_with_cpm( self ):
- self.root.caching_policy_manager = DummyCachingManagerWithPolicy()
+ self._setupCachingPolicyManager(DummyCachingManagerWithPolicy())
path, ref = self._extractFile()
from webdav.common import rfc1123_date
@@ -264,7 +281,7 @@
def test_index_html_with_304_and_caching( self ):
# See collector #355
- self.root.caching_policy_manager = DummyCachingManager()
+ self._setupCachingPolicyManager(DummyCachingManager())
original_len = len(self.RESPONSE.headers)
path, ref = self._extractFile()
Modified: CMF/trunk/CMFDefault/tests/test_MembershipTool.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_MembershipTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/tests/test_MembershipTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -20,6 +20,11 @@
from AccessControl.SecurityManagement import newSecurityManager
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+
+from Products.CMFCore.interfaces import IConfigurableWorkflowTool
+from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.PortalFolder import PortalFolder
from Products.CMFCore.tests.base.dummy import DummyFolder
from Products.CMFCore.tests.base.dummy import DummySite
@@ -84,11 +89,17 @@
self.site = DummySite('site').__of__(self.root)
self.site._setObject( 'portal_membership', self._makeOne() )
+ def tearDown(self):
+ cleanUp()
+ SecurityTest.tearDown(self)
+
def test_createMemberArea(self):
mtool = self.site.portal_membership
members = self.site._setObject( 'Members', PortalFolder('Members') )
acl_users = self.site._setObject( 'acl_users', DummyUserFolder() )
wtool = self.site._setObject( 'portal_workflow', DummyTool() )
+ sm = getSiteManager()
+ sm.registerUtility(self.site.portal_workflow, IConfigurableWorkflowTool)
# permission
mtool.createMemberArea('user_foo')
Modified: CMF/trunk/CMFDefault/tests/test_Portal.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Portal.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/tests/test_Portal.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -21,6 +21,7 @@
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.User import UnrestrictedUser
from Acquisition import aq_base
+from zope.app.component.hooks import setSite
from Products.CMFDefault.testing import FunctionalLayer
@@ -40,6 +41,9 @@
return content
+ def afterSetUp(self):
+ setSite(self.app.site)
+
def test_new( self ):
site = self.app.site
Modified: CMF/trunk/CMFDefault/tests/test_RegistrationTool.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_RegistrationTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/tests/test_RegistrationTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,11 +18,16 @@
import unittest
from Testing import ZopeTestCase
+from Acquisition import Implicit
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+
+from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.tests.base.testcase import RequestTest
from Products.CMFDefault.testing import FunctionalLayer
-class FauxMembershipTool:
+class FauxMembershipTool(Implicit):
def getMemberById( self, username ):
return None
@@ -38,6 +43,10 @@
def _makeOne(self, *args, **kw):
return self._getTargetClass()(*args, **kw)
+ def tearDown(self):
+ cleanUp()
+ RequestTest.tearDown(self)
+
def test_z2interfaces(self):
from Interface.Verify import verifyClass
from Products.CMFCore.interfaces.portal_actions \
@@ -67,14 +76,16 @@
Spam, spam, spam
"""
- tool = self._makeOne().__of__( self.root )
- self.root.portal_membership = FauxMembershipTool()
+ rtool = self._makeOne()
+ mtool = FauxMembershipTool()
+ sm = getSiteManager()
+ sm.registerUtility(mtool, IMembershipTool)
props = { 'email' : INJECTED_HEADERS
, 'username' : 'username'
}
- result = tool.testPropertiesValidity( props, None )
+ result = rtool.testPropertiesValidity(props, None)
self.failIf( result is None, 'Invalid e-mail passed inspection' )
Modified: CMF/trunk/CMFDefault/tests/test_SyndicationTool.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_SyndicationTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/tests/test_SyndicationTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -20,6 +20,10 @@
from DateTime.DateTime import DateTime
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+
+from Products.CMFCore.interfaces import ITypesTool
from Products.CMFCore.tests.base.testcase import SecurityTest
@@ -38,6 +42,10 @@
def _makeOne(self, *args, **kw):
return self._getTargetClass()(*args, **kw)
+ def tearDown(self):
+ cleanUp()
+ SecurityTest.tearDown(self)
+
def test_empty(self):
ONE_MINUTE = (24.0 * 60.0) / 86400
@@ -163,12 +171,14 @@
from Products.CMFCore.PortalFolder import PortalFolder
from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder
from Products.CMFCore.TypesTool import TypesTool
+ sm = getSiteManager()
PERIOD = 'hourly'
FREQUENCY = 4
NOW = DateTime()
MAX_ITEMS = 42
self.root._setObject( 'portal_types', TypesTool() )
+ sm.registerUtility(self.root.portal_types, ITypesTool)
self.root._setObject('pf', PortalFolder('pf'))
self.root._setObject('bf', CMFBTreeFolder('bf'))
self.root._setObject('portal_syndication', self._makeOne())
Modified: CMF/trunk/CMFDefault/tests/test_join.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_join.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/tests/test_join.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,6 +18,8 @@
import unittest
from Testing import ZopeTestCase
+from zope.app.component.hooks import setSite
+
from Products.CMFDefault.testing import FunctionalLayer
@@ -25,6 +27,9 @@
layer = FunctionalLayer
+ def afterSetUp(self):
+ setSite(self.app.site)
+
def test_join( self ):
site = self.app.site
member_id = 'test_user'
Modified: CMF/trunk/CMFDefault/utils.py
===================================================================
--- CMF/trunk/CMFDefault/utils.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFDefault/utils.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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)
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)
email_charset = ptool.getProperty('email_charset', None) or 'utf-8'
try:
msg = MIMEText(mtext.encode(), 'plain')
Modified: CMF/trunk/CMFTopic/Topic.py
===================================================================
--- CMF/trunk/CMFTopic/Topic.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFTopic/Topic.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,11 +18,14 @@
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.utils import getToolByName
+from Products.CMFCore.interfaces import ICatalogTool
+from Products.CMFCore.interfaces import ISyndicationTool
from interfaces import IMutableTopic
from interfaces import ITopic
@@ -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')
@@ -150,7 +153,7 @@
o Return no more brain objects than the limit set by the
syndication tool.
"""
- syn_tool = getToolByName( self, 'portal_syndication' )
+ syn_tool = getUtility(ISyndicationTool)
limit = syn_tool.getMaxItems( self )
brains = self.queryCatalog( sort_limit=limit )[ :limit ]
return [ brain.getObject() for brain in brains ]
Modified: CMF/trunk/CMFTopic/tests/test_DateC.py
===================================================================
--- CMF/trunk/CMFTopic/tests/test_DateC.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFTopic/tests/test_DateC.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -19,6 +19,7 @@
from Testing import ZopeTestCase
from DateTime.DateTime import DateTime
+from zope.app.component.hooks import setSite
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFDefault.testing import FunctionalLayer
@@ -160,6 +161,7 @@
day_diffs.extend(selectable_diffs)
def afterSetUp(self):
+ setSite(self.app.site)
self.site = self.app.site
self.site._setObject( 'topic', Topic('topic') )
self.topic = self.site.topic
Modified: CMF/trunk/CMFTopic/tests/test_Topic.py
===================================================================
--- CMF/trunk/CMFTopic/tests/test_Topic.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFTopic/tests/test_Topic.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -21,6 +21,11 @@
from Acquisition import Implicit
+from zope.component import getSiteManager
+
+from Products.CMFCore.interfaces import ICatalogTool
+from Products.CMFCore.interfaces import ISyndicationTool
+from Products.CMFCore.interfaces import ITypesTool
from Products.CMFCore.testing import ConformsToFolder
from Products.CMFCore.testing import EventZCMLLayer
from Products.CMFCore.tests.base.dummy import DummySite
@@ -62,7 +67,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 +85,8 @@
indexObject = _index
+ reindexObject = _index
+
def searchResults( self, REQUEST=None, **kw ):
limit = None
@@ -136,8 +143,11 @@
self._getTargetClass()(id, *args, **kw))
def _initSite(self, max_items=15, index_ids=()):
+ sm = getSiteManager()
self.site.portal_catalog = DummyCatalog( index_ids )
+ sm.registerUtility(self.site.portal_catalog, ICatalogTool)
self.site.portal_syndication = DummySyndicationTool( max_items )
+ sm.registerUtility(self.site.portal_syndication, ISyndicationTool)
def _initDocuments(self, **kw):
for k, v in kw.items():
@@ -194,7 +204,9 @@
self.assertEqual( query[ 'baz' ], 43 )
def test_Nested( self ):
+ sm = getSiteManager()
self.site._setObject( 'portal_types', TypesTool() )
+ sm.registerUtility(self.site.portal_types, ITypesTool)
self.site.portal_types._setObject('Topic', FTI(id='Topic',
product='CMFTopic', factory='addTopic'))
topic = self._makeOne('top')
Modified: CMF/trunk/CMFUid/UniqueIdAnnotationTool.py
===================================================================
--- CMF/trunk/CMFUid/UniqueIdAnnotationTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFUid/UniqueIdAnnotationTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFUid/UniqueIdGeneratorTool.py
===================================================================
--- CMF/trunk/CMFUid/UniqueIdGeneratorTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFUid/UniqueIdGeneratorTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFUid/UniqueIdHandlerTool.py
===================================================================
--- CMF/trunk/CMFUid/UniqueIdHandlerTool.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFUid/UniqueIdHandlerTool.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -27,14 +27,19 @@
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 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
@@ -80,7 +85,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)
@@ -92,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)
@@ -106,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)
@@ -176,10 +181,10 @@
return default
# convert the uid to the right format
- generator = getToolByName(self, 'portal_uidgenerator')
+ generator = getUtility(IUniqueIdGenerator)
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)
@@ -260,3 +265,5 @@
manage_queryObject = PageTemplateFile('queryUID.pt', _wwwdir)
InitializeClass(UniqueIdHandlerTool)
+registerToolInterface('portal_uidhandler', IUniqueIdHandler)
+
Copied: CMF/trunk/CMFUid/profiles/default/componentregistry.xml (from rev 73020, CMF/branches/jens_tools_as_utilities/CMFUid/profiles/default/componentregistry.xml)
Modified: CMF/trunk/CMFUid/tests/test_uidannotation.py
===================================================================
--- CMF/trunk/CMFUid/tests/test_uidannotation.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFUid/tests/test_uidannotation.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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/trunk/CMFUid/tests/test_uidhandling.py
===================================================================
--- CMF/trunk/CMFUid/tests/test_uidhandling.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/CMFUid/tests/test_uidhandling.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,10 +18,17 @@
import unittest
import Testing
+from zope.component import getSiteManager
+from zope.testing.cleanup import cleanUp
+
+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
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:
@@ -51,6 +58,18 @@
self.root._setObject('dummy', DummyContent(id='dummy'))
self.root._setObject('dummy2', DummyContent(id='dummy2'))
+ 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 tearDown(self):
+ cleanUp()
+ SecurityTest.tearDown(self)
+
def test_z3interfaces(self):
from zope.interface.verify import verifyClass
from Products.CMFUid.interfaces import IUniqueIdBrainQuery
Modified: CMF/trunk/DCWorkflow/DCWorkflow.py
===================================================================
--- CMF/trunk/DCWorkflow/DCWorkflow.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/DCWorkflow/DCWorkflow.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -25,14 +25,16 @@
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
from zope.event import notify
# 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
@@ -231,7 +233,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/trunk/DCWorkflow/Expression.py
===================================================================
--- CMF/trunk/DCWorkflow/Expression.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/DCWorkflow/Expression.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -122,7 +122,7 @@
'container': container,
'folder': container,
'nothing': None,
- 'root': wf.getPhysicalRoot(),
+ 'root': ob.getPhysicalRoot(),
'request': getattr( ob, 'REQUEST', None ),
'modules': SecureModuleImporter,
'user': getSecurityManager().getUser(),
Modified: CMF/trunk/DCWorkflow/browser/workflow.py
===================================================================
--- CMF/trunk/DCWorkflow/browser/workflow.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/DCWorkflow/browser/workflow.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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
Modified: CMF/trunk/DCWorkflow/tests/test_DCWorkflow.py
===================================================================
--- CMF/trunk/DCWorkflow/tests/test_DCWorkflow.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/DCWorkflow/tests/test_DCWorkflow.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -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
@@ -30,6 +31,8 @@
class DCWorkflowDefinitionTests(unittest.TestCase):
+ layer = TraversingZCMLLayer
+
def setUp(self):
self.site = DummySite('site')
self.site._setObject( 'portal_types', DummyTool() )
Modified: CMF/trunk/DCWorkflow/tests/test_exportimport.py
===================================================================
--- CMF/trunk/DCWorkflow/tests/test_exportimport.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/DCWorkflow/tests/test_exportimport.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -18,6 +18,8 @@
import unittest
import Testing
+from zope.component import getSiteManager
+
from Products.PythonScripts.PythonScript import PythonScript
from Products.ExternalMethod.ExternalMethod import ExternalMethod
@@ -29,6 +31,7 @@
import _WorkflowSetup as WorkflowSetupBase
from Products.CMFCore.exportimport.tests.test_workflow \
import DummyWorkflowTool
+from Products.CMFCore.interfaces import IConfigurableWorkflowTool
from Products.CMFCore.testing import DummyWorkflow
from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
from Products.DCWorkflow.testing import ExportImportZCMLLayer
@@ -75,7 +78,9 @@
def _initDCWorkflow( self, workflow_id ):
+ sm = getSiteManager()
wf_tool = self.root.site.portal_workflow
+ sm.registerUtility(wf_tool, IConfigurableWorkflowTool)
wf_tool._setObject( workflow_id, DCWorkflowDefinition( workflow_id ) )
return wf_tool._getOb( workflow_id )
Modified: CMF/trunk/DCWorkflow/tests/test_guard.py
===================================================================
--- CMF/trunk/DCWorkflow/tests/test_guard.py 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/DCWorkflow/tests/test_guard.py 2007-03-07 16:41:03 UTC (rev 73035)
@@ -206,7 +206,8 @@
# Create compulsory context elements
sm = getSecurityManager()
- ob = DummyContent('dummy')
+ self.site._setObject('dummy', DummyContent('dummy'))
+ ob = self.site.dummy
wf_def = self._getDummyWorkflow()
# Initialize the guard with an ok guard
@@ -238,7 +239,8 @@
# Create compulsory context elements
sm = getSecurityManager()
- ob = DummyContent('dummy')
+ self.site._setObject('dummy', DummyContent('dummy'))
+ ob = self.site.dummy
wf_def = self._getDummyWorkflow()
# Initialize the guard with an ok guard
Modified: CMF/trunk/INSTALL.txt
===================================================================
--- CMF/trunk/INSTALL.txt 2007-03-07 16:40:16 UTC (rev 73034)
+++ CMF/trunk/INSTALL.txt 2007-03-07 16:41:03 UTC (rev 73035)
@@ -61,6 +61,23 @@
site creation.
+Important Note for users upgrading existing CMF instances to CMF 2.1
+
+ In order to make CMF instances created in CMF versions prior to CMF 2.1
+ work, you need to run a separate one-time upgrade script. After putting the
+ new code in place as instructed above, please change into your instance
+ home and execute the following as the user normally running this Zope
+ instance:
+
+ ./bin/zopectl run Products/CMFCore/Extensions/migrateToCMF21.py
+
+ The script will print some diagnostic information to the console and
+ inform you about CMF sites it finds and upgrades. Once the script has
+ finished, you can start and use your Zope instance as before. This script
+ only needs to be run a single time when you start using a CMF version
+ 2.1.0-beta or higher.
+
+
Installing Translations for CMF
Assumptions
More information about the CMF-checkins
mailing list