[mod_python] publisher cgi

Jorey Bump list at joreybump.com
Tue Nov 7 09:31:11 EST 2006


Gregor Kling wrote:

>> You CAN use javascript to add fields before submitting the form.  That will 
>> work fine under CGI or mod_python.
>>
> Hm. Sure I can add it with JavaScript.
> But as i understand mod_publisher, there is a mapping between form data
> and paramaters in the equivalent method.
> So with adding several fields with JavaScript I have to add functions
> with a variable list of paramters, respectively for every probable
> combination of arguments a specific method ....

The automatic mapping of form data can useful in a simple, strictly 
controlled environment, but it's much better to use the standardized 
interface of the dictionary-like object req.form, as Jim suggests. This 
allows you to do simple, safe operations like:

for key in req.form.keys():
     do_stuff_with_key(key)

or:

if req.form.has_key('foo'):
     do_foo(req)

Note that req.form is *dictionary-like* and may still undergo changes to 
  make it behave more like a real dictionary. Try to use a recent 
version of mod_python to reduce incompatibilities.

Letting users name fields that are directly converted to top-level 
objects could cause severe namespace collisions, so don't even attempt 
that route.


More information about the Mod_python mailing list