[Zope-dev] Passing arguments to DTML Methods

Espen Sorbye Frederiksen ceeesf@cee.hw.ac.uk
Thu, 25 Jan 2001 22:03:31 +0000 (GMT)


Thank you Dieter!

Espen

On Thu, 25 Jan 2001, Dieter Maurer wrote:

> Espen Sorbye Frederiksen writes:
>  > How do you pass on variables to a DTML Method.
>  > If I would use a python method I would use <dtml-call "pythonmethod(var1,
>  > var2)">. This does not work with DTML Methods. First of all why? Secondly
>  > how is it possible to get around the problem?
> DTML Methods have 2 positional and arbitrary many keyword parameters.
> The positional arguments are "client" and "REQUEST".
> "client" is an object (or tuple of objects or None).
> All attributes of "client" are put into the DTML namespace.
> "REQUEST" is a mapping object (or None), all keys of this
> object are put into the DTML namespace.
> All keyword arguments are put into the DTML namespace.
>
> Thus, you can use:
>
>       <dtml-XXX "method(_.None,_,param1=value1, param2=value2, ...)">
>
> In this use: "_.None" is the client and "_" the mapping object.
> You must pass the "_" as otherwise, you break the DTML namespace
> chain.
>
> An alternative, probably easier:
>
>      <dtml-let param1="value1"
>                param2="value2"
> 	       ....>
>        <dtml-XXX method>
>      </dtml-let>
>
> i.e. you bring the arguments into the DTML namespace (with the "let")
> and then let DTML automatically pass the namespace to your method.
>
>
>
> Dieter
>