[CMF-checkins] SVN: CMF/trunk/CMF - use ISiteRoot utility
Yvo Schubbe
y.2007- at wcm-solutions.de
Wed Mar 7 19:00:37 EST 2007
Log message for revision 73044:
- use ISiteRoot utility
Changed:
U CMF/trunk/CMFCore/MembershipTool.py
U CMF/trunk/CMFCore/tests/test_MembershipTool.py
U CMF/trunk/CMFDefault/Favorite.py
U CMF/trunk/CMFDefault/tests/test_Favorite.py
-=-
Modified: CMF/trunk/CMFCore/MembershipTool.py
===================================================================
--- CMF/trunk/CMFCore/MembershipTool.py 2007-03-07 23:52:58 UTC (rev 73043)
+++ CMF/trunk/CMFCore/MembershipTool.py 2007-03-08 00:00:36 UTC (rev 73044)
@@ -38,7 +38,7 @@
from interfaces import IMemberDataTool
from interfaces import IMembershipTool
from interfaces import IRegistrationTool
-from interfaces import IURLTool
+from interfaces import ISiteRoot
from interfaces.portal_membership \
import portal_membership as z2IMembershipTool
from permissions import AccessContentsInformation
@@ -522,8 +522,7 @@
# Delete members' local roles.
if delete_localroles:
- utool = getUtility(IURLTool)
- self.deleteLocalRoles( utool.getPortalObject(), member_ids,
+ self.deleteLocalRoles( getUtility(ISiteRoot), member_ids,
reindex=1, recursive=1 )
return tuple(member_ids)
Modified: CMF/trunk/CMFCore/tests/test_MembershipTool.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_MembershipTool.py 2007-03-07 23:52:58 UTC (rev 73043)
+++ CMF/trunk/CMFCore/tests/test_MembershipTool.py 2007-03-08 00:00:36 UTC (rev 73044)
@@ -27,6 +27,7 @@
from Products.CMFCore.MemberDataTool import MemberDataTool
from Products.CMFCore.PortalFolder import PortalFolder
from Products.CMFCore.interfaces import IMemberDataTool
+from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.interfaces import IURLTool
from Products.CMFCore.tests.base.dummy import DummySite
from Products.CMFCore.tests.base.dummy import DummyTool
@@ -141,12 +142,10 @@
def test_deleteMembers(self):
site = self._makeSite()
sm = getSiteManager()
+ sm.registerUtility(site, ISiteRoot)
mtool = site.portal_membership
members = site._setObject( 'Members', PortalFolder('Members') )
acl_users = site._setObject( 'acl_users', DummyUserFolder() )
- utool = site._setObject( 'portal_url', DummyTool() )
- sm.registerUtility(utool, IURLTool)
- wtool = site._setObject( 'portal_workflow', DummyTool() )
mdtool = site._setObject( 'portal_memberdata', MemberDataTool() )
sm.registerUtility(mdtool, IMemberDataTool)
newSecurityManager(None, acl_users.all_powerful_Oz)
Modified: CMF/trunk/CMFDefault/Favorite.py
===================================================================
--- CMF/trunk/CMFDefault/Favorite.py 2007-03-07 23:52:58 UTC (rev 73043)
+++ CMF/trunk/CMFDefault/Favorite.py 2007-03-08 00:00:36 UTC (rev 73044)
@@ -28,6 +28,7 @@
from zope.component.factory import Factory
from zope.interface import implements
+from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.interfaces import IURLTool
from Products.CMFUid.interfaces import IUniqueIdAnnotationManagement
@@ -66,7 +67,7 @@
self.title=title
self.remote_url=remote_url
self.description = description
-
+
def _getUidByUrl(self):
"""Registers and returns the uid of the remote object if
the unique id handler tool is available.
@@ -75,9 +76,8 @@
handler = queryUtility(IUniqueIdAnnotationManagement)
if handler is None or not hasattr(handler, 'register'):
return
-
- portal = getUtility(IURLTool).getPortalObject()
- obj = portal.restrictedTraverse(self.remote_url)
+
+ obj = getUtility(ISiteRoot).restrictedTraverse(self.remote_url)
return handler.register(obj)
def _getObjectByUid(self):
@@ -143,8 +143,7 @@
if remote_obj is not None:
return remote_obj
- portal_url = getUtility(IURLTool)
- return portal_url.getPortalObject().restrictedTraverse(self.remote_url)
+ return getUtility(ISiteRoot).restrictedTraverse(self.remote_url)
security.declarePrivate('_edit')
def _edit( self, remote_url ):
Modified: CMF/trunk/CMFDefault/tests/test_Favorite.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Favorite.py 2007-03-07 23:52:58 UTC (rev 73043)
+++ CMF/trunk/CMFDefault/tests/test_Favorite.py 2007-03-08 00:00:36 UTC (rev 73044)
@@ -22,6 +22,7 @@
from zope.testing.cleanup import cleanUp
from Products.CMFCore.interfaces import IMembershipTool
+from Products.CMFCore.interfaces import ISiteRoot
from Products.CMFCore.interfaces import IURLTool
from Products.CMFCore.testing import ConformsToContent
from Products.CMFCore.tests.base.dummy import DummySite
@@ -41,8 +42,8 @@
def setUp(self):
sm = getSiteManager()
self.site = DummySite('site')
- self.site._setObject( 'portal_membership', DummyTool() )
- sm.registerUtility(self.site.portal_membership, IMembershipTool)
+ sm.registerUtility(self.site, ISiteRoot)
+ sm.registerUtility(DummyTool(), IMembershipTool)
self.site._setObject( 'portal_url', DummyTool() )
sm.registerUtility(self.site.portal_url, IURLTool)
More information about the CMF-checkins
mailing list