[Zope-dev] Arbitrary Arguments?

Marshall Powers mpowers1 at stevens.edu
Sun Jun 6 18:47:45 EDT 2004


In Python, you can declare a function to accept an arbitrary number of 
arguments by adding an argument that starts with * or **. A *-prefixed 
argument gets a tuple of the non-keyworded arguments that follow the 
declared arguments, a **-prefixed arguments gets a dictionary of 
keyword:value pairs of the keyworded arguments not declared in the 
argument list preceding it. For example,

def foo(a, b=2, *stuff, **morestuff):
 for x in stuff:
  print x,

 print
 for k in morestuff.keys():
  print k, morestuff[k]

if i call
foo(1, 2, 3, 4, 5, 6, x='a', y='b', z='c')

foo will print
4 5 6
x a
y b
z c

My problem is that when I write a Script(Python) in zope, and declare a 
*- or **-prefixed argument to my script, I always get an empty tuple or 
dictionary. It's not that im using an undeclared argument or anything, 
otherwise my script would get a runtime error. It just that the tuple 
or dictionary is not given any values when I make a call with 'extra' 
arguments. 

Does zope just not support this python feature? Should I just parse the 
arguments myself from the URL?

Sorry for the confusion,

Marshall 


Stefan H. Holek wrote:


>ZPublisher can only fill in arguments it knows about, i.e. that are 
>mentioned in the script's signature.
>
>Stefan
>
>
>On Sonntag, Jun 6, 2004, at 01:16 Europe/Vienna, Marshall Powers wrote:
>
>> So what is the deal?
>
>--
>The time has come to start talking about whether the emperor is as well
>dressed as we are supposed to think he is.               /Pete McBreen/
>
>



More information about the Zope-Dev mailing list