[Erp5-report] r20953 - /erp5/trunk/products/CMFActivity/ActivityTool.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed May 14 11:50:11 CEST 2008


Author: vincent
Date: Wed May 14 11:50:10 2008
New Revision: 20953

URL: http://svn.erp5.org?rev=20953&view=rev
Log:
PARENTS are stripped by REQUEST.copy(), always recreate them.
Also, recreate them with activity_tool path: originaly, they lead to timer server control panel, which is outside of erp5 site. This way, acquisition using PARENTS value will be able to access objects inside the site.

Modified:
    erp5/trunk/products/CMFActivity/ActivityTool.py

Modified: erp5/trunk/products/CMFActivity/ActivityTool.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/ActivityTool.py?rev=20953&r1=20952&r2=20953&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/ActivityTool.py (original)
+++ erp5/trunk/products/CMFActivity/ActivityTool.py Wed May 14 11:50:10 2008
@@ -823,12 +823,18 @@
         # Grab existig request (last chain item) and create a copy.
         request_container = base_chain.pop()
         request = request_container.REQUEST
+        # Generate PARENTS value. Sadly, we cannot reuse base_chain since
+        # PARENTS items must be wrapped in acquisition
+        parents = []
+        application = self.getPhysicalRoot().aq_base
+        for parent in self.aq_chain:
+          if parent.aq_base is application:
+            break
+          parents.append(parent)
         # XXX: REQUEST.clone() requires PARENTS to be set, and it's not when
         # runing unit tests. Recreate it if it does not exist.
-        parents = getattr(request, 'PARENTS', None)
-        if parents is None:
-          warn('CMFActivity.ActivityTool.invoke: PARENTS is not defined in REQUEST. It should only happen in unit tests.')
-          request['PARENTS'] = self.aq_chain[:]
+        if getattr(request.other, 'PARENTS', None) is None:
+          request.other['PARENTS'] = parents
         # XXX: itools (used by iHotfix) requires PATH_INFO to be set, and it's
         # not when runing unit tests. Recreate it if it does not exist.
         if request.environ.get('PATH_INFO') is None:
@@ -837,6 +843,8 @@
         # restore request information
         new_request = request.clone()
         request_info = message.request_info
+        # PARENTS is truncated by clone
+        new_request.other['PARENTS'] = parents
         new_request._script = request_info['_script']
         if 'SERVER_URL' in request_info:
           new_request.other['SERVER_URL'] = request_info['SERVER_URL']




More information about the Erp5-report mailing list