Jim Gallacher
jpg at jgassociates.ca
Tue Mar 28 11:50:55 EST 2006
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
|