[CMF-checkins] SVN: CMF/branches/2.1/CMF - 5 more tools are no
longer registered as utilities
Yvo Schubbe
y.2007- at wcm-solutions.de
Tue Jun 26 16:36:27 EDT 2007
Log message for revision 77113:
- 5 more tools are no longer registered as utilities
Changed:
U CMF/branches/2.1/CMFCore/ActionInformation.py
U CMF/branches/2.1/CMFCore/CachingPolicyManager.py
U CMF/branches/2.1/CMFCore/DiscussionTool.py
U CMF/branches/2.1/CMFCore/Expression.py
U CMF/branches/2.1/CMFCore/MemberDataTool.py
U CMF/branches/2.1/CMFCore/MembershipTool.py
U CMF/branches/2.1/CMFCore/RegistrationTool.py
U CMF/branches/2.1/CMFCore/SkinsTool.py
U CMF/branches/2.1/CMFCore/exportimport/cachingpolicymgr.py
U CMF/branches/2.1/CMFCore/exportimport/tests/test_cachingpolicymgr.py
U CMF/branches/2.1/CMFCore/tests/test_ActionInformation.py
U CMF/branches/2.1/CMFCore/tests/test_ActionProviderBase.py
U CMF/branches/2.1/CMFCore/tests/test_ActionsTool.py
U CMF/branches/2.1/CMFCore/tests/test_CachingPolicyManager.py
U CMF/branches/2.1/CMFCore/tests/test_DynamicType.py
U CMF/branches/2.1/CMFCore/tests/test_Expression.py
U CMF/branches/2.1/CMFCore/tests/test_FSDTMLMethod.py
U CMF/branches/2.1/CMFCore/tests/test_FSPageTemplate.py
U CMF/branches/2.1/CMFCore/tests/test_FSReSTMethod.py
U CMF/branches/2.1/CMFCore/tests/test_FSSTXMethod.py
U CMF/branches/2.1/CMFCore/tests/test_MemberDataTool.py
U CMF/branches/2.1/CMFCore/tests/test_MembershipTool.py
U CMF/branches/2.1/CMFCore/utils.py
U CMF/branches/2.1/CMFDefault/DefaultWorkflow.py
U CMF/branches/2.1/CMFDefault/DiscussionItem.py
U CMF/branches/2.1/CMFDefault/DiscussionTool.py
U CMF/branches/2.1/CMFDefault/DublinCore.py
U CMF/branches/2.1/CMFDefault/RegistrationTool.py
U CMF/branches/2.1/CMFDefault/browser/folder.py
U CMF/branches/2.1/CMFDefault/browser/folder.txt
U CMF/branches/2.1/CMFDefault/browser/metadata.py
U CMF/branches/2.1/CMFDefault/browser/utils.py
U CMF/branches/2.1/CMFDefault/factory.py
U CMF/branches/2.1/CMFDefault/profiles/default/componentregistry.xml
U CMF/branches/2.1/CMFDefault/skins/zpt_content/metadata_edit_control.py
U CMF/branches/2.1/CMFDefault/skins/zpt_control/addtoFavorites.py
U CMF/branches/2.1/CMFDefault/skins/zpt_control/change_password.py
U CMF/branches/2.1/CMFDefault/skins/zpt_control/folder_localrole_edit.py
U CMF/branches/2.1/CMFDefault/skins/zpt_control/members_add_control.py
U CMF/branches/2.1/CMFDefault/skins/zpt_control/members_delete_control.py
U CMF/branches/2.1/CMFDefault/skins/zpt_control/portal_config_control.py
U CMF/branches/2.1/CMFDefault/skins/zpt_control/validatePassword.py
U CMF/branches/2.1/CMFDefault/skins/zpt_generic/discitem_delete.py
U CMF/branches/2.1/CMFDefault/skins/zpt_generic/discussion_reply.py
U CMF/branches/2.1/CMFDefault/skins/zpt_generic/folder_contents.py
U CMF/branches/2.1/CMFDefault/skins/zpt_generic/getMainGlobals.py
U CMF/branches/2.1/CMFDefault/skins/zpt_generic/join_form.py
U CMF/branches/2.1/CMFDefault/skins/zpt_generic/logged_in.py
U CMF/branches/2.1/CMFDefault/skins/zpt_generic/members_manage_form.py
U CMF/branches/2.1/CMFDefault/skins/zpt_generic/password_form.py
U CMF/branches/2.1/CMFDefault/skins/zpt_generic/search_form.py
U CMF/branches/2.1/CMFDefault/skins/zpt_generic/setup_talkback_tree.py
U CMF/branches/2.1/CMFDefault/tests/RegistrationTool.txt
U CMF/branches/2.1/CMFDefault/tests/test_DiscussionTool.py
U CMF/branches/2.1/CMFDefault/tests/test_Discussions.py
U CMF/branches/2.1/CMFDefault/tests/test_DublinCore.py
U CMF/branches/2.1/CMFDefault/tests/test_Favorite.py
U CMF/branches/2.1/CMFDefault/tests/test_File.py
U CMF/branches/2.1/CMFDefault/tests/test_Image.py
U CMF/branches/2.1/CMFDefault/tests/test_RegistrationTool.py
-=-
Modified: CMF/branches/2.1/CMFCore/ActionInformation.py
===================================================================
--- CMF/branches/2.1/CMFCore/ActionInformation.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/ActionInformation.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -24,8 +24,6 @@
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
@@ -33,10 +31,10 @@
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 getToolByName
_unchanged = [] # marker
@@ -502,7 +500,7 @@
def __init__( self, tool, folder, object=None ):
self.portal = portal = aq_parent(aq_inner(tool))
- membership = getUtility(IMembershipTool)
+ membership = getToolByName(tool, 'portal_membership')
self.isAnonymous = membership.isAnonymousUser()
self.user_id = membership.getAuthenticatedMember().getId()
self.portal_url = portal.absolute_url()
Modified: CMF/branches/2.1/CMFCore/CachingPolicyManager.py
===================================================================
--- CMF/branches/2.1/CMFCore/CachingPolicyManager.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/CachingPolicyManager.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -29,9 +29,7 @@
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
@@ -39,12 +37,12 @@
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 :(
@@ -64,7 +62,7 @@
Construct an expression context for TALES expressions,
for use by CachingPolicy objects.
"""
- pm = queryUtility(IMembershipTool)
+ pm = getToolByName( content, 'portal_membership', None )
if not pm or pm.isAnonymousUser():
member = None
else:
@@ -830,6 +828,8 @@
Return a list of HTTP caching headers based on 'content',
'view_method', and 'keywords'.
"""
+ # XXX: this method violates the rules for tools/utilities:
+ # createCPContext depends on a non-utility tool
context = createCPContext( content, view_method, keywords, time=time )
for policy_id, policy in self.listPolicies():
@@ -846,6 +846,8 @@
set_last_modified_header), where modification_time is a DateTime,
or None.
"""
+ # XXX: this method violates the rules for tools/utilities:
+ # createCPContext depends on a non-utility tool
context = createCPContext( content, view_method, keywords, time=time )
for policy_id, policy in self.listPolicies():
if policy.getEnable304s() and policy.testPredicate(context):
@@ -881,6 +883,7 @@
InitializeClass( CachingPolicyManager )
registerToolInterface('caching_policy_manager', ICachingPolicyManager)
+
def handleCachingPolicyManagerEvent(ob, event):
""" Event subscriber for (un)registering a CPM as CacheManager
"""
Modified: CMF/branches/2.1/CMFCore/DiscussionTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/DiscussionTool.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/DiscussionTool.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -23,11 +23,9 @@
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 IOldstyleDiscussable
from interfaces import IOldstyleDiscussionTool
from interfaces.Discussions import OldDiscussable as z2IOldstyleDiscussable
@@ -72,7 +70,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 = getUtility(IMembershipTool)
+ membershiptool = getToolByName(self.content, 'portal_membership')
home = membershiptool.getHomeFolder()
if not hasattr(home, 'Correspondence'):
home.manage_addPortalFolder('Correspondence')
Modified: CMF/branches/2.1/CMFCore/Expression.py
===================================================================
--- CMF/branches/2.1/CMFCore/Expression.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/Expression.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -19,12 +19,9 @@
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 interfaces import IMembershipTool
from utils import getToolByName
@@ -90,7 +87,7 @@
'''
An expression context provides names for TALES expressions.
'''
- pm = getUtility(IMembershipTool)
+ pm = getToolByName(portal, 'portal_membership')
if object is None:
object_url = ''
else:
Modified: CMF/branches/2.1/CMFCore/MemberDataTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/MemberDataTool.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/MemberDataTool.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -22,17 +22,12 @@
from Globals import InitializeClass
from OFS.PropertyManager import PropertyManager
from OFS.SimpleItem import SimpleItem
+from zope.interface import implements
from ZPublisher.Converters import type_converters
-from zope.component import getUtility
-from zope.component import queryUtility
-from zope.interface import implements
-
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
@@ -40,6 +35,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
@@ -97,7 +93,9 @@
Return the number of members stored in the _members
BTree and some other useful info
'''
- membertool = getUtility(IMembershipTool)
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
+ membertool = getToolByName(self, 'portal_membership')
members = self._members
user_list = membertool.listMemberIds()
member_list = members.keys()
@@ -114,12 +112,14 @@
security.declarePrivate('searchMemberData')
def searchMemberData(self, search_param, search_term, attributes=()):
""" Search members. """
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
res = []
if not search_param:
return res
- membership = getUtility(IMembershipTool)
+ membership = getToolByName(self, 'portal_membership')
if len(attributes) == 0:
attributes = ('id', 'email')
@@ -150,12 +150,14 @@
security.declarePrivate( 'searchMemberDataContents' )
def searchMemberDataContents( self, search_param, search_term ):
""" Search members. This method will be deprecated soon. """
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
res = []
if search_param == 'username':
search_param = 'id'
- mtool = getUtility(IMembershipTool)
+ mtool = getToolByName(self, 'portal_membership')
for member_id in self._members.keys():
@@ -177,7 +179,9 @@
def pruneMemberDataContents(self):
""" Delete data contents of all members not listet in acl_users.
"""
- membertool = getUtility(IMembershipTool)
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
+ membertool = getToolByName(self, 'portal_membership')
members = self._members
user_list = membertool.listMemberIds()
@@ -277,10 +281,12 @@
Accepts either keyword arguments or a mapping for the "properties"
argument.
'''
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
if properties is None:
properties = kw
- membership = getUtility(IMembershipTool)
- registration = queryUtility(IRegistrationTool)
+ membership = getToolByName(self, 'portal_membership')
+ registration = getToolByName(self, 'portal_registration', None)
if not membership.isAnonymousUser():
member = membership.getAuthenticatedMember()
if registration:
Modified: CMF/branches/2.1/CMFCore/MembershipTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/MembershipTool.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/MembershipTool.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -15,6 +15,7 @@
$Id$
"""
import logging
+from warnings import warn
from AccessControl import ClassSecurityInfo
from AccessControl.User import nobody
@@ -28,14 +29,11 @@
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 exceptions import AccessControl_Unauthorized
from exceptions import BadRequest
-from interfaces import IMemberDataTool
from interfaces import IMembershipTool
-from interfaces import IRegistrationTool
from interfaces import ISiteRoot
from interfaces.portal_membership \
import portal_membership as z2IMembershipTool
@@ -49,6 +47,7 @@
from utils import _checkPermission
from utils import _dtmldir
from utils import _getAuthenticatedUser
+from utils import getToolByName
from utils import UniqueObject
from utils import postonly
@@ -97,7 +96,9 @@
def setPassword(self, password, domains=None, REQUEST=None):
'''Allows the authenticated member to set his/her own password.
'''
- registration = queryUtility(IRegistrationTool)
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
+ registration = getToolByName(self, 'portal_registration', None)
if not self.isAnonymousUser():
member = self.getAuthenticatedMember()
if registration:
@@ -127,6 +128,8 @@
Provides an opportunity for a portal_memberdata tool to retrieve and
store member data independently of the user object.
"""
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
b = getattr(u, 'aq_base', None)
if b is None:
# u isn't wrapped at all. Wrap it in self.acl_users.
@@ -145,7 +148,7 @@
portal_role not in u.roles):
u.roles.append(portal_role)
- mdtool = queryUtility(IMemberDataTool)
+ mdtool = getToolByName(self, 'portal_memberdata', None)
if mdtool is not None:
try:
u = mdtool.wrapUser(u)
@@ -330,8 +333,13 @@
Note that this call should *not* cause any change at all to user
databases.
'''
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on self.REQUEST
if REQUEST is None:
- raise TypeError('new REQUEST argument required')
+ REQUEST = self.REQUEST
+ warn("credentialsChanged should be called with 'REQUEST' as "
+ "second argument. The BBB code will be removed in CMF 2.3.",
+ DeprecationWarning, stacklevel=2)
if not self.isAnonymousUser():
acl_users = self.acl_users
@@ -411,7 +419,9 @@
security.declareProtected(ListPortalMembers, 'searchMembers')
def searchMembers( self, search_param, search_term ):
""" Search the membership """
- md = getUtility(IMemberDataTool)
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
+ md = getToolByName( self, 'portal_memberdata' )
return md.searchMemberData( search_param, search_term )
@@ -497,6 +507,8 @@
delete_localroles=1, REQUEST=None):
""" Delete members specified by member_ids.
"""
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
# Delete members in acl_users.
acl_users = self.acl_users
@@ -517,7 +529,7 @@
'permission for the underlying User Folder.')
# Delete member data in portal_memberdata.
- mdtool = queryUtility(IMemberDataTool)
+ mdtool = getToolByName(self, 'portal_memberdata', None)
if mdtool is not None:
for member_id in member_ids:
mdtool.deleteMemberData(member_id)
Modified: CMF/branches/2.1/CMFCore/RegistrationTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/RegistrationTool.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/RegistrationTool.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -22,11 +22,8 @@
from Globals import DTMLFile
from Globals import InitializeClass
from OFS.SimpleItem import SimpleItem
-
-from zope.component import getUtility
from zope.interface import implements
-from interfaces import IMembershipTool
from interfaces import IRegistrationTool
from interfaces.portal_registration \
import portal_registration as z2IRegistrationTool
@@ -36,6 +33,7 @@
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
from utils import postonly
@@ -144,6 +142,8 @@
role that can always be granted); these conditions should be
detected before the fact so that a cleaner message can be printed.
'''
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
if not self.isMemberIdAllowed(id):
raise ValueError(_(u'The login name you selected is already in '
u'use or is not valid. Please choose another.'))
@@ -161,7 +161,7 @@
# Anyone is always allowed to grant the 'Member' role.
_limitGrantedRoles(roles, self, ('Member',))
- membership = getUtility(IMembershipTool)
+ membership = getToolByName(self, 'portal_membership')
membership.addMember(id, password, roles, domains, properties)
member = membership.getMemberById(id)
@@ -173,11 +173,13 @@
def isMemberIdAllowed(self, id):
'''Returns 1 if the ID is not in use and is not reserved.
'''
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
if len(id) < 1 or id == 'Anonymous User':
return 0
if not self._ALLOWED_MEMBER_ID_PATTERN.match( id ):
return 0
- membership = getUtility(IMembershipTool)
+ membership = getToolByName(self, 'portal_membership')
if membership.getMemberById(id) is not None:
return 0
return 1
Modified: CMF/branches/2.1/CMFCore/SkinsTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/SkinsTool.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/SkinsTool.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -27,14 +27,12 @@
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.portal_skins import portal_skins as z2ISkinsTool
from permissions import AccessContentsInformation
@@ -308,7 +306,7 @@
"""
# XXX: this method violates the rules for tools/utilities:
# it depends on a non-utility tool and uses self.REQUEST
- mtool = getUtility(IMembershipTool)
+ mtool = getToolByName(self, 'portal_membership')
utool = getToolByName(self, 'portal_url')
member = mtool.getAuthenticatedMember()
if hasattr(aq_base(member), 'getProperty'):
Modified: CMF/branches/2.1/CMFCore/exportimport/cachingpolicymgr.py
===================================================================
--- CMF/branches/2.1/CMFCore/exportimport/cachingpolicymgr.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/exportimport/cachingpolicymgr.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -16,7 +16,6 @@
"""
from zope.component import adapts
-from zope.component import getSiteManager
from zope.component import queryMultiAdapter
from Products.GenericSetup.interfaces import INode
@@ -28,6 +27,7 @@
from Products.CMFCore.interfaces import ICachingPolicy
from Products.CMFCore.interfaces import ICachingPolicyManager
+from Products.CMFCore.utils import getToolByName
class CachingPolicyNodeAdapter(NodeAdapterBase):
@@ -172,16 +172,16 @@
def importCachingPolicyManager(context):
"""Import caching policy manager settings from an XML file.
"""
- sm = getSiteManager(context.getSite())
- tool = sm.getUtility(ICachingPolicyManager)
+ site = context.getSite()
+ tool = getToolByName(site, 'caching_policy_manager')
importObjects(tool, '', context)
def exportCachingPolicyManager(context):
"""Export caching policy manager settings as an XML file.
"""
- sm = getSiteManager(context.getSite())
- tool = sm.queryUtility(ICachingPolicyManager)
+ site = context.getSite()
+ tool = getToolByName(site, 'caching_policy_manager', None)
if tool is None:
logger = context.getLogger('cachingpolicies')
logger.info('Nothing to export.')
Modified: CMF/branches/2.1/CMFCore/exportimport/tests/test_cachingpolicymgr.py
===================================================================
--- CMF/branches/2.1/CMFCore/exportimport/tests/test_cachingpolicymgr.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/exportimport/tests/test_cachingpolicymgr.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -26,11 +26,8 @@
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"
@@ -131,9 +128,6 @@
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/branches/2.1/CMFCore/tests/test_ActionInformation.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_ActionInformation.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/tests/test_ActionInformation.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -21,11 +21,8 @@
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
@@ -219,9 +216,7 @@
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
@@ -335,9 +330,7 @@
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/branches/2.1/CMFCore/tests/test_ActionProviderBase.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_ActionProviderBase.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/tests/test_ActionProviderBase.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -18,10 +18,8 @@
import unittest
import Testing
-from zope.component import getSiteManager
from zope.testing.cleanup import cleanUp
-from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
from Products.CMFCore.tests.base.testcase import SecurityRequestTest
@@ -66,9 +64,8 @@
def setUp(self):
SecurityRequestTest.setUp(self)
self.site = DummySite('site').__of__(self.root)
- sm = getSiteManager()
utool = self.site._setObject( 'portal_url', DummyTool() )
- sm.registerUtility(DummyTool(), IMembershipTool)
+ mtool = self.site._setObject( 'portal_membership', DummyTool() )
def tearDown(self):
cleanUp()
Modified: CMF/branches/2.1/CMFCore/tests/test_ActionsTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_ActionsTool.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/tests/test_ActionsTool.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -25,7 +25,6 @@
from Products.CMFCore.ActionInformation import ActionCategory
from Products.CMFCore.ActionInformation import ActionInformation
from Products.CMFCore.Expression import Expression
-from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.MembershipTool import MembershipTool
from Products.CMFCore.tests.base.testcase import SecurityRequestTest
@@ -118,7 +117,6 @@
root._setObject( 'portal_url', URLTool() )
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',)
Modified: CMF/branches/2.1/CMFCore/tests/test_CachingPolicyManager.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_CachingPolicyManager.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/tests/test_CachingPolicyManager.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -27,11 +27,9 @@
from App.Common import rfc1123_date
from DateTime.DateTime import DateTime
from OFS.Cache import Cacheable
-from zope.component import getSiteManager
from Products.CMFCore.FSDTMLMethod import FSDTMLMethod
from Products.CMFCore.FSPageTemplate import FSPageTemplate
-from Products.CMFCore.interfaces import ICachingPolicyManager
from Products.CMFCore.testing import FunctionalZCMLLayer
from Products.CMFCore.testing import TraversingZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyContent
@@ -681,9 +679,6 @@
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',
@@ -907,11 +902,6 @@
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)
@@ -1232,9 +1222,6 @@
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/branches/2.1/CMFCore/tests/test_DynamicType.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_DynamicType.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/tests/test_DynamicType.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -33,8 +33,6 @@
from ZPublisher.HTTPResponse import HTTPResponse
from Products.CMFCore.DynamicType import DynamicType
-from Products.CMFCore.interfaces import IMembershipTool
-from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.tests.base.dummy import DummyObject
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
@@ -78,7 +76,6 @@
class DynamicTypeDefaultTraversalTests(unittest.TestCase):
def setUp(self):
- sm = getSiteManager()
self.site = DummySite('site')
self.site._setObject( 'portal_types', TypesTool() )
fti = FTIDATA_CMF15[0].copy()
@@ -161,9 +158,7 @@
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() )
self.site._setObject( 'portal_url', DummyTool() )
fti = FTIDATA_CMF15[0].copy()
Modified: CMF/branches/2.1/CMFCore/tests/test_Expression.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_Expression.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/tests/test_Expression.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -18,12 +18,9 @@
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
@@ -49,25 +46,19 @@
, 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/branches/2.1/CMFCore/tests/test_FSDTMLMethod.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_FSDTMLMethod.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/tests/test_FSDTMLMethod.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -25,11 +25,9 @@
from OFS.Folder import Folder
from Products.StandardCacheManagers import RAMCacheManager
from zope.app.component.hooks import setHooks
-from zope.component import getSiteManager
from Products.CMFCore.FSDTMLMethod import FSDTMLMethod
from Products.CMFCore.FSMetadata import FSMetadata
-from Products.CMFCore.interfaces import ICachingPolicyManager
from Products.CMFCore.tests.base.dummy import DummyCachingManager
from Products.CMFCore.tests.base.dummy import DummyCachingManagerWithPolicy
from Products.CMFCore.tests.base.testcase import FSDVTest
@@ -60,10 +58,6 @@
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' )
Modified: CMF/branches/2.1/CMFCore/tests/test_FSPageTemplate.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_FSPageTemplate.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/tests/test_FSPageTemplate.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -25,14 +25,11 @@
from Acquisition import aq_base
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.testing import TraversingZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyCachingManager
from Products.CMFCore.tests.base.testcase import FSDVTest
@@ -63,10 +60,6 @@
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' )
Modified: CMF/branches/2.1/CMFCore/tests/test_FSReSTMethod.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_FSReSTMethod.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/tests/test_FSReSTMethod.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -21,10 +21,8 @@
import re
from Acquisition import aq_base
-from zope.component import getSiteManager
from zope.testing.cleanup import cleanUp
-from Products.CMFCore.interfaces import ICachingPolicyManager
from Products.CMFCore.testing import TraversingZCMLLayer
from Products.CMFCore.tests.base.testcase import FSDVTest
from Products.CMFCore.tests.base.testcase import RequestTest
@@ -102,12 +100,6 @@
# 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)
@@ -137,12 +129,6 @@
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'
Modified: CMF/branches/2.1/CMFCore/tests/test_FSSTXMethod.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_FSSTXMethod.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/tests/test_FSSTXMethod.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -21,10 +21,8 @@
import re
from Acquisition import aq_base
-from zope.component import getSiteManager
from zope.testing.cleanup import cleanUp
-from Products.CMFCore.interfaces import ICachingPolicyManager
from Products.CMFCore.testing import TraversingZCMLLayer
from Products.CMFCore.tests.base.testcase import FSDVTest
from Products.CMFCore.tests.base.testcase import RequestTest
@@ -132,12 +130,6 @@
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)
@@ -167,12 +159,6 @@
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'
Modified: CMF/branches/2.1/CMFCore/tests/test_MemberDataTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_MemberDataTool.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/tests/test_MemberDataTool.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -19,13 +19,9 @@
import Testing
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):
@@ -106,11 +102,8 @@
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/branches/2.1/CMFCore/tests/test_MembershipTool.py
===================================================================
--- CMF/branches/2.1/CMFCore/tests/test_MembershipTool.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/tests/test_MembershipTool.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -24,7 +24,6 @@
from zope.testing.cleanup import cleanUp
from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder
-from Products.CMFCore.interfaces import IMemberDataTool
from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.MemberDataTool import MemberDataTool
from Products.CMFCore.PortalFolder import PortalFolder
@@ -174,7 +173,6 @@
members = site._setObject( 'Members', PortalFolder('Members') )
acl_users = site._setObject( 'acl_users', DummyUserFolder() )
mdtool = site._setObject( 'portal_memberdata', MemberDataTool() )
- sm.registerUtility(mdtool, IMemberDataTool)
newSecurityManager(None, acl_users.all_powerful_Oz)
self.assertEqual( acl_users.getUserById('user_foo'),
Modified: CMF/branches/2.1/CMFCore/utils.py
===================================================================
--- CMF/branches/2.1/CMFCore/utils.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFCore/utils.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -49,14 +49,12 @@
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__'
@@ -367,7 +365,7 @@
# not a conditional GET
return False
- manager = queryUtility(ICachingPolicyManager)
+ manager = getToolByName(obj, 'caching_policy_manager', None)
if manager is None:
return False
@@ -447,7 +445,7 @@
delattr(REQUEST, SUBTEMPLATE)
content = aq_parent(obj)
- manager = queryUtility(ICachingPolicyManager)
+ manager = getToolByName(obj, 'caching_policy_manager', None)
if manager is None:
return
Modified: CMF/branches/2.1/CMFDefault/DefaultWorkflow.py
===================================================================
--- CMF/branches/2.1/CMFDefault/DefaultWorkflow.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/DefaultWorkflow.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -21,10 +21,8 @@
from Acquisition import aq_parent
from DateTime import DateTime
from Globals import InitializeClass
-from zope.component import getUtility
from zope.interface import implements
-from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.interfaces import IWorkflowDefinition
from Products.CMFCore.interfaces.portal_workflow \
import WorkflowDefinition as z2IWorkflowDefinition
@@ -100,7 +98,7 @@
content = info.object
content_url = info.object_url
content_creator = content.Creator()
- pm = getUtility(IMembershipTool)
+ pm = getToolByName(self, 'portal_membership')
current_user = pm.getAuthenticatedMember().getId()
review_state = self.getReviewStateOf(content)
actions = []
@@ -204,7 +202,7 @@
elif review_state == 'private':
raise AccessControl_Unauthorized('Already private')
content_creator = ob.Creator()
- pm = getUtility(IMembershipTool)
+ pm = getToolByName(self, 'portal_membership')
current_user = pm.getAuthenticatedMember().getId()
if (content_creator != current_user) and not allow_review:
raise AccessControl_Unauthorized('Not creator or reviewer')
@@ -251,7 +249,7 @@
security.declarePrivate('setReviewStateOf')
def setReviewStateOf(self, ob, review_state, action, comment):
tool = aq_parent(aq_inner(self))
- pm = getUtility(IMembershipTool)
+ pm = getToolByName(self, 'portal_membership')
current_user = pm.getAuthenticatedMember().getId()
status = {
'actor': current_user,
Modified: CMF/branches/2.1/CMFDefault/DiscussionItem.py
===================================================================
--- CMF/branches/2.1/CMFDefault/DiscussionItem.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/DiscussionItem.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -22,18 +22,16 @@
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
@@ -115,7 +113,7 @@
- We are a nested reply; in this case, our 'in_reply_to'
field will be the ID of the parent DiscussionItem.
"""
- tool = getUtility(IDiscussionTool)
+ tool = getToolByName( self, 'portal_discussion' )
talkback = tool.getDiscussionFor( self )
return talkback._getReplyParent( self.in_reply_to )
Modified: CMF/branches/2.1/CMFDefault/DiscussionTool.py
===================================================================
--- CMF/branches/2.1/CMFDefault/DiscussionTool.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/DiscussionTool.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -20,16 +20,15 @@
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.interfaces import IDiscussionResponse
from Products.CMFCore.interfaces import IDiscussionTool
-from Products.CMFCore.interfaces import IMembershipTool
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
@@ -75,7 +74,9 @@
def overrideDiscussionFor(self, content, allowDiscussion):
""" Override discussability for the given object or clear the setting.
"""
- mtool = getUtility(IMembershipTool)
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
+ mtool = getToolByName( self, 'portal_membership' )
if not mtool.checkPermission(ModifyPortalContent, content):
raise AccessControl_Unauthorized
Modified: CMF/branches/2.1/CMFDefault/DublinCore.py
===================================================================
--- CMF/branches/2.1/CMFDefault/DublinCore.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/DublinCore.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -21,14 +21,10 @@
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
@@ -36,6 +32,7 @@
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
@@ -109,7 +106,7 @@
""" Add creator to Dublin Core creators.
"""
if creator is None:
- mtool = queryUtility(IMembershipTool)
+ mtool = getToolByName(self, 'portal_membership', None)
creator = mtool and mtool.getAuthenticatedMember().getId()
# call self.listCreators() to make sure self.creators exists
@@ -172,7 +169,7 @@
def Publisher( self ):
""" Dublin Core Publisher element - resource publisher.
"""
- tool = queryUtility(IMetadataTool)
+ tool = getToolByName(self, 'portal_metadata', None)
if tool is not None:
return tool.getPublisher()
Modified: CMF/branches/2.1/CMFDefault/RegistrationTool.py
===================================================================
--- CMF/branches/2.1/CMFDefault/RegistrationTool.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/RegistrationTool.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -15,18 +15,19 @@
$Id$
"""
+from warnings import warn
+
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 Products.CMFCore.utils import postonly
@@ -40,7 +41,6 @@
""" Manage through-the-web signup policies.
"""
- implements(IRegistrationTool)
__implements__ = BaseTool.__implements__
meta_type = 'Default Registration Tool'
@@ -133,7 +133,9 @@
o Raise an exception if user ID is not found.
"""
- membership = getUtility(IMembershipTool)
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
+ membership = getToolByName(self, 'portal_membership')
member = membership.getMemberById(forgotten_userid)
if member is None:
@@ -159,10 +161,18 @@
return self.mail_password_response( self, REQUEST )
security.declarePublic( 'registeredNotify' )
- def registeredNotify(self, new_member_id, REQUEST, password=None):
+ def registeredNotify(self, new_member_id, password=None, REQUEST=None):
""" Handle mailing the registration / welcome message.
"""
- membership = getUtility(IMembershipTool)
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool and uses self.REQUEST
+ if REQUEST is None:
+ REQUEST = self.REQUEST
+ warn("registeredNotify should be called with 'REQUEST' as third "
+ "argument. The BBB code will be removed in CMF 2.3.",
+ DeprecationWarning, stacklevel=2)
+
+ membership = getToolByName( self, 'portal_membership' )
member = membership.getMemberById( new_member_id )
if member is None:
@@ -189,21 +199,16 @@
host.send( mail_text )
security.declareProtected(ManagePortal, 'editMember')
- def editMember( self
- , member_id
- , properties=None
- , password=None
- , roles=None
- , domains=None
- , REQUEST = None
- ):
+ def editMember(self, member_id, properties=None, password=None,
+ roles=None, domains=None, REQUEST=None):
""" Edit a user's properties and security settings
o Checks should be done before this method is called using
testPropertiesValidity and testPasswordValidity
"""
-
- mtool = getUtility(IMembershipTool)
+ # XXX: this method violates the rules for tools/utilities:
+ # it depends on a non-utility tool
+ mtool = getToolByName(self, 'portal_membership')
member = mtool.getMemberById(member_id)
member.setMemberProperties(properties)
member.setSecurityProfile(password,roles,domains)
Modified: CMF/branches/2.1/CMFDefault/browser/folder.py
===================================================================
--- CMF/branches/2.1/CMFDefault/browser/folder.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/browser/folder.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -17,13 +17,11 @@
from DocumentTemplate import sequence
from Products.PythonScripts.standard import thousands_commas
-from zope.component import getUtility
from ZTUtils import Batch
from ZTUtils import LazyFilter
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
@@ -373,7 +371,7 @@
@memoize
@decode
def up_info(self):
- mtool = getUtility(IMembershipTool)
+ mtool = self._getTool('portal_membership')
allowed = mtool.checkPermission(ListFolderContents, self.context,
'aq_parent')
if allowed:
Modified: CMF/branches/2.1/CMFDefault/browser/folder.txt
===================================================================
--- CMF/branches/2.1/CMFDefault/browser/folder.txt 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/browser/folder.txt 2007-06-26 20:36:26 UTC (rev 77113)
@@ -10,11 +10,9 @@
>>> 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
>>> 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())
Modified: CMF/branches/2.1/CMFDefault/browser/metadata.py
===================================================================
--- CMF/branches/2.1/CMFDefault/browser/metadata.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/browser/metadata.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -18,7 +18,6 @@
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
@@ -30,9 +29,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
@@ -173,7 +172,7 @@
return getattr(context, 'allow_discussion', None)
def _setAllowDiscussion(self, value):
- dtool = getUtility(IDiscussionTool)
+ dtool = getToolByName(self.context, 'portal_discussion')
dtool.overrideDiscussionFor(self.context, value)
allow_discussion = property(_getAllowDiscussion, _setAllowDiscussion)
Modified: CMF/branches/2.1/CMFDefault/browser/utils.py
===================================================================
--- CMF/branches/2.1/CMFDefault/browser/utils.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/browser/utils.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -20,7 +20,6 @@
from Products.Five import BrowserView
from zope.component import getUtility
-from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.interfaces import IPropertiesTool
from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.permissions import View
@@ -72,7 +71,7 @@
@memoize
def _checkPermission(self, permission):
- mtool = getUtility(IMembershipTool)
+ mtool = self._getTool('portal_membership')
return mtool.checkPermission(permission, self.context)
@memoize
Modified: CMF/branches/2.1/CMFDefault/factory.py
===================================================================
--- CMF/branches/2.1/CMFDefault/factory.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/factory.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -19,6 +19,7 @@
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
@@ -56,7 +57,7 @@
setSite(site)
site._setObject(_TOOL_ID, SetupTool(_TOOL_ID))
- setup_tool = getattr(site, _TOOL_ID)
+ setup_tool = getToolByName(site, _TOOL_ID)
setup_tool.setBaselineContext('profile-%s' % profile_id)
setup_tool.runAllImportStepsFromProfile('profile-%s' % profile_id)
Modified: CMF/branches/2.1/CMFDefault/profiles/default/componentregistry.xml
===================================================================
--- CMF/branches/2.1/CMFDefault/profiles/default/componentregistry.xml 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/profiles/default/componentregistry.xml 2007-06-26 20:36:26 UTC (rev 77113)
@@ -3,27 +3,12 @@
<adapters/>
<utilities>
<utility
- interface="Products.CMFCore.interfaces.ICachingPolicyManager"
- object="/caching_policy_manager"/>
- <utility
- interface="Products.CMFCore.interfaces.IDiscussionTool"
- object="/portal_discussion"/>
- <utility
- interface="Products.CMFCore.interfaces.IMemberDataTool"
- object="/portal_memberdata"/>
- <utility
- interface="Products.CMFCore.interfaces.IMembershipTool"
- object="/portal_membership"/>
- <utility
interface="Products.CMFCore.interfaces.IMetadataTool"
object="/portal_metadata"/>
<utility
interface="Products.CMFCore.interfaces.IPropertiesTool"
object="/portal_properties"/>
<utility
- interface="Products.CMFCore.interfaces.IRegistrationTool"
- object="/portal_registration"/>
- <utility
interface="Products.CMFCore.interfaces.ISiteRoot"
object="/"/>
<utility
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_content/metadata_edit_control.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_content/metadata_edit_control.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_content/metadata_edit_control.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -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 getToolByInterfaceName
+from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.exceptions import ResourceLockedError
from Products.CMFDefault.utils import Message as _
-dtool = getToolByInterfaceName('Products.CMFCore.interfaces.IDiscussionTool')
+dtool = getToolByName(script, 'portal_discussion')
def tuplify( value ):
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_control/addtoFavorites.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_control/addtoFavorites.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_control/addtoFavorites.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -1,8 +1,8 @@
##parameters=
##
-from Products.CMFCore.utils import getToolByInterfaceName
+from Products.CMFCore.utils import getToolByName
-mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+mtool = getToolByName(script, 'portal_membership')
home = mtool.getHomeFolder()
if not hasattr(home, 'Favorites'):
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_control/change_password.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_control/change_password.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_control/change_password.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -1,11 +1,11 @@
##parameters=password, confirm, domains=None, **kw
##title=Action to change password
##
-from Products.CMFCore.utils import getToolByInterfaceName
+from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.utils import Message as _
-mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
-rtool = getToolByInterfaceName('Products.CMFCore.interfaces.IRegistrationTool')
+mtool = getToolByName(script, 'portal_membership')
+rtool = getToolByName(script, 'portal_registration')
result = rtool.testPasswordValidity(password, confirm)
if result:
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_control/folder_localrole_edit.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_control/folder_localrole_edit.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_control/folder_localrole_edit.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -1,10 +1,10 @@
##parameters=change_type
##title=Set local roles
##
-from Products.CMFCore.utils import getToolByInterfaceName
+from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.utils import Message as _
-mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+mtool = getToolByName(script, 'portal_membership')
if change_type == 'add':
mtool.setLocalRoles(obj=context,
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_control/members_add_control.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_control/members_add_control.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_control/members_add_control.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -2,12 +2,13 @@
##title=Add a member
##
from Products.CMFCore.utils import getToolByInterfaceName
+from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.permissions import ManageUsers
from Products.CMFDefault.utils import Message as _
-mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+mtool = getToolByName(script, 'portal_membership')
ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
-rtool = getToolByInterfaceName('Products.CMFCore.interfaces.IRegistrationTool')
+rtool = getToolByName(script, 'portal_registration')
try:
rtool.addMember( id=member_id, password=password,
@@ -18,7 +19,7 @@
return context.setStatus(False, errmsg)
else:
if ptool.getProperty('validate_email') or send_password:
- rtool.registeredNotify(member_id, context.REQUEST)
+ rtool.registeredNotify(member_id, REQUEST=context.REQUEST)
if mtool.checkPermission(ManageUsers, mtool):
return context.setStatus(True, _(u'Member registered.'))
else:
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_control/members_delete_control.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_control/members_delete_control.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_control/members_delete_control.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -1,10 +1,10 @@
##parameters=ids, **kw
##title=Delete members
##
-from Products.CMFCore.utils import getToolByInterfaceName
+from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.utils import Message as _
-mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+mtool = getToolByName(script, 'portal_membership')
mtool.deleteMembers(ids, REQUEST=context.REQUEST)
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_control/portal_config_control.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_control/portal_config_control.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_control/portal_config_control.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -1,9 +1,9 @@
##parameters=**kw
##
-from Products.CMFCore.utils import getToolByInterfaceName
+from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.utils import Message as _
-ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
+ptool = getToolByName(script, 'portal_properties')
if not ptool.hasProperty('default_charset'):
ptool.manage_addProperty('default_charset', '', 'string')
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_control/validatePassword.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_control/validatePassword.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_control/validatePassword.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -3,9 +3,10 @@
##title=
##
from Products.CMFCore.utils import getToolByInterfaceName
+from Products.CMFCore.utils import getToolByName
ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
-rtool = getToolByInterfaceName('Products.CMFCore.interfaces.IRegistrationTool')
+rtool = getToolByName(script, 'portal_registration')
if ptool.getProperty('validate_email'):
password = rtool.generatePassword()
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_generic/discitem_delete.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_generic/discitem_delete.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_generic/discitem_delete.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -1,10 +1,10 @@
##parameters=
##title=Delete reply
##
-from Products.CMFCore.utils import getToolByInterfaceName
+from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.utils import Message as _
-dtool = getToolByInterfaceName('Products.CMFCore.interfaces.IDiscussionTool')
+dtool = getToolByName(script, 'portal_discussion')
parent = context.inReplyTo()
talkback = dtool.getDiscussionFor(parent)
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_generic/discussion_reply.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_generic/discussion_reply.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_generic/discussion_reply.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -1,10 +1,10 @@
##parameters=title, text, **kw
##title=Reply to content
##
-from Products.CMFCore.utils import getToolByInterfaceName
+from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.utils import Message as _
-dtool = getToolByInterfaceName('Products.CMFCore.interfaces.IDiscussionTool')
+dtool = getToolByName(script, 'portal_discussion')
talkback = dtool.getDiscussionFor(context)
replyID = talkback.createReply(title=title, text=text)
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_generic/folder_contents.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_generic/folder_contents.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_generic/folder_contents.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -2,7 +2,6 @@
##
from ZTUtils import Batch
from ZTUtils import make_query
-from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.permissions import AddPortalContent
from Products.CMFDefault.permissions import DeleteObjects
@@ -13,7 +12,7 @@
from Products.CMFDefault.utils import html_marshal
from Products.CMFDefault.utils import Message as _
-mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+mtool = getToolByName(script, 'portal_membership')
utool = getToolByName(script, 'portal_url')
portal_url = utool()
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_generic/getMainGlobals.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_generic/getMainGlobals.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_generic/getMainGlobals.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -7,7 +7,7 @@
atool = getToolByName(script, 'portal_actions')
caltool = getToolByName(script, 'portal_calendar', None)
-mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+mtool = getToolByName(script, 'portal_membership')
ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
utool = getToolByName(script, 'portal_url')
wtool = getToolByName(script, 'portal_workflow')
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_generic/join_form.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_generic/join_form.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_generic/join_form.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -7,7 +7,7 @@
from Products.CMFDefault.utils import Message as _
atool = getToolByName(script, 'portal_actions')
-mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+mtool = getToolByName(script, 'portal_membership')
ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
utool = getToolByName(script, 'portal_url')
portal_url = utool()
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_generic/logged_in.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_generic/logged_in.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_generic/logged_in.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -5,7 +5,7 @@
from Products.CMFDefault.utils import decode
from Products.CMFDefault.utils import Message as _
-mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+mtool = getToolByName(script, 'portal_membership')
ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
stool = getToolByName(script, 'portal_skins')
utool = getToolByName(script, 'portal_url')
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_generic/members_manage_form.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_generic/members_manage_form.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_generic/members_manage_form.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -1,14 +1,13 @@
##parameters=b_start=0, ids=(), members_new='', members_delete=''
##
from ZTUtils import Batch
-from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFCore.utils import getToolByName
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 = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+mtool = getToolByName(script, 'portal_membership')
form = context.REQUEST.form
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_generic/password_form.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_generic/password_form.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_generic/password_form.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -6,7 +6,7 @@
from Products.CMFDefault.utils import Message as _
atool = getToolByName(script, 'portal_actions')
-mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+mtool = getToolByName(script, 'portal_membership')
ptool = getToolByInterfaceName('Products.CMFCore.interfaces.IPropertiesTool')
utool = getToolByName(script, 'portal_url')
member = mtool.getAuthenticatedMember()
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_generic/search_form.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_generic/search_form.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_generic/search_form.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -1,13 +1,12 @@
##parameters=search=''
##
-from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFCore.utils import getToolByName
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 = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+mtool = getToolByName(script, 'portal_membership')
ttool = getToolByName(script, 'portal_types')
utool = getToolByName(script, 'portal_url')
portal_url = utool()
Modified: CMF/branches/2.1/CMFDefault/skins/zpt_generic/setup_talkback_tree.py
===================================================================
--- CMF/branches/2.1/CMFDefault/skins/zpt_generic/setup_talkback_tree.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/skins/zpt_generic/setup_talkback_tree.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -2,12 +2,11 @@
##title=Standard Tree
##
from ZTUtils import SimpleTreeMaker
-from Products.CMFCore.utils import getToolByInterfaceName
from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.permissions import ManagePortal
from Products.CMFDefault.utils import decode
-mtool = getToolByInterfaceName('Products.CMFCore.interfaces.IMembershipTool')
+mtool = getToolByName(script, 'portal_membership')
utool = getToolByName(script, 'portal_url')
portal_url = utool()
Modified: CMF/branches/2.1/CMFDefault/tests/RegistrationTool.txt
===================================================================
--- CMF/branches/2.1/CMFDefault/tests/RegistrationTool.txt 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/tests/RegistrationTool.txt 2007-06-26 20:36:26 UTC (rev 77113)
@@ -29,14 +29,13 @@
>>> 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)
>>> app.site.setupCurrentSkin(app.REQUEST)
>>> sm = getSiteManager()
- >>> sm.registerUtility(MembershipTool(), IMembershipTool)
>>> sm.registerUtility(MailHost(), IMailHost)
>>> rtool = app.site.portal_registration
+ >>> rtool.portal_membership = MembershipTool()
>>> rtool.password_email = password_email
>>> rtool.mail_password_response = mail_password_response
>>> rtool.registered_email = registered_email
@@ -51,14 +50,14 @@
registeredNotify sends a welcome message::
- >>> rtool.registeredNotify('foo', app.REQUEST)
+ >>> rtool.registeredNotify('foo', REQUEST=app.REQUEST)
>>> 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)
+ >>> del rtool.portal_membership
password_email and registered_email
-----------------------------------
Modified: CMF/branches/2.1/CMFDefault/tests/test_DiscussionTool.py
===================================================================
--- CMF/branches/2.1/CMFDefault/tests/test_DiscussionTool.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/tests/test_DiscussionTool.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -18,11 +18,8 @@
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.tests.base.dummy import DummyFolder
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
@@ -37,11 +34,8 @@
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() )
def tearDown(self):
Modified: CMF/branches/2.1/CMFDefault/tests/test_Discussions.py
===================================================================
--- CMF/branches/2.1/CMFDefault/tests/test_Discussions.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/tests/test_Discussions.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -18,11 +18,7 @@
import unittest
import Testing
-from zope.component import getSiteManager
-
from Products.CMFCore.CatalogTool import CatalogTool
-from Products.CMFCore.interfaces import IDiscussionTool
-from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.testing import EventZCMLLayer
from Products.CMFCore.tests.base.dummy import DummyContent
from Products.CMFCore.tests.base.dummy import DummySite
@@ -32,6 +28,7 @@
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
@@ -109,11 +106,8 @@
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() )
def _makeDummyContent(self, id, *args, **kw):
@@ -331,7 +325,7 @@
talkback = dtool.getDiscussionFor(test)
self.failUnless(hasattr(talkback, 'aq_base'))
# Acquire a portal tool
- self.failUnless(getattr(talkback, 'portal_discussion', None))
+ self.failUnless(getToolByName(talkback, 'portal_discussion'))
def test_existingTalkbackIsWrapped(self):
test = self._makeDummyContent('test')
@@ -341,7 +335,7 @@
talkback = dtool.getDiscussionFor(test)
self.failUnless(hasattr(talkback, 'aq_base'))
# Acquire a portal tool
- self.failUnless(getattr(talkback, 'portal_discussion', None))
+ self.failUnless(getToolByName(talkback, 'portal_discussion'))
def test_suite():
Modified: CMF/branches/2.1/CMFDefault/tests/test_DublinCore.py
===================================================================
--- CMF/branches/2.1/CMFDefault/tests/test_DublinCore.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/tests/test_DublinCore.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -22,11 +22,8 @@
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
@@ -101,10 +98,8 @@
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(), () )
@@ -117,10 +112,8 @@
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(), () )
@@ -142,10 +135,8 @@
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()
@@ -177,9 +168,7 @@
def test_publisher_with_metadata_tool(self):
PUBLISHER = 'Some Publisher'
site = DummySite('site').__of__(self.root)
- sm = getSiteManager()
site.portal_metadata = DummyMetadataTool(publisher=PUBLISHER)
- sm.registerUtility(site.portal_metadata, IMetadataTool)
item = self._makeDummyContent('item').__of__(site)
self.assertEqual(item.Publisher(), PUBLISHER)
Modified: CMF/branches/2.1/CMFDefault/tests/test_Favorite.py
===================================================================
--- CMF/branches/2.1/CMFDefault/tests/test_Favorite.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/tests/test_Favorite.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -21,7 +21,6 @@
from zope.component import getSiteManager
from zope.testing.cleanup import cleanUp
-from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.testing import ConformsToContent
from Products.CMFCore.tests.base.dummy import DummySite
@@ -42,7 +41,7 @@
sm = getSiteManager()
self.site = DummySite('site')
sm.registerUtility(self.site, ISiteRoot)
- sm.registerUtility(DummyTool(), IMembershipTool)
+ self.site._setObject( 'portal_membership', DummyTool() )
self.site._setObject( 'portal_url', DummyTool() )
def tearDown(self):
Modified: CMF/branches/2.1/CMFDefault/tests/test_File.py
===================================================================
--- CMF/branches/2.1/CMFDefault/tests/test_File.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/tests/test_File.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -20,10 +20,8 @@
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
@@ -107,10 +105,6 @@
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()
Modified: CMF/branches/2.1/CMFDefault/tests/test_Image.py
===================================================================
--- CMF/branches/2.1/CMFDefault/tests/test_Image.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/tests/test_Image.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -22,14 +22,12 @@
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
@@ -212,10 +210,6 @@
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()
Modified: CMF/branches/2.1/CMFDefault/tests/test_RegistrationTool.py
===================================================================
--- CMF/branches/2.1/CMFDefault/tests/test_RegistrationTool.py 2007-06-26 19:36:28 UTC (rev 77112)
+++ CMF/branches/2.1/CMFDefault/tests/test_RegistrationTool.py 2007-06-26 20:36:26 UTC (rev 77113)
@@ -19,10 +19,8 @@
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
@@ -71,10 +69,8 @@
Spam, spam, spam
"""
- rtool = self._makeOne()
- mtool = FauxMembershipTool()
- sm = getSiteManager()
- sm.registerUtility(mtool, IMembershipTool)
+ rtool = self._makeOne().__of__(self.app)
+ self.app.portal_membership = FauxMembershipTool()
props = { 'email' : INJECTED_HEADERS
, 'username' : 'username'
More information about the CMF-checkins
mailing list