[mod_python] Templates et. al.

marinus van aswegen mvanaswegen at gmail.com
Wed Mar 29 02:37:37 EST 2006


Hi Jim

Perhaps I need to rephrase the question. If you want to provide feedback to
the client based on his input you have options:
1. Use Javascript
2. Render a new page with feedback (reading the input variables and
presenting them)
3. Append to the feedback current page (request), without reading the
variables.

I've implemented two methods, I'm curios to see how other people have
approached and solved this problem.


Regards

Marinus


On 3/28/06, Jim Gallacher <jpg at jgassociates.ca> wrote:
>
> marinus van aswegen wrote:
> > 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
> >
>
> I'm not sure what you mean by "clear the slate", but if your page is
> getting rendered twice then you are calling your render function twice
> in the same request. There is not enough context in the code snippet
> above to really tell what is happening. Perhaps you could post a more
> complete example?
>
> Jim
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20060329/b4747371/attachment.html


More information about the Mod_python mailing list