Turbogears and Genshi baby steps

Wednesday, September 20, 2006

These are the baby steps for using Genshi template system in Turbogears.

1 - In case you have not installed Genshi do....
easy_install Genshi

2 - Create a new turbogears project with...
tg-admin quickstart genshibasic

3 - Go to controllers.py in ./genshibasic/genshibasic directory

add this to the Root class

def genshi(self):
return dict(pretty="basic")

4 - create a new template file ( genshi.html ) in the templates directory of the project.

include this in genshi.html ...

<html xmlns="http://www.w3.org/1999/xhtml"
pretty ${pretty}

5 - Start your project with

python start-genshibasic.py

6 - Open your browser and type http://localhost:8080/genshi

The rest is to study carefully genshi documentation to be a black belt.

1 comments: to “ Turbogears and Genshi baby steps so far...


    Wrap widgets with ET().
    TurboGears widgets return KID ElementTree XML nodes, which Genshi needs to convert to use as HTML.
    (ToscaWidgets returns raw HTML)
    E.g.: Instead of ${bookmarks_widget.display(bookmarks)} use ${ET(bookmarks_widget.display(bookmarks))}