[Zope] DTML methods bafflement

Martijn Faassen M.Faassen@vet.uu.nl
Thu, 15 Apr 1999 19:05:28 +0200


Hi there,

I thought I'd figured out DTML methods, but here's something that I
intuitely think is possible, but gives me an error (in Zope 1.10.2). It
has to do with DTML methods (or documents, I don't think there's a
difference) calling each other.

My basic understanding:

A DTML method is a callable object, that functions as a method of a Zope
folder.

DTML methods can call other DTML methods, with the #call tag:

<!--#call callee-->

The call tag doesn't give any return value.

The #var tag does; it gives as return value the rendered HTML of the
called DTML object.

You can supply arguments to your calling DTML methods:

DTML method - 'caller'
  <!--#var "callee(arg='Foo!')"-->

DTML method - 'callee'
  <p>The arg was: <!--#var arg--></p>

This works as expected when rendering 'caller', you see:
  The arg was: Foo!

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
values on to each other. If it is my error, then perhaps we need some
document that describes what exactly is going on when DTML methods call
each other, how arguments are passed. I've been browsing through the
source but so far I'm not enlightened. I'm wishing for some easy to
remember algorithm/structure that's applied here.

A related question; in my perhaps broken view of DTML methods as methods
can get arguments, the concept of an 'argument list' (somewhat like in Z
SQL methods) for DTML methods (and documents) would be useful. I realize
acquisition can produce a whole lot of potential arguments (actually
being acquired as attributes), but perhaps there should be some way to
call up a list of everything that's in the namespace of a particular
DTML method (in particular circumstances). Something like that would
help my understanding, and might help debugging in general.
 
Regards,

Martijn

(and here's the promised error traceback from Zope:)

<!--
 Error type:  
 Error value: callee
 -->
</BODY></HTML>
<!--
Traceback (innermost last):
  File f:\Program Files\Zope\lib\python\ZPublisher\Publish.py, line 877,
in publish_module
  File f:\Program Files\Zope\lib\python\ZPublisher\Publish.py, line 590,
in publish
    (Info: /baffle/baffle)
  File f:\Program Files\Zope\lib\python\OFS\DTMLMethod.py, line 155, in
__call__
    (Object: baffle)
  File f:\Program Files\Zope\lib\python\OFS\DTMLMethod.py, line 151, in
__call__
    (Object: baffle)
  File f:\Program Files\Zope\lib\python\DocumentTemplate\DT_String.py,
line 513, in __call__
    (Object: baffle)
  File f:\Program Files\Zope\lib\python\DocumentTemplate\DT_Util.py,
line 266, in eval
    (Object: caller(newarg='Bar!'))
  File <string>, line 0, in ?
  File f:\Program Files\Zope\lib\python\OFS\DTMLMethod.py, line 147, in
__call__
    (Object: caller)
  File f:\Program Files\Zope\lib\python\DocumentTemplate\DT_String.py,
line 513, in __call__
    (Object: caller)
  File f:\Program Files\Zope\lib\python\DocumentTemplate\DT_Util.py,
line 266, in eval
    (Object: callee(arg=newarg))
  File <string>, line 0, in ?
NameError: (see above)

-->