I'm having troubles passing a non-specified number of variables from a form to a method in one of my products. The (simplified) method is like this: def manage_editAction(self, *arguments, **keywords): "Prints values" print len(arguments) for arg in arguments: print "arg:", arg print len(keywords) for kw in keywords.keys(): print kw, ':', keywords[kw] And the corresponding dtml is like this: <html> <body> <form name="form" action="." method="post"> <input type='text' size='20' name="name"> <input type="submit" value="Change" name="manage_editAction:method"> </form> </body> </html> But this results in both len(arguments) and len(keywords) being 0 (I've tried with only one of them (*arguments or **keywords) as well). If I change the method to this: def manage_editAction(self, name): "Prints values" print "name:", name it works as predicted, the value of 'name' is printed. So why does it not work with a variable number of arguments? TIA, Jesper -- Jesper Holmberg |"But how can | jesper.holmberg@enst-bretagne.fr | one be warm | ENST Br, BP 832, 29285 Brest, FRANCE | alone?" |
Hi Jesper, Jesper Holmberg wrote:
I'm having troubles passing a non-specified number of variables from a form to a method in one of my products.
The (simplified) method is like this:
def manage_editAction(self, *arguments, **keywords): "Prints values" print len(arguments) for arg in arguments: print "arg:", arg print len(keywords) for kw in keywords.keys(): print kw, ':', keywords[kw]
do something like this: def manage_editAction(self, REQUEST): "Prints values" for key in REQUEST.form.keys(): print "%s: %s" % (key, REQUEST[key]) ... Holger
* On Sun Dec 02, Holger Hoffmann wrote:
Jesper Holmberg wrote:
I'm having troubles passing a non-specified number of variables from a form to a method in one of my products.
do something like this:
def manage_editAction(self, REQUEST): "Prints values" for key in REQUEST.form.keys(): print "%s: %s" % (key, REQUEST[key])
Thank you Holger! That was what I was looking for without knowing it. Jesper -- Jesper Holmberg |"But how can | jesper.holmberg@enst-bretagne.fr | one be warm | ENST Br, BP 832, 29285 Brest, FRANCE | alone?" |
participants (2)
-
Holger Hoffmann -
Jesper Holmberg