[CMF-checkins] SVN: CMF/trunk/ forward ported recent changes
(r77113, r77356) from 2.1 branch:
Yvo Schubbe
y.2007- at wcm-solutions.de
Tue Jul 3 11:18:12 EDT 2007
Log message for revision 77358:
forward ported recent changes (r77113, r77356) from 2.1 branch:
- 4 more tools are no longer registered as utilities
- related cleanup
Changed:
U CMF/trunk/CMFCore/ActionInformation.py
U CMF/trunk/CMFCore/CachingPolicyManager.py
U CMF/trunk/CMFCore/DiscussionTool.py
U CMF/trunk/CMFCore/Expression.py
U CMF/trunk/CMFCore/MemberDataTool.py
U CMF/trunk/CMFCore/MembershipTool.py
U CMF/trunk/CMFCore/RegistrationTool.py
U CMF/trunk/CMFCore/SkinsTool.py
U CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py
U CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.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_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_FSReSTMethod.py
U CMF/trunk/CMFCore/tests/test_FSSTXMethod.py
U CMF/trunk/CMFCore/tests/test_MemberDataTool.py
U CMF/trunk/CMFCore/tests/test_MembershipTool.py
U CMF/trunk/CMFCore/utils.py
U CMF/trunk/CMFDefault/DefaultWorkflow.py
U CMF/trunk/CMFDefault/DiscussionTool.py
U CMF/trunk/CMFDefault/DublinCore.py
U CMF/trunk/CMFDefault/RegistrationTool.py
U CMF/trunk/CMFDefault/browser/document.py
U CMF/trunk/CMFDefault/browser/folder.py
U CMF/trunk/CMFDefault/browser/folder.txt
U CMF/trunk/CMFDefault/browser/utils.py
U CMF/trunk/CMFDefault/factory.py
U CMF/trunk/CMFDefault/profiles/default/componentregistry.xml
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/validatePassword.py
U CMF/trunk/CMFDefault/skins/zpt_generic/folder_contents.py
U CMF/trunk/CMFDefault/skins/zpt_generic/getMainGlobals.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_manage_form.py
U CMF/trunk/CMFDefault/skins/zpt_generic/password_form.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/tests/RegistrationTool.txt
U CMF/trunk/CMFDefault/tests/test_DiscussionTool.py
U CMF/trunk/CMFDefault/tests/test_Discussions.py
U CMF/trunk/CMFDefault/tests/test_Document.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_RegistrationTool.py
U CMF/trunk/CMFTopic/skins/zpt_topic/topic_criteria_form.pt
U CMF/trunk/slurp_release.py
-=-
Modified: CMF/trunk/CMFCore/ActionInformation.py
===================================================================
--- CMF/trunk/CMFCore/ActionInformation.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/ActionInformation.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -24,7 +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
@@ -32,9 +31,9 @@
from interfaces import IAction
from interfaces import IActionCategory
from interfaces import IActionInfo
-from interfaces import IMembershipTool
from permissions import View
from utils import _checkPermission
+from utils import getToolByName
_unchanged = [] # marker
@@ -499,7 +498,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/trunk/CMFCore/CachingPolicyManager.py
===================================================================
--- CMF/trunk/CMFCore/CachingPolicyManager.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/CachingPolicyManager.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -30,18 +30,17 @@
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 Expression import Expression
from interfaces import ICachingPolicy
from interfaces import ICachingPolicyManager
-from interfaces import IMembershipTool
from permissions import ManagePortal
from permissions import View
from utils import _dtmldir
from utils import _setCacheHeaders
from utils import _ViewEmulator
+from utils import getToolByName
from utils import registerToolInterface
# This is lame :(
@@ -61,7 +60,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:
@@ -826,6 +825,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():
@@ -842,6 +843,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):
@@ -877,6 +880,7 @@
InitializeClass( CachingPolicyManager )
registerToolInterface('caching_policy_manager', ICachingPolicyManager)
+
def handleCachingPolicyManagerEvent(ob, event):
""" Event subscriber for (un)registering a CPM as CacheManager
"""
Modified: CMF/trunk/CMFCore/DiscussionTool.py
===================================================================
--- CMF/trunk/CMFCore/DiscussionTool.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/DiscussionTool.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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 permissions import AccessContentsInformation
@@ -68,7 +66,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/trunk/CMFCore/Expression.py
===================================================================
--- CMF/trunk/CMFCore/Expression.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/Expression.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFCore/MemberDataTool.py
===================================================================
--- CMF/trunk/CMFCore/MemberDataTool.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/MemberDataTool.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -22,20 +22,17 @@
from Globals import InitializeClass
from OFS.PropertyManager import PropertyManager
from OFS.SimpleItem import SimpleItem
-from zope.component import getUtility
-from zope.component import queryUtility
from zope.interface import implements
from ZPublisher.Converters import type_converters
from exceptions import BadRequest
from interfaces import IMemberData
from interfaces import IMemberDataTool
-from interfaces import IMembershipTool
-from interfaces import IRegistrationTool
from permissions import ManagePortal
from permissions import SetOwnProperties
from permissions import ViewManagementScreens
from utils import _dtmldir
+from utils import getToolByName
from utils import registerToolInterface
from utils import UniqueObject
@@ -91,7 +88,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()
@@ -108,12 +107,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')
@@ -144,12 +145,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():
@@ -171,7 +174,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()
@@ -270,10 +275,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/trunk/CMFCore/MembershipTool.py
===================================================================
--- CMF/trunk/CMFCore/MembershipTool.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/MembershipTool.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -30,14 +30,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 permissions import AccessContentsInformation
from permissions import ChangeLocalRoles
@@ -49,6 +46,7 @@
from utils import _checkPermission
from utils import _dtmldir
from utils import _getAuthenticatedUser
+from utils import getToolByName
from utils import UniqueObject
logger = logging.getLogger('CMFCore.MembershipTool')
@@ -95,7 +93,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:
@@ -124,6 +124,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.
@@ -142,7 +144,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)
@@ -327,8 +329,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
@@ -400,7 +407,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 )
@@ -478,6 +487,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
@@ -498,7 +509,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/trunk/CMFCore/RegistrationTool.py
===================================================================
--- CMF/trunk/CMFCore/RegistrationTool.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/RegistrationTool.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -23,10 +23,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 permissions import AddPortalMember
from permissions import MailForgottenPassword
@@ -34,6 +32,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
@@ -141,6 +140,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.'))
@@ -158,7 +159,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)
@@ -169,11 +170,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/trunk/CMFCore/SkinsTool.py
===================================================================
--- CMF/trunk/CMFCore/SkinsTool.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/SkinsTool.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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 permissions import AccessContentsInformation
from permissions import ManagePortal
@@ -305,7 +303,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/trunk/CMFCore/exportimport/cachingpolicymgr.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/exportimport/cachingpolicymgr.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py
===================================================================
--- CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/exportimport/tests/test_cachingpolicymgr.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFCore/tests/test_ActionInformation.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_ActionInformation.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/tests/test_ActionInformation.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -20,12 +20,10 @@
from OFS.Folder import manage_addFolder
from Products.PythonScripts.PythonScript import manage_addPythonScript
-from zope.component import getSiteManager
from zope.interface.verify import verifyClass
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
@@ -208,9 +206,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
@@ -324,9 +320,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/trunk/CMFCore/tests/test_ActionProviderBase.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_ActionProviderBase.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/tests/test_ActionProviderBase.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -18,11 +18,9 @@
import unittest
import Testing
-from zope.component import getSiteManager
from zope.interface.verify import verifyClass
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
@@ -67,9 +65,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/trunk/CMFCore/tests/test_ActionsTool.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_ActionsTool.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/tests/test_ActionsTool.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -26,7 +26,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
@@ -108,7 +107,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/trunk/CMFCore/tests/test_CachingPolicyManager.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_CachingPolicyManager.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/tests/test_CachingPolicyManager.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -27,12 +27,10 @@
from App.Common import rfc1123_date
from DateTime.DateTime import DateTime
from OFS.Cache import Cacheable
-from zope.component import getSiteManager
from zope.interface.verify import verifyClass
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
@@ -442,6 +440,7 @@
def test_interfaces(self):
from Products.CMFCore.CachingPolicyManager import CachingPolicyManager
+ from Products.CMFCore.interfaces import ICachingPolicyManager
verifyClass(ICachingPolicyManager, CachingPolicyManager)
@@ -671,9 +670,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',
@@ -897,11 +893,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)
@@ -1222,9 +1213,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/trunk/CMFCore/tests/test_DynamicType.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_DynamicType.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/tests/test_DynamicType.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -34,8 +34,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
@@ -71,7 +69,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()
@@ -154,9 +151,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/trunk/CMFCore/tests/test_Expression.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_Expression.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/tests/test_Expression.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFCore/tests/test_FSDTMLMethod.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSDTMLMethod.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/tests/test_FSDTMLMethod.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFCore/tests/test_FSPageTemplate.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSPageTemplate.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/tests/test_FSPageTemplate.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFCore/tests/test_FSReSTMethod.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSReSTMethod.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/tests/test_FSReSTMethod.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFCore/tests/test_FSSTXMethod.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_FSSTXMethod.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/tests/test_FSSTXMethod.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFCore/tests/test_MemberDataTool.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_MemberDataTool.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/tests/test_MemberDataTool.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -19,14 +19,10 @@
import Testing
import Acquisition
-from zope.component import getSiteManager
from zope.interface.verify import verifyClass
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):
@@ -80,6 +76,7 @@
cleanUp()
def test_interfaces(self):
+ from Products.CMFCore.interfaces import IMemberDataTool
from Products.CMFCore.MemberDataTool import MemberDataTool
verifyClass(IMemberDataTool, MemberDataTool)
@@ -97,11 +94,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/trunk/CMFCore/tests/test_MembershipTool.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_MembershipTool.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/tests/test_MembershipTool.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -25,7 +25,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
@@ -166,7 +165,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/trunk/CMFCore/utils.py
===================================================================
--- CMF/trunk/CMFCore/utils.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFCore/utils.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -28,7 +28,9 @@
from AccessControl.Permission import Permission
from AccessControl.PermissionRole import rolesForPermissionOn
from AccessControl.Role import gather_permissions
+from Acquisition.interfaces import IAcquirer
from Acquisition import aq_get
+from Acquisition import aq_inner
from Acquisition import aq_parent
from Acquisition import Implicit
from DateTime import DateTime
@@ -47,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__'
@@ -100,7 +100,15 @@
if tool_interface is not None:
try:
- return getUtility(tool_interface)
+ utility = getUtility(tool_interface)
+ # Site managers, except for five.localsitemanager, return unwrapped
+ # utilities. If the result is something which is acquisition-unaware
+ # but unwrapped we wrap it on the context.
+ if IAcquirer.providedBy(obj) and \
+ aq_parent(utility) is None and \
+ IAcquirer.providedBy(utility):
+ utilty = utility.__of__(obj)
+ return utility
except ComponentLookupError:
# behave in backwards-compatible way
# fall through to old implementation
@@ -357,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
@@ -437,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/trunk/CMFDefault/DefaultWorkflow.py
===================================================================
--- CMF/trunk/CMFDefault/DefaultWorkflow.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/DefaultWorkflow.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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.utils import _checkPermission
from Products.CMFCore.utils import _modifyPermissionMappings
@@ -97,7 +95,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 = []
@@ -201,7 +199,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')
@@ -248,7 +246,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/trunk/CMFDefault/DiscussionTool.py
===================================================================
--- CMF/trunk/CMFDefault/DiscussionTool.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/DiscussionTool.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -20,12 +20,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 Products.CMFCore.interfaces import IDiscussionResponse
from Products.CMFCore.interfaces import IDiscussionTool
-from Products.CMFCore.interfaces import IMembershipTool
+from Products.CMFCore.utils import _checkPermission
+from Products.CMFCore.utils import registerToolInterface
from Products.CMFCore.utils import UniqueObject
from DiscussionItem import DiscussionItemContainer
@@ -69,8 +69,7 @@
def overrideDiscussionFor(self, content, allowDiscussion):
""" Override discussability for the given object or clear the setting.
"""
- mtool = getUtility(IMembershipTool)
- if not mtool.checkPermission(ModifyPortalContent, content):
+ if not _checkPermission(ModifyPortalContent, content):
raise AccessControl_Unauthorized
if allowDiscussion is None or allowDiscussion == 'None':
@@ -119,3 +118,4 @@
return content.talkback
InitializeClass( DiscussionTool )
+registerToolInterface('portal_discussion', IDiscussionTool)
Modified: CMF/trunk/CMFDefault/DublinCore.py
===================================================================
--- CMF/trunk/CMFDefault/DublinCore.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/DublinCore.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -21,14 +21,12 @@
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.utils import getToolByName
from permissions import ModifyPortalContent
from permissions import View
@@ -100,7 +98,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
@@ -163,7 +161,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/trunk/CMFDefault/RegistrationTool.py
===================================================================
--- CMF/trunk/CMFDefault/RegistrationTool.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/RegistrationTool.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -15,6 +15,8 @@
$Id$
"""
+from warnings import warn
+
from AccessControl import ClassSecurityInfo
from AccessControl.requestmethod import postonly
from Acquisition import aq_base
@@ -23,10 +25,10 @@
from zope.component import getUtility
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 permissions import ManagePortal
from utils import checkEmailAddress
@@ -128,7 +130,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:
@@ -154,10 +158,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:
@@ -192,8 +204,9 @@
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/trunk/CMFDefault/browser/document.py
===================================================================
--- CMF/trunk/CMFDefault/browser/document.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/browser/document.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -25,6 +25,7 @@
from zope.schema import Text
from zope.schema import TextLine
+from Products.CMFDefault.Document import REST_AVAILABLE
from Products.CMFDefault.formlib.form import ContentEditFormBase
from Products.CMFDefault.formlib.schema import ProxyFieldProperty
from Products.CMFDefault.formlib.schema import SchemaAdapterBase
@@ -38,8 +39,6 @@
from utils import memoize
from utils import ViewBase
-from Products.CMFDefault.Document import REST_AVAILABLE
-
available_text_formats = (
(u'structured-text', 'structured-text', _(u'structured-text')),
(u'plain', 'plain', _(u'plain text')),
Modified: CMF/trunk/CMFDefault/browser/folder.py
===================================================================
--- CMF/trunk/CMFDefault/browser/folder.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/browser/folder.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/browser/folder.txt
===================================================================
--- CMF/trunk/CMFDefault/browser/folder.txt 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/browser/folder.txt 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/browser/utils.py
===================================================================
--- CMF/trunk/CMFDefault/browser/utils.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/browser/utils.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/factory.py
===================================================================
--- CMF/trunk/CMFDefault/factory.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/factory.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/profiles/default/componentregistry.xml
===================================================================
--- CMF/trunk/CMFDefault/profiles/default/componentregistry.xml 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/profiles/default/componentregistry.xml 2007-07-03 15:18:06 UTC (rev 77358)
@@ -3,27 +3,15 @@
<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/trunk/CMFDefault/skins/zpt_control/addtoFavorites.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/addtoFavorites.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/skins/zpt_control/addtoFavorites.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/skins/zpt_control/change_password.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/change_password.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/skins/zpt_control/change_password.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/skins/zpt_control/folder_localrole_edit.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/folder_localrole_edit.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/skins/zpt_control/folder_localrole_edit.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/skins/zpt_control/members_add_control.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/members_add_control.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/skins/zpt_control/members_add_control.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/skins/zpt_control/members_delete_control.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/members_delete_control.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/skins/zpt_control/members_delete_control.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/skins/zpt_control/validatePassword.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_control/validatePassword.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/skins/zpt_control/validatePassword.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/skins/zpt_generic/folder_contents.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/folder_contents.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/folder_contents.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/skins/zpt_generic/getMainGlobals.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/getMainGlobals.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/getMainGlobals.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/skins/zpt_generic/join_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/join_form.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/join_form.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/skins/zpt_generic/logged_in.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/logged_in.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/skins/zpt_generic/members_manage_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/members_manage_form.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/members_manage_form.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/skins/zpt_generic/password_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/password_form.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/password_form.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/skins/zpt_generic/search_form.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/search_form.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/search_form.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/skins/zpt_generic/setup_talkback_tree.py
===================================================================
--- CMF/trunk/CMFDefault/skins/zpt_generic/setup_talkback_tree.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/skins/zpt_generic/setup_talkback_tree.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/tests/RegistrationTool.txt
===================================================================
--- CMF/trunk/CMFDefault/tests/RegistrationTool.txt 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/tests/RegistrationTool.txt 2007-07-03 15:18:06 UTC (rev 77358)
@@ -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/trunk/CMFDefault/tests/test_DiscussionTool.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_DiscussionTool.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/tests/test_DiscussionTool.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -23,13 +23,13 @@
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
+from Products.CMFCore.tests.base.testcase import SecurityTest
-class DiscussionToolTests(unittest.TestCase):
+class DiscussionToolTests(SecurityTest):
def _makeOne(self, *args, **kw):
from Products.CMFDefault.DiscussionTool import DiscussionTool
@@ -37,16 +37,16 @@
return DiscussionTool(*args, **kw)
def setUp(self):
+ SecurityTest.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):
cleanUp()
+ SecurityTest.tearDown(self)
def test_interfaces(self):
from Products.CMFCore.interfaces import IDiscussionTool
Modified: CMF/trunk/CMFDefault/tests/test_Discussions.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Discussions.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/tests/test_Discussions.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -23,7 +23,6 @@
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
@@ -33,6 +32,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
@@ -82,7 +82,6 @@
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):
@@ -300,7 +299,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')
@@ -310,7 +309,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/trunk/CMFDefault/tests/test_Document.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Document.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/tests/test_Document.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -65,6 +65,7 @@
def _makeOne(self, *args, **kw):
return self._getTargetClass()(*args, **kw)
+
class DummyLinebreakNormalizer(object):
implements(ILinebreakNormalizer)
Modified: CMF/trunk/CMFDefault/tests/test_DublinCore.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_DublinCore.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/tests/test_DublinCore.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -21,12 +21,9 @@
from AccessControl.SecurityManagement import newSecurityManager
from Acquisition import Implicit
from DateTime.DateTime import DateTime
-from zope.component import getSiteManager
from zope.interface.verify import verifyClass
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
@@ -86,9 +83,8 @@
def test_notifyModified(self):
site = DummySite('site').__of__(self.root)
- sm = getSiteManager()
acl_users = site._setObject( 'acl_users', DummyUserFolder() )
- sm.registerUtility(MembershipTool(), IMembershipTool)
+ site._setObject( 'portal_membership', MembershipTool() )
newSecurityManager(None, acl_users.user_foo)
item = self._makeDummyContent('item').__of__(site)
self.assertEqual( item.listCreators(), () )
@@ -101,9 +97,8 @@
def test_creators_methods(self):
site = DummySite('site').__of__(self.root)
- sm = getSiteManager()
acl_users = site._setObject( 'acl_users', DummyUserFolder() )
- sm.registerUtility(MembershipTool(), IMembershipTool)
+ site._setObject( 'portal_membership', MembershipTool() )
newSecurityManager(None, acl_users.user_foo)
item = self._makeDummyContent('item').__of__(site)
self.assertEqual( item.listCreators(), () )
@@ -125,9 +120,8 @@
def test_creators_upgrade(self):
site = DummySite('site').__of__(self.root)
- sm = getSiteManager()
acl_users = site._setObject( 'acl_users', DummyUserFolder() )
- sm.registerUtility(MembershipTool(), IMembershipTool)
+ site._setObject( 'portal_membership', MembershipTool() )
newSecurityManager(None, acl_users.user_foo)
item = self._makeDummyContent('item').__of__(site)
item.manage_fixupOwnershipAfterAdd()
@@ -159,9 +153,7 @@
def test_publisher_with_metadata_tool(self):
PUBLISHER = 'Some Publisher'
site = DummySite('site').__of__(self.root)
- sm = getSiteManager()
- sm.registerUtility(DummyMetadataTool(publisher=PUBLISHER),
- IMetadataTool)
+ site.portal_metadata = DummyMetadataTool(publisher=PUBLISHER)
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-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/tests/test_Favorite.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -22,7 +22,6 @@
from zope.interface.verify import verifyClass
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
@@ -43,7 +42,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/trunk/CMFDefault/tests/test_File.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_File.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/tests/test_File.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -20,11 +20,9 @@
from os.path import join as path_join
-from zope.component import getSiteManager
from zope.interface.verify import verifyClass
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 DummyCachingManager
from Products.CMFCore.tests.base.dummy import DummyCachingManagerWithPolicy
@@ -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/trunk/CMFDefault/tests/test_Image.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Image.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/tests/test_Image.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -25,11 +25,9 @@
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.User import UnrestrictedUser
from zope.app.component.hooks import setSite
-from zope.component import getSiteManager
from zope.interface.verify import verifyClass
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 DummyCachingManager
from Products.CMFCore.tests.base.dummy import DummyCachingManagerWithPolicy
@@ -211,10 +209,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/trunk/CMFDefault/tests/test_RegistrationTool.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_RegistrationTool.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFDefault/tests/test_RegistrationTool.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -19,11 +19,9 @@
from Testing import ZopeTestCase
from Acquisition import Implicit
-from zope.component import getSiteManager
from zope.interface.verify import verifyClass
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
@@ -64,10 +62,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'
Modified: CMF/trunk/CMFTopic/skins/zpt_topic/topic_criteria_form.pt
===================================================================
--- CMF/trunk/CMFTopic/skins/zpt_topic/topic_criteria_form.pt 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/CMFTopic/skins/zpt_topic/topic_criteria_form.pt 2007-07-03 15:18:06 UTC (rev 77358)
@@ -12,7 +12,7 @@
</span>
</span>
<input type="submit" name="topic_editCriteria:action"
- value=" Save changes" />
+ value=" Save changes " />
<input type="submit" name="topic_deleteCriteria:action"
value=" Delete selected " />
<input type="hidden" name=":default_action" value="editCriteria" />
Modified: CMF/trunk/slurp_release.py
===================================================================
--- CMF/trunk/slurp_release.py 2007-07-03 15:08:59 UTC (rev 77357)
+++ CMF/trunk/slurp_release.py 2007-07-03 15:18:06 UTC (rev 77358)
@@ -133,7 +133,7 @@
, 'auth='
]
)
- except getopt.GetOptError:
+ except getopt.GetoptError:
self._usage()
for k, v in opts:
More information about the CMF-checkins
mailing list