[Zope] Variable number of arguments

Jesper Holmberg jesper.holmberg@enst-bretagne.fr
Sun, 2 Dec 2001 19:58:15 +0100


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?"     |