[Zope-dev] Return anything but strings from a method??
Chris McDonough
chrism@digicool.com
Sat, 13 May 2000 14:48:26 -0400
Thomas,
An example external method:
def foo():
return [1,2,3]
A DTML method that calls the external method (also named foo) that
references the foo method:
<dtml-in foo>
<dtml-var sequence-item>
</dtml-in>
returns "1 2 3"
<dtml-var "foo()[0]">
returns "1"
Another python method:
def bar():
return {'a':1, 'b':2, 'c':3}
DTML:
<dtml-var "bar()['a']">
returns "1"
A minor note: please try not to send HTML formatted mail to the list.
Thanks!
Thomas Weholt wrote:
>
> Hi,
>
> I got a method in a product that should be able to return a list, a
> tuple or a dictionary but I cannot seem to use them in the same way as
> in plain python. Is there anything I should be aware of?
>
> I got a disk-based dictionary ( Berkley DB ) in which I`ve stored
> several customized classes? If I return a list of objects like this,
> how could I access this in DTML-code?
>
> If somebody could give me an example on how you can return a little
> more than just a string from a method to a dtml-document/method I`d be
> grateful. At the moment nothing but plain strings seem to work.
>
> Thomas
>
>
--
Chris McDonough
Digital Creations
Publishers of Zope - http://www.zope.org