From Kid to Genshi – Changing template language

September 25, 2006

Genshi (formerly Markup) is a library that provides an integrated set of components for parsing, generating, and processing HTML, XML or other textual content for output generation on the web.

Replacing Kid with Genshi XML Template Language makes a lot of sense:

  • Better performance
  • Easier to debug
  • Uses standards like XPath and XInclude
  • TurboGears 1.1 will by default use Genshi as its template engine.

XInclude alone is a reason to use Genshi. It is an inclusion mechanism to facilitate modularity, and a recommendation by W3C.

Migrating to Genshi is very simple. Most things will work without change.

Below is an example of how i use Genshi to iterate over actions and include a template to display action details. I use the same template in other places to avoid duplication.
Read the rest of this entry »


Testing in TurboGears

September 11, 2006

I finally got time to continue on my GTD application. I wrote unit tests for all controller methods.

My first idea was to include a mock framework so I wouldn’t need to execute external logic in my tests, but then I realized that would be overkill. I’m using an in-memory database (SQLite) and executing the whole application stack (except for javascript). All tests runs within 10 seconds, which is acceptable.

TurboGears includes Nose, which is a test discovery and running process for unittest. Typing “nosetests” on the command line runs all tests in the project.

I’ve decided to later use AJAX in my application, and a good way to test the whole stack including javascript is to test with Selenium. I’ll leave this for later.

It just works

I have never felt such a joy developing a web application. I get into flow more often. Things just work and I rarely show the ‘what the heck happened’-face.

Read the rest of this entry »