PyMeld for html templates?

Sean Schertell sean at datafly.net
Sun Jan 21 21:47:53 EST 2007


I'm trying to get PyMeld happening but I'm a bit stumped as to how to  
make it work with mod_python.

The pymeld docs show examples only for the Python command line  
interpreter and show using the print statement to output stuff. But  
using mod_python.apache, I think you need to use req.write(something)  
format. And of course, this fails when you feed it output from Meld.

Any tips?

Sean



On Jan 20, 2007, at 6:18 AM, Richie Hindle wrote:

> [Sean]
>> I wonder if anyone has any thoughts on PyMeld as a template
>> system for churning out general websites?
>
> I'm doing that (but then I would be wouldn't I? 8-)
> http://www.mandant.net is an example - the content of each page comes
> from a file containing just the content, the layout and sidebar are
> defined in a template HTML file, and the navigation is built by a
> Python script.  All that is pulled together using PyMeld into a set of
> HTML files and deployed to the web server (there's no need to it on  
> the
> fly for that site, but you certainly could).
>
>> I want for a URI request to mysite.com/info
>> to pull in a layout.html template which will in turn be populated by
>> the info.html template. [...]  how about PyMeld, any ideas on how
>> to do it or whether it will even work as I've described?
>
> You'd do something like this:
>
> from PyMeld import Meld
>
> LAYOUT = """<html><head><title id='title'>The Title</title></head>
> <body><div id='info'>The page information goes here.</div>
> <p id='footer>Copyright Me 2007.</p></body></html>"""
>
> INFO = """<html><head><title id='title'>The real title</title></head>
> <body id='info'><p>Here is the info, which would in the real world
> be read from a file.</p></body></html>"""
>
> page = Meld(LAYOUT)
> info = Meld(INFO)
> page.title = info.title._content
> page.info = info.info._content
> print page
>
> Is that the sort of thing you had in mind?
>
> -- 
> Richie Hindle
> richie at entrian.com
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list