How to use Genshi with web2py

[edit|delete]

0) Install Genshi

1) Download this

2) Save it in a place where python can find it

3) in your controller add:

import Genshi4web2py

4) in your actions return

return Genshi4web2py.render(dict(...), request, response)

instead of the usual

return dict(...)

5) To make Genshi the default for all views (instead of of normal web2py template language), at the top of your controller, after importing the Genshi4web2py module, state:

response.postprocessing.append(lambda x: Genshi4web2py.render(x, request, response))

Thanks to Timothy Farrell for submitting this recipe.



Post a comment