[Zope] Problems passing parameters to and external function

Steve Jibson stevej@parlant.com
Fri, 03 Dec 1999 08:28:08 -0700


I am using Zope 2.1.0 (src install on RedHat Linux 6.1) and I'm having a
bit of trouble with passing parameters to external functions.  I'm not
sure if it's a problem with Zope or maybe I just don't understand how it
should work.  Here's a description of what I'm seeing:

I have an external function (myFunc) that looks like this:

def myFunc(self, a, b):
    return a, b

I have a dtml document that looks like this:

myFunc returned: <dtml-var "myFunc(1,2)">

When I view the document, I get exactly what I expect:

myFunc returned: (1,2)

If, however, I modify myFunc to include a default value for b, like
this:

def myFunc(self, a, b=5):
    return a, b

when I view the document again, I get:

myFunc returned: (1,5)

even though I specified a value for b, it still uses the default.

Taking the story further, if I change my document as follows:

myFunc returned: <dtml-var "myFunc(0,1,2)">

I get a valid result again:

myFunc returned: (1,2)

Also, if I change the document as follows:

myFunc returned: <dtml-var "myFunc(1,b=2)">

it seems to work properly again displaying:

myFunc returned: (1,2)

Now, if we take this wierdness one step further and change the document
to look like this:

myFunc returned: <dtml-var "myFunc(a=1,b=2)">

Then I get a Zope error: "not enough arguments; expected 2, got 0" when
I veiw it.

It seems like the more I play with it, the stranger it gets.  (It seems
that the Zope gods are against me.)
Any help would be appreciated.

Thanks!

Steve Jibson
stevej@parlant.com