Wouldn't be nicer to have this on an external template? Something like [mako](http://www.makotemplates.org)? Just an opinion :-)