Chicken Scratches

Developing ideas on developing.
Page style (CSS):

Archive for May, 2008

Python templates – Django and Cheetah

May 28th, 2008 by Eddie Sullivan

When writing web applications, sooner or later (usually sooner), everybody is going to need a template language. String-interpolation just doesn't cut it. We need a way to write something that is almost all text (or HTML, or XML, or whatever), but with some dynamic pieces thrown in.

Since this need is so universal, and the basic requirements are so easy to describe, many different groups of people have taken it upon themselves to create Yet Another Template Language. As developers, we can join the fray and roll our own, or we can wade through the myriad options available to us to find the one that meets our needs or philosophy. Those who use PHP or ASP pretty much have the choice made for them, since the languages themselves are glorified template processors. Python programmers have a lot more options.

Here I'm just going to focus on the two Python templating languages I have used in real applications: Cheetah and the Django templating engine. (Django, of course, is more than just templates, but the template subsystem can be used independently.) I use and enjoy both of these, but there are significant differences that are worth comparing and contrasting, when deciding which to use for your particular needs. There are other comparisons out there, including one by the Benevolent Dictator for Life himself (though that's a bit out of date and inaccurate). When choosing which to use, you should read as many opinions as you can, then make the decision yourself. Presented here are just my personal thoughts.

Read the rest of this entry »

This month’s Limerick contest: Basketball

May 12th, 2008 by Eddie Sullivan

This month's contest over at limericks.chickenwingsoftware.com is Basketball: In this, the NBA playoff season, young man's fancy turns lightly to thoughts of hoops. Plus, the Celtics wear green!

A typical entry:

There once was a girl named Christine
Who had gotten the gambling gene
She said with some sadness,
"I lost at March Madness
Before it reached the sweet sixteen."

Sure, it's no masterpiece, but it's fun. That's sort of the spirit of these contests. Head on over to read more, rate them, or write your own.