Zope Sequences and Python Scripting

Patrick W. Fraley patrick at fraley.de
Thu Apr 17 15:26:36 EDT 2003


On Thu, 17 Apr 2003 10:34:32 +0000, Terry Hancock wrote:

> 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>
>    <hr>
> </dtml-in>
> 
> or
> 
> <dtml-in filter_row>
>   <dtml-with seq-item>
>        <dtml-var filter_id><br>
>        <dtml-var bez_ref><br>
>        <dtml-var col_span><br>
>        <hr>
>   </dtml-with>
> </dtml-in>
> 
> (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.
> 
> Cheers,
> Terry

Well unfortunately the first one did the trick.  Unfortunately, because
this causes some other problems (this was just a short example).  I need
those variables in the current namespace.   But now I do have a basic idea
of what needs to be accomplished and I think I can take it from here.

Also after reading up a little more on Zope doc's I get the feeling that
I should be doing this with page templates instead. Any comments,
suggestions?

Thank you for your response,
Patrick






More information about the Python-list mailing list