Returning lists of Tuples from External Methods
Something special seems to happen if I return a list of two-element tuples from an external method. If I return a list of three-element tuples, Zope does what I expect. It allows me to sequence through each tuple in the list using <dtml-in> and then I use <dtml-var "_['sequence-item'][0]"> <dtml-var "_['sequence-item'][1]"> and <dtml-var "_['sequence-item'][2]"> to access elements of the tuple. But if I return a two element tuple, I get a list of the second element of the tuple when I use <dtml-in>. I suspect Zope is doing something like interpreting the tuple list as name/value pairs and adding them to the namespace. But I haven't found any documentation on it. Any clues on what is happening here? David S. Harrison (dsh@magma-da.com)
At 02:48 PM 11/8/99 -0800, David S. Harrison wrote:
But if I return a two element tuple, I get a list of the second element of the tuple when I use <dtml-in>. I suspect Zope is doing something like interpreting the tuple list as name/value pairs and adding them to the namespace. But I haven't found any documentation on it. Any clues on what is happening here?
When iterating over a sequence of two-item tuples, <dtml-in> puts the first item into "sequence-key" and the second into "sequence-item". It is indeed treating the sequence as a .items() style list.
participants (2)
-
David S. Harrison -
Phillip J. Eby