On Tue, 4 Jul 2000, Pieter Claerhout wrote:
> I want the external method to return this in a list, where I can iterate over using
>the
> <dtml-in> tag, so that I can reference the different fields in each record with a
>name.
>
> What should the list look like so that I can accomplish this?
dtml-in eats a list of objects or a list of dictionaries.
Example 1.
class Item:
pass
Your external methods should return:
l = []
item1 = Item()
item1.date = "21/12/67"
item1.foo = "bar"
l.append(item1)
item2 = Item()
item2.date = "1/1/2000"
item2.foo = "baz"
l.append(item2)
...etc...
return l
In the DTML use the list: <dtml-in thelist><dtml-var date></dtml-in thelist>
Example 2 (dictionaries).
Your external methods should return:
l = []
item1 = {}
item1["date"] = "21/12/67"
item1["foo"] = "bar"
l.append(item1)
item2 = {}
item2["date"] = "1/1/2000"
item2["foo"] = "baz"
l.append(item2)
...etc...
return l
In the DTML use the list: <dtml-in thelist mapping><dtml-var date></dtml-in thelist>
^^^^^^^
dtml-in needs to be notified these are dicttionaries.
Oleg. (All opinions are mine and not of my employer)
----
Oleg Broytmann Foundation for Effective Policies [EMAIL PROTECTED]
Programmers don't die, they just GOSUB without RETURN.
_______________________________________________
Zope maillist - [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://lists.zope.org/mailman/listinfo/zope-announce
http://lists.zope.org/mailman/listinfo/zope-dev )