It's a semi-documented feature... If "sequence-item" is a two-item tuple, the first element becomes "sequence-key" and the second element becomes "sequence-item". This is so that you can iterate over a dictionary's .items() without fuss, and dates back to the days when DocumentTemplates didn't have the wealth of other facilities they do now. The DTML reference covers this, sort of. If you look at the "Item variables defined by the in tag" table, sequence-key is explained. What it doesn't say is that it applies to any two-item tuple, not just ones that came from a mapping object's .items() method. At 07:21 AM 7/19/99 +0200, Alexander Staubo wrote:
Did I make a mistake in the following DTML?
<!--#in "[('a', 1), ('b', 2)]"--> <!--#var sequence-item--><br> <!--#/in-->
It turns out that this will only print "1" and "2" -- not "('a', 1)" and "('b', 2)" as I expected. However, if I add a third item to the tuples, it works:
<!--#in "[('a', 1, 0), ('b', 2, 0)]"--> <!--#var sequence-item--><br> <!--#/in-->
This prints out
('a', 1, 0) ('b', 2, 0)
Now, that's not right, is it?
(Verified with Zope 2.0.0a3.)