Commit 42b05aa8 authored by Jérome Perrin's avatar Jérome Perrin

Support the case where CMFReportTool is not installed.

In this case PDFTemplates will not work, but it does not prevent zope startup.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25331 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 325114fa
...@@ -203,30 +203,36 @@ registerFileExtension('pdft', FSPDFTemplate) ...@@ -203,30 +203,36 @@ registerFileExtension('pdft', FSPDFTemplate)
registerMetaType('ERP5 PDF Template', FSPDFTemplate) registerMetaType('ERP5 PDF Template', FSPDFTemplate)
# Dynamic Patch # Dynamic Patch
from Products.CMFReportTool.ReportTool import ReportTool
try: try:
from Products.CMFReportTool.ReportTool import ReportTool
except ImportError:
ReportTool = None
if ReportTool:
try:
from Products.CMFReportTool.ReportTool import ZODBResourceHandler from Products.CMFReportTool.ReportTool import ZODBResourceHandler
HAS_ZODB_RESOURCE_HANDLER=1 HAS_ZODB_RESOURCE_HANDLER=1
except ImportError: except ImportError:
from Products.CMFReportTool.ReportTool import ZODBHandler, ResourceHandler from Products.CMFReportTool.ReportTool import ZODBHandler, ResourceHandler
HAS_ZODB_RESOURCE_HANDLER=0 HAS_ZODB_RESOURCE_HANDLER=0
from Products.CMFReportTool.RenderPDF.Parser import TemplateParser,DocumentParser from Products.CMFReportTool.RenderPDF.Parser import TemplateParser,DocumentParser
try: try:
# Zope 2.10 and later. # Zope 2.10 and later.
from Products.PageTemplates.Expressions import boboAwareZopeTraverse from Products.PageTemplates.Expressions import boboAwareZopeTraverse
except ImportError: except ImportError:
# Zope 2.9 and earlier. # Zope 2.9 and earlier.
boboAwareZopeTraverse = None boboAwareZopeTraverse = None
from Products.PageTemplates.Expressions import restrictedTraverse from Products.PageTemplates.Expressions import restrictedTraverse
from StringIO import StringIO from StringIO import StringIO
import xml.dom.minidom import xml.dom.minidom
import urllib,os.path import urllib,os.path
if HAS_ZODB_RESOURCE_HANDLER: if HAS_ZODB_RESOURCE_HANDLER:
class ERP5ResourceHandler(ZODBResourceHandler): class ERP5ResourceHandler(ZODBResourceHandler):
''' Wrapper for ZODB Resources and files''' ''' Wrapper for ZODB Resources and files'''
...@@ -259,7 +265,7 @@ if HAS_ZODB_RESOURCE_HANDLER: ...@@ -259,7 +265,7 @@ if HAS_ZODB_RESOURCE_HANDLER:
obj = obj.data obj = obj.data
return StringIO(str(obj)) return StringIO(str(obj))
else: else:
class ERP5ResourceHandler(ResourceHandler): class ERP5ResourceHandler(ResourceHandler):
''' Wrapper for ZODB Resources and files''' ''' Wrapper for ZODB Resources and files'''
def __init__(self, context=None, resource_path=None): def __init__(self, context=None, resource_path=None):
...@@ -298,7 +304,7 @@ else: ...@@ -298,7 +304,7 @@ else:
def ReportTool_renderPDF(self, templatename, document_xml, *args, **kwargs): def ReportTool_renderPDF(self, templatename, document_xml, *args, **kwargs):
""" """
Render document using template Render document using template
""" """
...@@ -342,4 +348,4 @@ def ReportTool_renderPDF(self, templatename, document_xml, *args, **kwargs): ...@@ -342,4 +348,4 @@ def ReportTool_renderPDF(self, templatename, document_xml, *args, **kwargs):
return buf.read() return buf.read()
ReportTool.renderPDF = ReportTool_renderPDF ReportTool.renderPDF = ReportTool_renderPDF
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment