Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Perl Template Toolkit: Now in spicy new Python flavor

77 views
Skip to first unread message

eef...@gmail.com

unread,
Jan 14, 2008, 6:00:52 PM1/14/08
to
I'd like to inform the Python community that the powerful and popular
Template Toolkit system, previously available only in its original
Perl implementation, is now also available in a beta Python
implementation:

http://tt2.org/python/index.html

I created this port both as a fun programming project, and for use in
environments where Perl is not available, for reasons technical,
cultural, or otherwise. The extensive Perl test suites have also been
ported, and most templates require no or very little modification.

Discussion of the Python implementation should be conducted on the
main Template Toolkit developer mailing list; see the site above for
details.

SJ Carter

unread,
Jan 15, 2008, 2:29:58 PM1/15/08
to
Congrats. This will no doubt prove valuable to any Python programmer.

Joshua Kugler

unread,
Jan 15, 2008, 3:15:27 PM1/15/08
to pytho...@python.org
eef...@gmail.com wrote:
> I'd like to inform the Python community that the powerful and popular
> Template Toolkit system, previously available only in its original
> Perl implementation, is now also available in a beta Python
> implementation:
>
> http://tt2.org/python/index.html
>
> I created this port both as a fun programming project, and for use in
> environments where Perl is not available, for reasons technical,
> cultural, or otherwise. The extensive Perl test suites have also been
> ported, and most templates require no or very little modification.

I must say...wow. That would have saved me some time and hassle about a
year ago, but of course, I wouldn't have fell in love with pure XML
templates either. :) As someone who has used Template Toolkit quite a bit,
I must say that is is quite cool. Congrats on a job well done!

j

George Sakkis

unread,
Jan 15, 2008, 4:45:59 PM1/15/08
to

How does it compare with other "mainstream" Python template engines
such as Cheetah, Mako, etc. ? Unless I missed it, the documentation
covers the Perl version only.

George

eef...@gmail.com

unread,
Jan 16, 2008, 3:01:43 PM1/16/08
to
On Jan 15, 1:45 pm, George Sakkis <george.sak...@gmail.com> wrote:
> > eef...@gmail.com wrote:
> > > I'd like to inform the Python community that the powerful and popular
> > > Template Toolkit system, previously available only in its original
> > > Perl implementation, is now also available in a beta Python
> > > implementation:
>
> > >http://tt2.org/python/index.html
>
> > > I created this port both as a fun programming project, and for use in
> > > environments where Perl is not available, for reasons technical,
> > > cultural, or otherwise. The extensive Perl test suites have also been
> > > ported, and most templates require no or very little modification.

> How does it compare with other "mainstream" Python template engines


> such as Cheetah, Mako, etc. ?

I can't claim a comprehensive familiarity with Python template
offerings, but all of the packages approved for use at my previous
workplace left me cold. The most popular were ClearSilver and Django,
and both felt horribly limiting compared to the Template Toolkit,
which I became acquainted with when hacking on Bugzilla some years
ago. Neither supports what I would consider very basic operations on
the template data. Nothing like the following can be expressed in
those packages:


from pprint import PrettyPrinter
from template import Template

print Template().processString(
"the list is [% a.pformat(b(c + d)) %]",
{ "a": PrettyPrinter(2, 40), "b": range, "c": 10, "d": 20 }
)


Here we have a template that includes a method call, a function call,
and simple addition. Neither Django nor ClearSilver can manage any of
these three things. Both of those packages offer other features not
found in the Template Toolkit; it was the relative impotence of the
templating systems that drove me to attack the translation.

> Unless I missed it, the documentation
> covers the Perl version only.

The online documentation, yes. All source-level documentation (from
which the online documentation is largely drawn) has been converted
into Python docstrings in the source code. They can be read by
browsing the Subversion repository or by importing the code and using
help(); eg:

>>> import template.stash
>>> help(template.stash)
... module docs ...
>>> help(template.stash.Stash)
... class docs ...
>>> help(template.stash.Stash.get)
... method docs ...

Bruno Desthuilliers

unread,
Jan 17, 2008, 11:57:24 AM1/17/08
to
eef...@gmail.com a écrit :

> On Jan 15, 1:45 pm, George Sakkis <george.sak...@gmail.com> wrote:
>>> eef...@gmail.com wrote:
>>>> I'd like to inform the Python community that the powerful and popular
>>>> Template Toolkit system, previously available only in its original
>>>> Perl implementation, is now also available in a beta Python
>>>> implementation:
>>>> http://tt2.org/python/index.html
>>>> I created this port both as a fun programming project, and for use in
>>>> environments where Perl is not available, for reasons technical,
>>>> cultural, or otherwise. The extensive Perl test suites have also been
>>>> ported, and most templates require no or very little modification.
>
>> How does it compare with other "mainstream" Python template engines
>> such as Cheetah, Mako, etc. ?
>
> I can't claim a comprehensive familiarity with Python template
> offerings, but all of the packages approved for use at my previous
> workplace left me cold. The most popular were ClearSilver and Django,
> and both felt horribly limiting compared to the Template Toolkit,

ClearSilver is not a Python templating system, but a C templating system
with bindings for various languages including Python. Being (by design)
language-agnostic, it's indeed *very* limited (and that's an
understatement).

wrt/ Django templates, it indeed imposes severe limitations on what can
be simply expressed when you are familiar with Python. This is by design
- since it has been designed to be safe to use for non-programmers. Now
while not my cup of tea, it has proven to be fairly usable, quite less
limiting that what I feared at first, and really easy to use for our web
designer/integrator.

Now there are way more flexible/expressive templating systems in Python,
either XML oriented (genshi) or more generic (my favorite one so far
being Mako).

But anyway, I'm not the one that will complain with Perl templating
systems being ported to Python - FWIW, Mako was born from it's author
previous experience with porting Mason to Python !-)

Paul Boddie

unread,
Jan 17, 2008, 12:29:42 PM1/17/08
to
On 16 Jan, 21:01, "eef...@gmail.com" <eef...@gmail.com> wrote:
>
> I can't claim a comprehensive familiarity with Python template
> offerings, but all of the packages approved for use at my previous
> workplace left me cold.

There are a few offerings listed on this page:

http://wiki.python.org/moin/Templating

I suppose you could add Template Toolkit somewhere on that page,
indicating where it fits into the bigger picture.

Paul

eef...@gmail.com

unread,
Jan 18, 2008, 1:03:52 PM1/18/08
to
On Jan 16, 12:01 pm, "eef...@gmail.com" <eef...@gmail.com> wrote:
> On Jan 15, 1:45 pm, George Sakkis <george.sak...@gmail.com> wrote:
> > Unless I missed it, the documentation
> > covers the Perl version only.
>
> The online documentation, yes. All source-level documentation (from
> which the online documentation is largely drawn) has been converted
> into Python docstrings in the source code.

Augh! And I forgot to mention that there's a file README.python at
the top level of the repository that discusses several of the issues
that arose in converting a large Perl project into Python, and how I
addressed them. Possibly interesting reading.

http://tt2.org/svnweb/Template-Python/view/trunk/README.python

joshua.hi...@gmail.com

unread,
Oct 7, 2014, 9:51:54 PM10/7/14
to
Sorry, is anyone else having trouble opening the README.txt?

Chris Angelico

unread,
Oct 7, 2014, 10:09:42 PM10/7/14
to pytho...@python.org
You're top-posting from Google Groups in response to a six-year-old
post. At least you provided us with some context. But you're looking
at something pretty ancient, so a more appropriate response would be
to first search the web to see if the URL's changed, and if you're
still having trouble, to ask (as a brand new thread) something like "I
found this from six years ago, does anyone know if it's still
active?". We here on comp.lang.python / python-list don't have the
power to help you; you need the original author, whose contact details
can probably be found by poking around on the web site you quoted the
link to.

ChrisA
0 new messages