Google App Engine: Templates

Posted by greg Thu, 08 May 2008 17:51:00 GMT

Google App Engine comes with Django templates support built-into the framework. All I can say is, WTF? Fundamentally, I believe in clean separation between display and logic. But what I have a problem with is the Django philosophy that python has no business inside the template. What? I can understand this thinking if you hired a bunch of retards to code your application. Bad things can happen to kids with no supervision. But come on! This is fascist. I believe your framework should work for you and not the other way around.

After digging into Django templates for a few weeks, I decided it wasn’t for me. Too much of my time was being devoted to writing custom tags which eventually would be replaced with python during the template compilation. I surveyed what else was out there. Right now, I’ve chosen to use Mako templates for the one simple fact: life is too short to deal with an extra layer of bullshit.

It appears using mako’s template caching with GAE is a no go, too. But this is a GAE thang since it doesn’t allow writing to disk. However, you can write python in your templates. I use Cheetah for building pages at my work. It’s pretty good, too. It has its quirks and from what I’ve read, it also works with GAE with minimal monkey patching.

One other thing I find odd with python web development is having to explicitly render a template and bind all your variables to in the first place. But this is also just me getting used to the pythonic way of life. This is just something I’ve taken for granted with .NET and Rails. There’s got to be a way to remove this extra step for every python controller action I code from here to eternity.

So there you go my devoted faithful… Learn it, live it, code it.

Comments

Leave a response

Comments