[IronPython] Python Pages -- web application stack (like django, rails, ...)
Charles Mason
cemasoniv at gmail.com
Thu Jun 12 20:19:59 CEST 2008
On Thu, Jun 12, 2008 at 5:40 AM, Michael Foord <fuzzyman at voidspace.org.uk>
wrote:
>
> There are also plenty of templating languages:
>
> Stan (used by Nevow)
> Genshi
> Cheetah
> Mako
> ZPT (Zope)
> SimpleTal (another Zope one)
> Kid
> Django template language
> PTL (Python templating language used by Quixote)
> Clearsilver (written in C with bindings for many languages)
> PyMeld
>
Anyone want to take a stab at why there are so many? It seems trivial to
me. I know I will be ridiculed for my example, but this is what I use on my
personal webserver:
def PrintTemplate(file, templatedict):
buf = open(config.Root + "/templates/" + file).read()
regex = re.compile( r"{{{(.*?)}}}", re.MULTILINE | re.DOTALL )
templatedict = copy.copy( templatedict )
templatedict.update( config.DefaultDict )
pos = 0
for find in re.finditer( regex, buf ):
sys.stdout.write( buf[ pos : find.start(0) ] )
pos = find.end(0)
py = find.group(1)
exec( py, templatedict )
else:
if pos < len( buf ):
sys.stdout.write( buf[ pos: ] )
Now, people are very likely to tell me about how bad it is to use exec, but
since I'm the one programming the page, I know what's going through it.
In essence, this *is* a python template system.
C
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080612/4e24bec4/attachment.html>
More information about the Ironpython-users
mailing list