[Zope-CMF] Re: [CMF 2.1] FSPageTemplate & Unicode

Hanno Schlichting plone at hannosch.info
Sun Jan 7 14:35:50 EST 2007


Hi Jens,

Jens Vagelpohl wrote:
> - I'll be happy to mark those places in the code where I had to
> manually wrap after a straight getUtility/queryUtility call so these
> places stand out as a reminder to do something about it.

I haven't marked those places yet, but attached you can find a patch
against the current CMFCore branch, that in combination with the small
change to DCWorkflow/Expressions.py noted earlier is needed to get most
of the tests for Plone running.

I still have one problem in the test case setup for functional tests,
where the portal isn't set as a site and thus the utility lookups don't
work, but as far as I can tell this is only a test case problem.

Hanno
-------------- next part --------------
Index: MembershipTool.py
===================================================================
--- MembershipTool.py	(revision 71776)
+++ MembershipTool.py	(working copy)
@@ -503,6 +503,7 @@
         # Delete member data in portal_memberdata.
         mdtool = queryUtility(IMemberDataTool)
         if mdtool is not None:
+            mdtool = mdtool.__of__(self)
             for member_id in member_ids:
                 mdtool.deleteMemberData(member_id)
 
@@ -513,7 +514,7 @@
 
         # Delete members' local roles.
         if delete_localroles:
-            utool = getUtility(IURLTool)
+            utool = getUtility(IURLTool).__of__(self)
             self.deleteLocalRoles( utool.getPortalObject(), member_ids,
                                    reindex=1, recursive=1 )
 
Index: MemberDataTool.py
===================================================================
--- MemberDataTool.py	(revision 71776)
+++ MemberDataTool.py	(working copy)
@@ -184,7 +184,7 @@
     def pruneMemberDataContents(self):
         """ Delete data contents of all members not listet in acl_users.
         """
-        membertool= getUtility(IMembershipTool)
+        membertool= getUtility(IMembershipTool).__of__(self)
         members = self._members
         user_list = membertool.listMemberIds()
 
Index: RegistrationTool.py
===================================================================
--- RegistrationTool.py	(revision 71776)
+++ RegistrationTool.py	(working copy)
@@ -159,7 +159,7 @@
         # Anyone is always allowed to grant the 'Member' role.
         _limitGrantedRoles(roles, self, ('Member',))
 
-        membership = getUtility(IMembershipTool)
+        membership = getUtility(IMembershipTool).__of__(self)
         membership.addMember(id, password, roles, domains, properties)
 
         member = membership.getMemberById(id)
Index: URLTool.py
===================================================================
--- URLTool.py	(revision 71776)
+++ URLTool.py	(working copy)
@@ -24,6 +24,7 @@
 from zope.interface import implements
 
 from ActionProviderBase import ActionProviderBase
+from interfaces import ISiteRoot
 from interfaces import IURLTool
 from interfaces.portal_url import portal_url as z2IURLTool
 from permissions import ManagePortal
@@ -74,7 +75,15 @@
     def getPortalObject(self):
         """ Get the portal object itself.
         """
-        return aq_parent( aq_inner(self) )
+        portal = aq_inner(self)
+        while True:
+            portal = getattr(portal, 'aq_parent', None)
+            if portal is None:
+                break
+            if ISiteRoot.providedBy(portal):
+                return portal
+        # Portal could not be found, log an error or raise one?
+        return aq_inner(self)
 
     security.declarePublic('getRelativeContentPath')
     def getRelativeContentPath(self, content):
Index: ActionInformation.py
===================================================================
--- ActionInformation.py	(revision 71776)
+++ ActionInformation.py	(working copy)
@@ -504,7 +504,7 @@
 
     def __init__( self, tool, folder, object=None ):
         self.portal = portal = aq_parent(aq_inner(tool))
-        membership = getUtility(IMembershipTool)
+        membership = getUtility(IMembershipTool).__of__(portal)
         self.isAnonymous = membership.isAnonymousUser()
         self.user_id = membership.getAuthenticatedMember().getId()
         self.portal_url = portal.absolute_url()
Index: PortalFolder.py
===================================================================
--- PortalFolder.py	(revision 71776)
+++ PortalFolder.py	(working copy)
@@ -125,7 +125,7 @@
             this folder.
         """
         result = []
-        portal_types = getUtility(ITypesTool)
+        portal_types = getUtility(ITypesTool).__of__(self)
         myType = portal_types.getTypeInfo(self)
 
         if myType is not None:
Index: CMFCatalogAware.py
===================================================================
--- CMFCatalogAware.py	(revision 71776)
+++ CMFCatalogAware.py	(working copy)
@@ -118,6 +118,7 @@
         if catalog is None:
             return
         path = '/'.join(self.getPhysicalPath())
+        catalog = catalog.__of__(self)
 
         # XXX if _getCatalogTool() is overriden we will have to change
         # this method for the sub-objects.


More information about the Zope-CMF mailing list