Fixing broken inline genshi tags on TG2.1

Turbogears 2.1 got a little issue with genshi templates being rendered as xml instead of xhtml. This causes the most various strange problems with tags nesting being closed in random points as the browser likes. This is caused by an improvement to the mechanism used to decide with rendering format to use that it is now based on the response content type. If your applications returns Content-Type text/xml or text/plain your templates will be rendered as xml or as plain text. But what happens with your application returns text/html which is the default case? Indeed in this case the application asks to your configuration file what to do, and as in your configuration file by default there isn’t any templating.genshi.method […]

Workaround for empty helpers in Turbogears 2.1

Last release of TG2.1 has a subtle bug due to the changes helpers management to support in pylons 1.0, this makes the “h” object appear as an empty dict instead of your application helpers module. The bug is already tracked on and as the fix is quite easy it will be probably fixed soon. In the mean time you can work around it by monkey patching the pylons.templating.pylons_globals (I do it in lib/ but any place is fine). import tg.render, pylons def patched_pylons_globals(): x = tg.render.my_pylons_globals() if x[’h’] == {}: conf = pylons.config._current_obj() x[’h’] = conf[’package’].lib.helpers return x pylons.templating.pylons_globals = patched_pylons_globals This will make your helpers work again in TG2.1. Please pay attention that this code is specific for […]