[mod_python] Templates et. al.

Mike Looijmans nlv11281 at natlab.research.philips.com
Thu Mar 30 04:27:18 EST 2006


I tend to do most work on the server side, for the simple reason that you have to (re)do your 
validation there anyway, because the client may be, deliberately or not, deceiving you.

The basic pattern I apply:
- Modifications are POSTed back to the same page handler (usually with an "action=insert" or similar 
item, usually attached to the submit button)
- The handler tries to apply the update/insert/delete. If there is any problem (e.g. concurrent 
update), this phase throws an exception. The exception is caught in the page handler and displayed 
near the top of the page. The page then renders as usual, with user-supplied input applied.
- The page redirects to the 'final' "thank you" style page. This prevents a user posting the same 
update twice with a reload.

-- 
Mike Looijmans
Philips Natlab / Topic Automation


marinus van aswegen wrote:

 > 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 <mailto: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?
 >      >




More information about the Mod_python mailing list