[Zope] using a dictionary returned from an external method

Ender kthangavelu@earthlink.net
Tue, 24 Oct 2000 17:54:37 -0700


Matthew Wilbert wrote:
> 
> I have some DTML that needs to call an external method that returns a dictionary.  I don't have any problem referencing the resulting dictionary by doing something like
> 
> <dtml-var externalMethod()['key1']>
> <dtml-var externalMethod()['key2']>

> .
>  .
> 
> However, I need to do this for several keys, and I don't
> want to call externalMethod several times.  Is there a
> way to assign the method result to another variable, or
> is it possible that DTML is smart enough not to do the
> call multiple times?  Or is there some other approach
> that I am not even thinking of?

<dtml-let mydict="externalMethod()">
<dtml-var "mydict['key1']">
</dtml-let>

i know dtml will cache results on the same method call in a single
request which generally makes it efficient to do stuff like

<dtml-if expensiveQuery>
	<dtml-var expensiveQuery>
<dtml-else>
	cheap skate;)
</dtml-if>

and i'm guessing the same should apply to external methods.

kapil