[Zope] Passing variables to a DTML method ...

Michel Pelletier michel@digicool.com
Thu, 23 Sep 1999 11:41:22 -0400


> -----Original Message-----
> From: Darran Edmundson [mailto:Darran.Edmundson@anu.edu.au]
> Sent: Thursday, September 23, 1999 11:03 AM
> To: zope@zope.org
> Subject: [Zope] Passing variables to a DTML method ...
> 
> 
> 
> Could someone explain how to pass variables to a
> DTML method?  For example, if I have the following
> in a DTML method:
> 
>  <dtml-call "REQUEST.set('testvar', 'value')">
>  <dtml-var "calledmethod(REQUEST)">

Due to some hysterical, I mean historical reasons you cannot simply
"call" a DTML Method unless you pass in a few things.

A DTML object needs a context in which to render itself.  This context
can be passed in one of three ways, as a 'client' object, a 'REQUEST'
mapping (any mapping) or as keyword arguments to the method.  For
example:

<dtml-var "calledmethod(_.None, _, testvar=value)">

is one way to do what your looking for.  _.None is the client (None), _
is the current namespace stack (thus the method will render itself in
the current context) and 'testvar=value' is a keyword argument for your
variable.

-Michel