[loggerhead/MERGE] Switch Loggerhead from KID to ZPT template engine

Toshio Kuratomi a.badger at gmail.com
Tue Jun 10 22:06:14 BST 2008


Martin Albisetti wrote:
> On Tue, Jun 10, 2008 at 12:16 PM, John Arbash Meinel
> <john at arbash-meinel.com> wrote:
>> Like I just did "python template fast" and found Mako, which claims this
>> benchmark:
> 
> Guillermo had mentioned Mako multiple times too, so it seems like
> something I should try sooner than later.
> There is one catch though, it's not tree-based, like
> Genshi/KID/ZPT/etc, which is probably why they have such an advantage
> of the other ones.
> Michael wasn't really happy by switching to a non-xml based engine,
> but I'm going to do some tests and see if the performance and
> dependency issue is attractive enough.
> 
> I also want to look into Pylons (http://pylonshq.com/) to substitute
> Turbogears, and that just happens to have Mako by default, and is
> compatible with 2.4 *and* 2.5.
> Hardy even has a pretty recent package.
> 
On frameworks:

TG2 will be based on pylons.  Both TG2 and pylons are pretty cool. 
They're both frameworks, though.  So if you want to have minimal 
external dependencies, this might not be the way to go (on the other 
hand, the way to avoid reinventing the wheel is to use a framework if 
you're doing work in a space that others have worked in.)  Pylons and 
TG2 use Paste for WSGI under the hood which makes them pretty nifty.  I 
could see making some wsgi-bzr middleware that would be pretty nifty for 
others to play around with.  (Like an exception handler that lets you 
browse the program's source code in bzr.  Now that would be a killer 
feature to show off the power of both bzr and Pylons/TG2/WSGI)

On templates:

mako and genshi serve different markets.  Genshi is great for generating 
correct xml/html.  mako is *great* for speed.

That said, if you want a tree based templating language but want better 
performance, there are ways to speed genshi up:

1) You can stop using <xi:include>.  At the PyCon TG sprint we 
determined that Genshi is taking a huge performance hit for every 
<xi:include> it does.  I don't know if this has been fixed yet: 0.5 has 
been released recently.

2) Use genshi's text template mode.  When I tested for some Fedora TG 
apps I found that Genshi's text template mode was quite a bit faster 
than its xml based template.  It could have been the <xi:include> 
problem as I wasn't aware of that so I didn't test xml-based templates 
that didn't have <xi:include>.

Aside from performance, using Genshi is a matter of stylistic preference 
as well.  One of Genshi's goals is to help you keep 
model-view-controller separate.  So it purposefully only supports simple 
code so you don't make big hacks in your view code (that's what the 
controller is for ;-).  If that appeals to you then you'll be willing to 
put up with genshi's limitations because you'll know you're probably 
doing something wrong if you hit them.  If it doesn't appeal to you, 
something like mako or cheetah would probably suit you better.

-Toshio

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20080610/11c1c799/attachment.pgp 


More information about the bazaar mailing list