Hi Stefan,

take a look at the _getPageTemplate method in rlwriter.py. Call it with a string which is a unique ID. The returned NextPageTemplate should be added to the reportlab story (a.k.a. RlWriter.elements)

Unfortunately this method is not used exclusively throughout the rlwriter.

note:

* the ID should be a string a not a unicode object since that caused problems a while ago * call NextPageTemplate before forcing a pagebreak b/c NextPageTemplates does change the page template for the *next* page

I hope this helps.

Regards,
Volker

On 08/18/2011 06:10 PM, Stefan Birkholz wrote:
Hello,

i added a new Template in pagetemplates.py by basically copypasting
TitlePage and modifying the __init__() and beforeDrawPage() functions.
In rlwriter.py at some point i call:

self.doc.addPageTemplate(MyNewTemplate)
elements.append(PageBreak())

This causes mw-render to go ballistic; for each chapter of the book an
error gets logged

2011-08-18T17:53:28 rlwriter.error>>  article failed: "u'Warranty'"
2011-08-18T17:53:28 rlwriter.error>>  Traceback (most recent call
last):
   File "/home/stefan/Projects/cg-mwlib.rl/lib/python2.7/site-packages/
mwlib.rl-0.12.8-py2.7.egg/mwlib/rl/rlwriter.py", line 405, in
articleRenderingOK
     testdoc.build(elements)
   File "/home/stefan/Projects/cg-mwlib.rl/lib/python2.7/site-packages/
mwlib.ext-0.12.3-py2.7-linux-i686.egg/mwlib/ext/reportlab/platypus/
doctemplate.py", line 796, in build
     self.handle_flowable(flowables)
   File "/home/stefan/Projects/cg-mwlib.rl/lib/python2.7/site-packages/
mwlib.ext-0.12.3-py2.7-linux-i686.egg/mwlib/ext/reportlab/platypus/
doctemplate.py", line 675, in handle_flowable
     f.apply(self)
   File "/home/stefan/Projects/cg-mwlib.rl/lib/python2.7/site-packages/
mwlib.ext-0.12.3-py2.7-linux-i686.egg/mwlib/ext/reportlab/platypus/
doctemplate.py", line 132, in apply
     getattr(doc,arn)(*args)
   File "/home/stefan/Projects/cg-mwlib.rl/lib/python2.7/site-packages/
mwlib.ext-0.12.3-py2.7-linux-i686.egg/mwlib/ext/reportlab/platypus/
doctemplate.py", line 550, in handle_nextPageTemplate
     raise ValueError, "can't find template('%s')"%pt
ValueError: can't find template('14.1 Warranty')
    handle_nextPageTemplate args=('14.1 Warranty',)

and there is no .pdf file created.

Leaving out the call to addPageTemplate works fine and yields no
errors.
According to e.g. this example for Reportlab:

http://code.activestate.com/recipes/123612-basedoctemplate-with-2-pagetemplate/

it appears that i also have to juggle around with calls to
nextPageTemplate(), the failure to do so seems consistent with the
Traceback above.

Could i get some information about how calls to addPageTemplate() and
nextPageTemplate() are handled in mwlib.rl?

Cheers,
  Stefan Birkholz


--
volker haas                 brainbot technologies ag
fon +49 6131 2116394        boppstraße 64
fax +49 6131 2116392        55118 mainz
[email protected]    http://www.brainbot.com/

--
You received this message because you are subscribed to the Google Groups 
"mwlib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/mwlib?hl=en.

Reply via email to