PDF reports result in exception

Bug #1169723 reported by Gediminas Paulauskas on 2013-04-16
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SchoolTool
Critical
Gediminas Paulauskas

Bug Description

Try to download any PDF report, get an exception.

Happens in Ubuntu Raring, that has new major versions of reportlab and z3c.rml

To reproduce, add to your versions section in buildout.cfg:

[versions]
reportlab = 2.6
z3c.rml = 2.0.0

------------------------------------------

Exception
KeyError: "'Times_New_Roman'\n handle_pageBegin args=()"

Traceback
File "/usr/lib/python2.7/dist-packages/zope/publisher/publish.py", line 132, in publish
  result = publication.callObject(request, obj)
File "/usr/lib/python2.7/dist-packages/zope/app/publication/zopepublication.py", line 205, in callObject
  return mapply(ob, request.getPositionalArguments(), request)
File "/usr/lib/python2.7/dist-packages/zope/publisher/publish.py", line 107, in mapply
  return debug_call(obj, args)
Extra information: <bound method GroupDetailPDFView.__call__ of <zope.browserpage.metaconfigure.GroupDetailPDFView object at 0xb24998ec>>
File "/usr/lib/python2.7/dist-packages/zope/publisher/publish.py", line 113, in debug_call
  return obj(*args)
File "/usr/lib/python2.7/dist-packages/schooltool/gradebook/browser/pdf_views.py", line 364, in __call__
  return super(BaseStudentDetailPDFView, self).__call__()
File "/usr/lib/python2.7/dist-packages/schooltool/app/browser/report.py", line 80, in __call__
  stream = rml2pdf.parseString(xml, filename=filename)
File "/usr/lib/python2.7/dist-packages/z3c/rml/rml2pdf.py", line 41, in parseString
  doc.process(output)
File "/usr/lib/python2.7/dist-packages/z3c/rml/document.py", line 584, in process
  self.doc.multiBuild(self.flowables)
File "/usr/lib/python2.7/dist-packages/reportlab/platypus/doctemplate.py", line 972, in multiBuild
  self.build(tempStory, **buildKwds)
File "/usr/lib/python2.7/dist-packages/reportlab/platypus/doctemplate.py", line 889, in build
  self.clean_hanging()
File "/usr/lib/python2.7/dist-packages/reportlab/platypus/doctemplate.py", line 517, in clean_hanging
  self.handle_flowable(self._hanging)
File "/usr/lib/python2.7/dist-packages/reportlab/platypus/doctemplate.py", line 769, in handle_flowable
  f.apply(self)
File "/usr/lib/python2.7/dist-packages/reportlab/platypus/doctemplate.py", line 146, in apply
  getattr(doc,arn)(*args)
File "/usr/lib/python2.7/dist-packages/reportlab/platypus/doctemplate.py", line 542, in handle_pageBegin
  self.pageTemplate.onPage(self.canv,self)
File "/usr/lib/python2.7/dist-packages/z3c/rml/template.py", line 146, in drawOnCanvas
  drawing.process()
File "/usr/lib/python2.7/dist-packages/z3c/rml/directive.py", line 113, in process
  self.processSubDirectives()
File "/usr/lib/python2.7/dist-packages/z3c/rml/directive.py", line 110, in processSubDirectives
  directive.process()
File "/usr/lib/python2.7/dist-packages/z3c/rml/canvas.py", line 59, in process
  getattr(canvas, self.callable)(**kwargs)
File "/usr/lib/python2.7/dist-packages/reportlab/pdfgen/canvas.py", line 1588, in setFont
  font = pdfmetrics.getFont(self._fontname)
File "/usr/lib/python2.7/dist-packages/reportlab/pdfbase/pdfmetrics.py", line 689, in getFont
  return findFontAndRegister(fontName)
File "/usr/lib/python2.7/dist-packages/reportlab/pdfbase/pdfmetrics.py", line 671, in findFontAndRegister
  face = getTypeFace(fontName)
File "/usr/lib/python2.7/dist-packages/reportlab/pdfbase/pdfmetrics.py", line 630, in getTypeFace
  return _typefaces[faceName]

Gediminas Paulauskas (menesis) wrote :

z3c.rml since 1.1.0 calls _reset when processing each document

A comment in z3c.rml.document.Document process method:

        # Reset all reportlab global variables. This is very important for
        # ReportLab not to fail.

Doing this, the fonts we registered are no longer set up correctly.

We register our own reset handler to setUpFonts again.

Changed in schooltool:
status: Confirmed → Fix Committed
assignee: nobody → Gediminas Paulauskas (menesis)
Changed in schooltool:
status: Fix Committed → Fix Released
summary: - KeyError: "'Times_New_Roman'\n handle_pageBegin args=()"
+ PDF reports result in exception
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers