For some reason which I can’t really articulate, I’m not a huge fan of Django templating. I’d actually prefer to use Genshi with Google App Engine, but I need to wait until all the kinks are ironed out, since as far as I can tell it’s not quite working painlessly yet. Another templating option is Mako, which I’ve barely used, but I still prefer to Django templates. One nice thing about Mako: it’s faster than most Python templating engines out there. So, here’s a quickie on how I got Mako working with Google App Engine. It wasn’t tricky at all, but I thought I’d document it anyway.
Checkout Mako from SVN and copy the directory mako/lib/mako to the path of your application, eg, on Linux:
$ cp -r mako/lib/mako myapp
(where myapp is the directory that your GAE app lives in).
In your app, obviously you’ll need to import some parts of mako:
Then, whenever you want to render a template as output (say, at the end of a ‘get’ or ‘post’ method .. see the GAE templating example for some context), call something like:
foo, bar = "some", "enthralling text"
template_values = {
’some_foo’: foo,
’some_bar’: bar
}
# index.mako is the template file in our GAE app directory
path = os.path.join(os.path.dirname(__file__), ‘index.mako’)
# make a new template instance
templ = Template(filename=path)
# unpack the dictionary to become keyword arguments and render
self.response.out.write(templ.render(**template_values))
An example of some template text that could go into index.mako could be:
One possible modification: I need to look into it, but defining your Template class (eg templ in the example above) in the main() function (maybe as a global) rather than instantiating it every time it is rendered would probably give better performance.

The Mako templates in Google App Engine: seems to work for me by Andrew Perry, unless otherwise expressly stated, is licensed under a Creative Commons CC0 1.0 Universal License.
Followed your instructions and it seems to work. Thanks!
I was looking around for a django template alternative and came across your post which seems to be the only relevant link that google returns when searching: mako “google app engine”
Thanks for making the effort to write it up! It saved me some time, as I am new to Python and the details of importing and installing.
Glad it helped Bjorn !
Thank you very much, Andrew. It’s simple, but a black-box too, until you know what must be done. Thanks!
Yes, on one hand it seems so simple, it shouldn’t warrant it’s own blog post … and yet I knew putting it here would save myself and others time next time I use Mako with GAE. Glad it helped. I’ve since grown to tolerate Django templating, and actually have never ended up using Mako in a production GAE app