Chuck Lima
cl at scriptall.com
Thu Oct 2 21:17:41 EST 2003
Yep, sure enough, I had multiple input fields named the same thing. I'm looping over a bunch of records and creating a form for each one on a single page and forgot to put a </form> at the end on each iteration!! Thank you. -Chuck On Thu, 2003-10-02 at 20:27, Michael S. Fischer wrote: > It didn't; whether the value is an object or a list depends on the form > submission contents. > > From http://www.python.org/doc/2.2.3/lib/node297.html: > > If the submitted form data contains more than one field with the same > name, the object retrieved by "form[key]" is not a FieldStorage or > MiniFieldStorage instance but a list of such instances. Similarly, in > this situation, "form.getvalue(key)" would return a list of strings. If > you expect this possibility (when your HTML form contains multiple > fields with the same name), use the isinstance() built-in function to > determine whether you have a single instance or a list of instances. For > example, this code concatenates any number of username fields, separated > by commas: > > > value = form.getvalue("username", "") > if isinstance(value, list): > # Multiple username fields specified > usernames = ",".join(value) > else: > # Single or no username field specified > usernames = value > > --Michael > > > Chuck Lima wrote: > > > A point of curiosity. Please don't hurt me. > > > > Some time ago, I was able to refer to a form field value in this manner: > > > > req.form["fieldname"] > > > > Now, I have to refer to the value in this fashion: > > > > req.form["fieldname"][0] > > > > Granted, it's been a while since I've done any new scripting with > > mod_python. I've searched the mailing list and looked at the docs for > > both v2 and v3 but can't find any reference to a change in the form > > attribute of the request object. > > > > When did the keys for req.form change to a list? > > > > Thanks, > > -Chuck > > > > _______________________________________________ > > Mod_python mailing list > > Mod_python at modpython.org > > http://mailman.modpython.org/mailman/listinfo/mod_python > > > >
|