[mod_python] Approaches to handling input forms.

Graham Dumpleton grahamd at dscpl.com.au
Tue Oct 19 19:51:43 EDT 2004


A question on what people perceive as being best practice as far as dealing
with forms when using mod_python.

Imagine there is a form for logging into a site and its url is at "login". I've
ignored extensions in this discussion as different mechanisms may or may
not make it easy to use them.

Is there a tendency to have the form when submitted, post back using
the same url, ie., ACTION field in form is not set, or to a different url.

If the first approach is used, any type of content handler for the resource
must be able to deal with with both no form data or required form data.
If no form data, put up the form, else if form data process the posted form
appropriately.

Upon processing the form, if login was successful, it might redirect to
another resource, or if the login form was actually part of a larger page, it
may then enable display of what other information was on the page.

In this approach you tend to end up with a lot of things jumbled up into
one content handler and it could perceivably get a bit messy.

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.
Being different urls though, you might have to be a bit trickier as far as
using redirects to get back to where you want when login is sucessful
especially if it is a generic login processor.

How do people handle this in the different mechanisms that are available?
Is there a general concensus that one approach is much superior to the other?
Are there any specific things that could be put into a content handler system
that can make this aspect of processing forms easier?


--
Graham Dumpleton (grahamd at dscpl.com.au)


More information about the Mod_python mailing list