[Zope] How to return two images by one procedure

Terry Hancock hancock@anansispaceworks.com
Tue, 1 Jul 2003 16:09:51 -0700


On Tuesday 01 July 2003 01:06 pm, Andreas Tille wrote:
> I worte an external procedure which returns an image.  Now I want
> to add an additional image showing a legend to exactly this
> dynamically created image.  Unfortunately I have no idea how
> I can make sure that this legend is connected to the image created
> in the external procedure.
> 
> Any idea how to solve this?

Return a tuple:

IN EXTERNAL METHOD:
def image_processing_function():
      return image1, image2

IN DTML TEMPLATE:
<dtml-let images="image_processing_function()">
     <dtml-var expr="images[0]">
     <dtml-var expr="images[1]">
</dtml-let>

(with lots of HTML formatting omitted, of course).

Note that in general, Python allows many-to-many
function mappings as a standard idiom:

(e,f,g) = example_function(a,b,c,d)

This is really "tuple unpacking" but note the symmetry
between arguments and return values.  Cool, huh?

So there's no need to stick to the usual idea of having
a single return value.

Cheers,
Terry


--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com