[Erp5-report] r17069 - /erp5/trunk/products/ERP5Form/PDFTemplate.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Oct 22 00:53:17 CEST 2007


Author: yo
Date: Mon Oct 22 00:53:17 2007
New Revision: 17069

URL: http://svn.erp5.org?rev=17069&view=rev
Log:
Adapt to the latest CMFReportTool.

Modified:
    erp5/trunk/products/ERP5Form/PDFTemplate.py

Modified: erp5/trunk/products/ERP5Form/PDFTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/PDFTemplate.py?rev=17069&r1=17068&r2=17069&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/PDFTemplate.py (original)
+++ erp5/trunk/products/ERP5Form/PDFTemplate.py Mon Oct 22 00:53:17 2007
@@ -212,7 +212,15 @@
   HAS_ZODB_RESOURCE_HANDLER=0
 
 from Products.CMFReportTool.RenderPDF.Parser import TemplateParser,DocumentParser
-from Products.PageTemplates.Expressions import restrictedTraverse
+
+try:
+    # Zope 2.10 and later.
+    from Products.PageTemplates.Expressions import boboAwareZopeTraverse
+except ImportError:
+    # Zope 2.9 and earlier.
+    boboAwareZopeTraverse = None
+    from Products.PageTemplates.Expressions import restrictedTraverse
+
 from StringIO import StringIO
 import xml.dom.minidom
 import urllib,os.path
@@ -225,7 +233,13 @@
     def handleZODB(self,path):
 
       path = path.split('/')
-      obj = restrictedTraverse(self.context,path,getSecurityManager())
+      if boboAwareZopeTraverse is None:
+          obj = restrictedTraverse(self.context,path,getSecurityManager())
+      else:
+          # XXX only the request should be required, but this looks ad-hoc..
+          econtext = dict(request=self.context.REQUEST)
+          obj = boboAwareZopeTraverse(self.context, path, econtext)
+
 
       # check type and e.g. call object if script ...
       if callable(obj):
@@ -256,7 +270,12 @@
     def zodb_open(self, req):
       path = req.get_selector()
       path = path.split('/')
-      obj = restrictedTraverse(self.context,path,getSecurityManager())
+      if boboAwareZopeTraverse is None:
+          obj = restrictedTraverse(self.context,path,getSecurityManager())
+      else:
+          # XXX only the request should be required, but this looks ad-hoc..
+          econtext = dict(request=self.context.REQUEST)
+          obj = boboAwareZopeTraverse(self.context, path, econtext)
 
       # check type and e.g. call object if script ...
       if callable(obj):




More information about the Erp5-report mailing list