On Mon, 08 Nov 1999 18:01:41 -0500, Phillip J. Eby wrote:
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.
So *that's* whats happening! Drove me crazy trying to get it to work here, and I finally came up with workaround that used sequence-index to subscript into the original sequence. Would that behavior be considered a bug? I kept looking for an option to dtml-in to tell it "hands off" my sequence and don't get smart with it. <dtml-with "_(results = ZopeFind(PARENTS[1], search_sub=1, REQUEST=REQUEST))"> <dtml-in results> <dtml-if "REQUEST.script != ''"> <dtml-let item="results[_['sequence-index']]" <!-- Work Around for dtml-in Behavior --> abs_path="_.string.split((URL2+'/'+item[0]), REQUEST.script)[1][1:]"> <dtml-var abs_path> <BR> <dtml-if "not item[1].meta_type in excludables"> <dtml-call "catalog_object(item[1], abs_path)"> <dtml-call "REQUEST.set('itemcount', itemcount+1)"> </dtml-if> </dtml-let> </dtml-if> </dtml-in> </dtml-with> -Jeff Rush