[Zope] referencing tuples
Dianne Van Dulken
Dianne.VanDulken@team.ozemail.com.au
Tue, 23 Apr 2002 17:16:25 +1000
Hi all,
I was wondering if what I am trying to do is possible, or not.
I have a method that returns a list of tuple pairs eg:
[(firstname, Di), (lastname, van Dulken), (address, ...) ] etc.
I have no problem looping through this to get the sequence-item,
sequence-key information:
<dtml-in "getDetails(_.None, _, status='Active')">
<dtml-in sequence-item>
<dtml-var sequence-key> = <dtml-var sequence-item>
</dtml-in>
<hr>
</dtml-in>
works fine.
BUT, I really only want (on this page, the method is used on other pages) to
know a couple of the tuple details in the list.
I know I can get this by looping through the whole sequence and using
<dtml-if "sequence-key == 'firstname'">
but that seems an incredibly slow and clunky way of referencing it to me.
Is there anyway I can reference the tuple value by the tuple key without
having to loop through them that way? I've tried getitem('firstname') and
sequence-var-firstname, but neither of these work. I couldn't find any one
else asking this, so I assume it is too basic for normal people to query on.
I also know I can reference THE tuple I am after by using sequence-item[1]
(or whatever), but that rather removes the whole point of having name
variables.
Thanks
Di