i am running into the same problem

did you find a solution?

On 2 פברואר, 16:44, tomtom5 <[email protected]> wrote:
> Hello, I'm very new to turbogears and currently digging into details.
> Now I run into troubles.
> The question is: how to call genshi to render a template with params
> into a string result?
>
> I try to return a pdf document, that is created via pisa (xhtml2pdf
> converter) from a genshi template:
> 1) My controller method fetches data (invoice, reports, ...) from data
> backend.
> 2) I would like to use genshi to render a html template (that defines
> the pdf presentation) into a string
> 3) Then I convert this String to PDF using pisa, and return the PDF.
>
> This stack works basically with attached controller code, but the
> genshi rendering doesn't work: anything in the py: namespace
> (<py:replace, <py:if..) is not executed/evaluated, while ${param}
> replacements work fine. Converting the result to pdf works perfektly
> again - but the templating logic is missing ;-) right now.
>
> I think I have to prepare the rendering in some way, but have no idea
> what is missing or how to call it to get the genshi rendering done
> well.
>
> import ho.pisa as pisa
> from pylons.templating import render_genshi
>
> @expose(content_type="application/pdf")
> def pisa_test(self, **kw):
>         filename = os.path.join(os.getcwd(), "pisa_test.pdf")
>         content = render_genshi('helloworld.reports.pisa_layout_test',
>                 dict(editor = "MyName", projectNumber="12345"))
>
>         f = file(filename, "wb")
>         pdf = pisa.CreatePDF(content, f)
>         f.close()
>         f = open(filename, 'rb')
>         pdf = f.read()
>         f.close()
>         return pdf
>
> Thanks for comments in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en.

Reply via email to