Graham Dumpleton
grahamd at dscpl.com.au
Tue Oct 19 22:34:53 EDT 2004
On Oct 19 21:58, Jorey Bump <list at joreybump.com> wrote: > > Subject: Re: [mod_python] Approaches to handling input forms. > > Graham Dumpleton wrote: > > > If the form and the processor of the form are at different urls, there is a > > better separation of functionality of presenting the form and its processing. > > I've found the opposite to be the case. That is, when the form submits > to itself, I can keep everything within the same context, including > conditional branching and error handling. I create a dispatch function > that looks at the form variables and acts accordingly. I move on to > another URL when there is no more processing to be done for that form > (which will often span multiple pages). > > Compared to earlier projects where I used different URLs, I'd have to > say that this method has encouraged me to reuse code more efficiently. > The separation of functionality occurs in the code, where it's most > important. The URLs serve as logical containers that distinguish the > various parts of the application. The responses so far have been really good. One thing I am curious about though is for those who use mod_python.publisher where form values can optionally be passed as parameters to the method being called, do you actually end up using that ability? The way I see it is that if a form takes many parameters and like in the above description the same URL might be used for a multistep form submission where the form values can change at each step, using the ability of mod_python.publisher to accept form values as parameters may just be more trouble than it is worth. This is because the same Python method has to be able to cope with a changing set of actual parameters at each phase of form submission. To me this suggests it is easier for the method simply to take only the req object and access req.form directly, rather than method parameters. What you perhaps end up with is using method parameters for quite simple forms, but for more complicated ones fallback to using req.form instead. Is this probably a fare enough thing to say? -- Graham Dumpleton (grahamd at dscpl.com.au)
|