Web development with Python 3.1

Terry Reedy tjreedy at udel.edu
Fri Oct 30 20:25:14 CET 2009


Dotan Cohen wrote:

> 
> It is clear and obvious. But it has the "template engine" duplicating
> a function that Python has built in.

...

>> Then use Mako - it uses plain Python to manage the presentation logic. And
>> if you go for Mako, then you might as well switch to Pylons. Great framework
>> too (better than Django on some parts FWIW), but you'll probably need much
>> more time to be fully productive with it (power and flexibility come with a
>> price...).
>>
> 
> Now we're talking! I will look further into Pylons and Mako.

I took a look a both yesterday. They are both generic text templating 
systems that seem to pretty much do the same thing. I suspect you will 
prefer Mako since it avoids duplicating Python's comtrol structures. But 
I think it worthwhile to look at both anyway since doing so will help to 
separate the concepts from the particular implementations.

My take on them is this: when text mixes code that is meant to be 
interpreted and text data meant to be taken literally, some means must 
be devised to distinguish the two. In programs files, the code is left 
unquoted and the text data is quoted. In template files, the marking is 
reversed: the literal text is left unquoted and the code *is* quoted. In 
Mako, expressions are quoted with braces ({...}), single statements with 
'%' prefix, and multiple statements as well as Mako tags with <% ...>.

Terry Jan Reedy




More information about the Python-list mailing list