Hello, I'm a newbie in zope. I think is a simple problem but I can find a solution. I would like to show 2 lists (ex: list1 and list2) like this : list1 = 1, 2, 3,... list2 = A, B, C,... list1 + list2 = 1 A 2 B 3 C How can I iterate 2 lits in one dtml-in ? Can you help me ?
William JOYE wrote:
Hello,
I'm a newbie in zope. I think is a simple problem but I can find a solution. I would like to show 2 lists (ex: list1 and list2) like this :
list1 = 1, 2, 3,... list2 = A, B, C,...
list1 + list2 =
1 A 2 B 3 C
How can I iterate 2 lits in one dtml-in ?
for me the easiest way seems to combine the two lists and iterate over the results in a dtml in. problem is that doing this in dtml is hard cause of safety restrictions, in python its pretty slack though. here is a web python method that does the list work name: combine args l1, l2 return map( (lambda x,y:(x,y)), l1, l2) and the dtml <dtml-in "combine(list1, list2)"> <dtml-var sequence-key> - <dtml-var sequence-item> </dtml-in> Cheers Kapil
never mind... web python methods don't have access to map... so my example wouldn't work on a through the web python method... without defining a map function... dieter's method is better. Kapil Thangavelu wrote:
William JOYE wrote:
Hello,
I'm a newbie in zope. I think is a simple problem but I can find a solution. I would like to show 2 lists (ex: list1 and list2) like this :
list1 = 1, 2, 3,... list2 = A, B, C,...
list1 + list2 =
1 A 2 B 3 C
How can I iterate 2 lits in one dtml-in ?
for me the easiest way seems to combine the two lists and iterate over the results in a dtml in. problem is that doing this in dtml is hard cause of safety restrictions, in python its pretty slack though. here is a web python method that does the list work
name: combine args l1, l2 return map( (lambda x,y:(x,y)), l1, l2)
and the dtml
<dtml-in "combine(list1, list2)"> <dtml-var sequence-key> - <dtml-var sequence-item> </dtml-in>
Cheers
Kapil
_______________________________________________ Zope maillist - Zope@zope.org 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 )
Kapil Thangavelu wrote:
return map( (lambda x,y:(x,y)), l1, l2)
You can replace this with return map(None, l1, l2) You can see why via print map.__doc__ Cheers, Nils -- nika@acm.org | nika@kassube.de (preferred) 4kassube@informatik.uni-hamburg.de | nika@on-luebeck.de
participants (3)
-
Kapil Thangavelu -
Nils Kassube -
William JOYE