[CMF-checkins] SVN: CMF/branches/jens_tools_as_utilities/CMF -
wrapped tools in some more places
Yvo Schubbe
y.2007- at wcm-solutions.de
Wed Jan 24 06:16:48 EST 2007
Log message for revision 72208:
- wrapped tools in some more places
Changed:
U CMF/branches/jens_tools_as_utilities/CMFCore/CachingPolicyManager.py
U CMF/branches/jens_tools_as_utilities/CMFCore/Expression.py
U CMF/branches/jens_tools_as_utilities/CMFCore/MembershipTool.py
U CMF/branches/jens_tools_as_utilities/CMFCore/RegistrationTool.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/DublinCore.py
U CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_RegistrationTool.py
-=-
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/CachingPolicyManager.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/CachingPolicyManager.py 2007-01-24 11:09:49 UTC (rev 72207)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/CachingPolicyManager.py 2007-01-24 11:16:47 UTC (rev 72208)
@@ -65,6 +65,7 @@
for use by CachingPolicy objects.
"""
pm = queryUtility(IMembershipTool)
+ pm = pm and pm.__of__(content)
if not pm or pm.isAnonymousUser():
member = None
else:
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/Expression.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/Expression.py 2007-01-24 11:09:49 UTC (rev 72207)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/Expression.py 2007-01-24 11:16:47 UTC (rev 72208)
@@ -91,7 +91,7 @@
'''
An expression context provides names for TALES expressions.
'''
- pm = getUtility(IMembershipTool)
+ pm = getUtility(IMembershipTool).__of__(portal)
if object is None:
object_url = ''
else:
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/MembershipTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/MembershipTool.py 2007-01-24 11:09:49 UTC (rev 72207)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/MembershipTool.py 2007-01-24 11:16:47 UTC (rev 72208)
@@ -148,6 +148,7 @@
mdtool = queryUtility(IMemberDataTool)
if mdtool is not None:
+ mdtool = mdtool.__of__(self)
try:
u = mdtool.wrapUser(u)
except ConflictError:
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/RegistrationTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/RegistrationTool.py 2007-01-24 11:09:49 UTC (rev 72207)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/RegistrationTool.py 2007-01-24 11:16:47 UTC (rev 72208)
@@ -174,7 +174,7 @@
return 0
if not self._ALLOWED_MEMBER_ID_PATTERN.match( id ):
return 0
- membership = getUtility(IMembershipTool)
+ membership = getUtility(IMembershipTool).__of__(self)
if membership.getMemberById(id) is not None:
return 0
return 1
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/DublinCore.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/DublinCore.py 2007-01-24 11:09:49 UTC (rev 72207)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/DublinCore.py 2007-01-24 11:16:47 UTC (rev 72208)
@@ -110,6 +110,7 @@
"""
if creator is None:
mtool = queryUtility(IMembershipTool)
+ mtool = mtool and mtool.__of__(self)
creator = mtool and mtool.getAuthenticatedMember().getId()
# call self.listCreators() to make sure self.creators exists
Modified: CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_RegistrationTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_RegistrationTool.py 2007-01-24 11:09:49 UTC (rev 72207)
+++ CMF/branches/jens_tools_as_utilities/CMFDefault/tests/test_RegistrationTool.py 2007-01-24 11:16:47 UTC (rev 72208)
@@ -18,14 +18,15 @@
import unittest
from Testing import ZopeTestCase
-from zope.component import getSiteManager
+from Acquisition import Implicit
+from zope.component import getGlobalSiteManager
from Products.CMFCore.interfaces import IMembershipTool
from Products.CMFCore.tests.base.testcase import RequestTest
from Products.CMFDefault.testing import FunctionalLayer
-class FauxMembershipTool:
+class FauxMembershipTool(Implicit):
def getMemberById( self, username ):
return None
@@ -70,20 +71,22 @@
Spam, spam, spam
"""
- tool = self._makeOne().__of__( self.root )
- self.root.portal_membership = FauxMembershipTool()
- sm = getSiteManager(self.root)
- sm.registerUtility(self.root.portal_membership, IMembershipTool)
+ rtool = self._makeOne()
+ mtool = FauxMembershipTool()
+ sm = getGlobalSiteManager()
+ sm.registerUtility(mtool, IMembershipTool)
props = { 'email' : INJECTED_HEADERS
, 'username' : 'username'
}
- result = tool.testPropertiesValidity( props, None )
+ result = rtool.testPropertiesValidity(props, None)
self.failIf( result is None, 'Invalid e-mail passed inspection' )
+ sm.unregisterUtility(mtool, IMembershipTool)
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(RegistrationToolTests))
More information about the CMF-checkins
mailing list