[CMF-checkins] SVN: CMF/branches/jens_tools_as_utilities/ - merging Hanno's patch to wrap tools in a few more places

Jens Vagelpohl jens at dataflake.org
Sun Jan 7 14:58:09 EST 2007


Log message for revision 71786:
  - merging Hanno's patch to wrap tools in a few more places
  

Changed:
  U   CMF/branches/jens_tools_as_utilities/CMFCore/ActionInformation.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/CMFCatalogAware.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/MemberDataTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/MembershipTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/PortalFolder.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/RegistrationTool.py
  U   CMF/branches/jens_tools_as_utilities/CMFCore/URLTool.py
  U   CMF/branches/jens_tools_as_utilities/DCWorkflow/Expression.py
  U   CMF/branches/jens_tools_as_utilities/DCWorkflow/tests/test_guard.py

-=-
Modified: CMF/branches/jens_tools_as_utilities/CMFCore/ActionInformation.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/ActionInformation.py	2007-01-07 18:32:31 UTC (rev 71785)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/ActionInformation.py	2007-01-07 19:58:08 UTC (rev 71786)
@@ -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()

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/CMFCatalogAware.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/CMFCatalogAware.py	2007-01-07 18:32:31 UTC (rev 71785)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/CMFCatalogAware.py	2007-01-07 19:58:08 UTC (rev 71786)
@@ -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.

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/MemberDataTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/MemberDataTool.py	2007-01-07 18:32:31 UTC (rev 71785)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/MemberDataTool.py	2007-01-07 19:58:08 UTC (rev 71786)
@@ -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()
 

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/MembershipTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/MembershipTool.py	2007-01-07 18:32:31 UTC (rev 71785)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/MembershipTool.py	2007-01-07 19:58:08 UTC (rev 71786)
@@ -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 )
 

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/PortalFolder.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/PortalFolder.py	2007-01-07 18:32:31 UTC (rev 71785)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/PortalFolder.py	2007-01-07 19:58:08 UTC (rev 71786)
@@ -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:

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/RegistrationTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/RegistrationTool.py	2007-01-07 18:32:31 UTC (rev 71785)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/RegistrationTool.py	2007-01-07 19:58:08 UTC (rev 71786)
@@ -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)

Modified: CMF/branches/jens_tools_as_utilities/CMFCore/URLTool.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/CMFCore/URLTool.py	2007-01-07 18:32:31 UTC (rev 71785)
+++ CMF/branches/jens_tools_as_utilities/CMFCore/URLTool.py	2007-01-07 19:58:08 UTC (rev 71786)
@@ -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):

Modified: CMF/branches/jens_tools_as_utilities/DCWorkflow/Expression.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/DCWorkflow/Expression.py	2007-01-07 18:32:31 UTC (rev 71785)
+++ CMF/branches/jens_tools_as_utilities/DCWorkflow/Expression.py	2007-01-07 19:58:08 UTC (rev 71786)
@@ -122,7 +122,7 @@
         'container':    container,
         'folder':       container,
         'nothing':      None,
-        'root':         wf.getPhysicalRoot(),
+        'root':         ob.getPhysicalRoot(),
         'request':      getattr( ob, 'REQUEST', None ),
         'modules':      SecureModuleImporter,
         'user':         getSecurityManager().getUser(),

Modified: CMF/branches/jens_tools_as_utilities/DCWorkflow/tests/test_guard.py
===================================================================
--- CMF/branches/jens_tools_as_utilities/DCWorkflow/tests/test_guard.py	2007-01-07 18:32:31 UTC (rev 71785)
+++ CMF/branches/jens_tools_as_utilities/DCWorkflow/tests/test_guard.py	2007-01-07 19:58:08 UTC (rev 71786)
@@ -206,7 +206,8 @@
 
         # Create compulsory context elements
         sm = getSecurityManager()
-        ob = DummyContent('dummy')
+        self.site._setObject('dummy', DummyContent('dummy'))
+        ob = self.site.dummy
         wf_def = self._getDummyWorkflow()
 
         # Initialize the guard with an ok guard
@@ -238,7 +239,8 @@
 
         # Create compulsory context elements
         sm = getSecurityManager()
-        ob = DummyContent('dummy')
+        self.site._setObject('dummy', DummyContent('dummy'))
+        ob = self.site.dummy
         wf_def = self._getDummyWorkflow()
 
         # Initialize the guard with an ok guard



More information about the CMF-checkins mailing list