Zope Sequences and Python Scripting

Terry Hancock hancock at anansispaceworks.com
Thu Apr 17 19:34:32 CEST 2003

Patrick W. Fraley wrote:
> I have a python script which returns a [] containing {}.  Now I can go
> thru the returned array (I know this is perl lingo, sorry that is my
> background) by using the <dtml-in> method, but I can not
> access the values of the dictionary contained within the sequence item.
> And here is what I am trying to do with the returned array:
> <dtml-in filter_row>
> <dtml-var filter_id><br>
> <dtml-var bez_ref><br>
> <dtml-var col_span><br>
> <hr>
> </dtml-in>

<dtml-in filter_row prefix="sq">
   <dtml-var expr="sq_item['filter_id']"><br>
   <dtml-var expr="sq_item['bez_ref']"><br>
   <dtml-var expr="sq_item['col_span']"><br>


<dtml-in filter_row>
  <dtml-with seq-item>
       <dtml-var filter_id><br>
       <dtml-var bez_ref><br>
       <dtml-var col_span><br>

(sorry, they're untested -- you may have to fix)

The point is, you will loop through the *sequence* of *dictionaries*. Then 
you act on each dictionary -- referencing its elements.  You can use python 
syntax to retrieve dictionary elements from the seq-item (prefix is a DTML 
kludge to make the syntax more python compatible), or "dtml-with" to make 
the dictionary the current namespace.  There are probably other ways to do 
it as well.


Terry Hancock
Anansi Spaceworks http://www.AnansiSpaceworks.com/

More information about the Python-list mailing list