[mod_python] Templates et. al.

marinus van aswegen mvanaswegen at gmail.com
Tue Mar 28 01:42:13 EST 2006


Hi All

I'm trying to find a good pattern to do page updates. The use case is as
follow:
The user is presented with a page, the user enters data, the user is
provided with feedback e.g. validation errors, failure, success.

I have implemented this in two ways, but I'd like to hear how others have
approached this problem.

option 1:
create a page render function
create a page handler function
if there's validation problems call the render function with args e.g.
update status

option 2:
create a page render function
create a page handler function
if there's validation problems render the page using the handler function
e.g. update status

I prefer option 1, because it retains the user input and I don't have to
manually populate fields again (option 2) , however I get situations where
the new page is just appended below the previous page. Is there a way to
tell mod_python to clear the slate?

This is how I render pages:

    # load the appropriate templates, mangle and render
    req.content_type ='text/html'
    tmpl = psp.PSP(req, filename='template.html')
    content = psp.PSP(req, filename= 'welcome.html', vars = {} )
    tmpl.run ( vars = {'status': status, 'content': content } )
    return apache.OK


Cheers

Marinus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20060328/3705a685/attachment.html


More information about the Mod_python mailing list