[mod_python] publisher form values

Sean Jamieson sean at barriescene.com
Wed Jan 11 15:59:14 EST 2006


my suggestion: just omit the numeric part of the name, and access the 
fields as a list

in publisher:
def processform( req, the_field ):
    if type( the_field ) is list:
        for field in the_field:
           print field


Dave Britton wrote:

>I am running modpython 2.7 on apache 1.3
>I have an html form that is generated dynamically based on database entries,
>so it may have an arbitrary number of fields displayed. In the module that
>generates them they are numbered field1, field2, etc.
>eg: (dynamically output html)
>
><form action = "handleform" method = "post">
>Field1 <input type = "text" name = "field1"><br>
>Field2 <input type = "text" name = "field2"><br>
>Field3 <input type = "text" name = "field3"><br>
><input type = "submit"></form>
>
>-- now, there might be 1 or 2 or x number of input fields, so I want to use
>the **kwds parameter form for the processing function, eg:
>
>def handleform(req, **kwds):
>
>and I was hoping this would just work, and I would get a nifty and
>arbitarily long set of variables name field1 - fieldn, but I couldn't seem
>to make the syntax work. I reverted to just using this:
>
>cgi={}
> for i in req.form.list:
>      cgi[i.name]=i.value
>
>to construct my own dictionary, but I am wondering if there is supposed to
>be an easy way to do this in publisher and I am just too unfamiliar with
>using **kwds to figure it out.
>Thanks for any suggestions!
>
>-Dave Britton
>
>_______________________________________________
>Mod_python mailing list
>Mod_python at modpython.org
>http://mailman.modpython.org/mailman/listinfo/mod_python
>
>
>  
>



More information about the Mod_python mailing list