[Zope] External methods returning multiple variables?

Oliver Bleutgen myzope@gmx.net
Fri, 02 Nov 2001 22:12:05 +0100


Doyon, Jean-Francois wrote:

> Hello,
> 
> I would like to have a DTML Method call an External Method that would set a
> bunch of variables that could be used further in the DTML using a simple
> <dtml-var myvariable> where myvariable was set by the External Method.
> 
> The trick is the name and number of variables isn't fixed.  So far I've
> managed to get all my name value pairs into a dictionary that I return with
> "return dictionary", but I'm not sure how to properly call this external
> method in order to make sure the dictionary gets returned ... can I even do
> that?  And once I get this dictionary accross, how do I use it in DTML ?
> 
> Am I on the right track here?
> 

Yupp, you are - at least something like this works for me.
You can use for instance

<dtml-with "external_method(your_input_data)" mapping>
<dtml-var your_dict_key1>
<dtml-var your_dict_key2>
</dtml-with>

(this is what works for me, but you don't know the keys beforehand,
do you?)

or (untested, but should work)

<dtml-call "REQUEST.set('my_dict',external_method(your_input_data))">
<dtml-in "my_dict.keys()">
<dtml-var sequence-item> has value
<dtml-var "my_dict[_['sequence-item']]">
</dtml-in>

There is also a mapping attribute for dtml-in, but I don't grasp it.

cheers,
oliver