[Zope] DTML methods bafflement

Pavlos Christoforou pavlos@gaaros.msrc.sunysb.edu
Thu, 15 Apr 1999 14:00:30 -0400 (EDT)


Hi Martijn -

> 
> Now, here comes the confusing part -- passing an argument along:
> 
> First, we rewrite caller to this:
>   <!--#var "callee(arg=newarg)"-->
> 
> Then we make a DTML method called 'baffle':
>   <!--#var "caller(newarg='Bar!')"-->
> 
> When I try to view that DTML method, I get an error (appended at the
> end).
> 
> Why does this happen? I expect it's not a bug but a failure to
> understand on my part. In my understanding, methods of objects can pass

In python function arguments that have default values are evaluated at
'compilation' time.  

So for example the following code raises an error:

def callee(a=b):
	print b

Traceback (innermost last):
  File "<stdin>", line 1, in ?
NameError: b

>>> b=4
>>> def callee(a=b):
...     print a
... 
>>> callee()
4
>>> b=5
>>> callee()
4

Seems that Zope will not raise an error when the DTML is originally
defined, which is puzzling for me too. 

Pavlos