Commit 2afc4dcc authored by Vincent Pelletier's avatar Vincent Pelletier

renderPDF must not be bound to a class, because it's only used as a "regular"...

renderPDF must not be bound to a class, because it's only used as a "regular" monkey patch for CMFReport's version. This change fixes PDFTemplate under Zope 2.8.
Updated some logs (even if they are commented out) to follow the naming change.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13751 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a9de0b52
...@@ -279,50 +279,48 @@ else: ...@@ -279,50 +279,48 @@ else:
class ERP5ReportTool(ReportTool): def ReportTool_renderPDF(self, templatename, document_xml, *args, **kwargs):
"""
def renderPDF(self, templatename, document_xml, *args, **kwargs): Render document using template
""" """
Render document using template
""" context = kwargs.get('context',None)
if context is None:
context = kwargs.get('context',None) context = self
if context is None:
context = self encoding = kwargs.get('encoding') or 'UTF-8'
#LOG('ReportTool_renderPDF', 0, 'encoding = %r' % encoding)
encoding = kwargs.get('encoding') or 'UTF-8' rhandler = ERP5ResourceHandler(context, getattr(self, 'resourcePath', None))
#LOG('ERP5ReportTool', 0, 'encoding = %r' % encoding)
rhandler = ERP5ResourceHandler(context, getattr(self, 'resourcePath', None)) # if zope gives us the xml in unicode
# we need to encode it before it can be parsed
# if zope gives us the xml in unicode template_xml = getattr(context, templatename)(*args, **kwargs)
# we need to encode it before it can be parsed if type(template_xml) is type(u''):
template_xml = getattr(context, templatename)(*args, **kwargs) template_xml = self._encode(template_xml, encoding)
if type(template_xml) is type(u''): if type(document_xml) is type(u''):
template_xml = self._encode(template_xml, encoding) document_xml = self._encode(document_xml, encoding)
if type(document_xml) is type(u''): #LOG('ReportTool_renderPDF', 0, 'template_xml = %r, document_xml = %r' % (template_xml, document_xml))
document_xml = self._encode(document_xml, encoding)
#LOG('ERP5ReportTool', 0, 'template_xml = %r, document_xml = %r' % (template_xml, document_xml)) # XXXXX Because reportlab does not support UTF-8, use Latin-1. What a mess.
template_xml = unicode(template_xml,encoding).encode('iso-8859-1')
# XXXXX Because reportlab does not support UTF-8, use Latin-1. What a mess. document_xml = unicode(document_xml,encoding).encode('iso-8859-1','replace')
template_xml = unicode(template_xml,encoding).encode('iso-8859-1') encoding = 'iso-8859-1'
document_xml = unicode(document_xml,encoding).encode('iso-8859-1','replace')
encoding = 'iso-8859-1' # create the PDFTemplate from xml
template_dom = xml.dom.minidom.parseString(template_xml)
# create the PDFTemplate from xml template_dom.encoding = encoding
template_dom = xml.dom.minidom.parseString(template_xml) template = TemplateParser(template_dom,encoding,resourceHandler=rhandler)()
template_dom.encoding = encoding
template = TemplateParser(template_dom,encoding,resourceHandler=rhandler)() # create the PDFDocment from xml
document_dom = xml.dom.minidom.parseString(document_xml)
# create the PDFDocment from xml document_dom.encoding = encoding
document_dom = xml.dom.minidom.parseString(document_xml) document = DocumentParser(document_dom,encoding,resourceHandler=rhandler)
document_dom.encoding = encoding
document = DocumentParser(document_dom,encoding,resourceHandler=rhandler) # create the PDF itself using the document and the template
buf = StringIO()
# create the PDF itself using the document and the template document(template,buf)
buf = StringIO() buf.seek(0)
document(template,buf) return buf.read()
buf.seek(0)
return buf.read()
ReportTool.renderPDF = ReportTool_renderPDF
ReportTool.renderPDF = ERP5ReportTool.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