[IronPython] Python Pages -- web application stack (like django, rails, ...)

Bill Merrill bill at monkey.org
Thu Jun 12 20:30:50 CEST 2008


This is exactly why there are so many.

-Bill

On Jun 12, 2008, at 2:19 PM, Charles Mason wrote:
>
> 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
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com




More information about the Ironpython-users mailing list