----- Original Message ----- From: "Ferhat Ayaz" <[EMAIL PROTECTED]>
To: <zope@zope.org>
Sent: Saturday, September 02, 2006 7:40 AM
Subject: [Zope] iterating dictionaries with dtml-in

I know it's a silly question. But I was not able to
find an example for this:

I have a list of dicts like

Now I want to iterate each 'name' like

I want to do this with DTML.

<dtml-in getDicts>
        HOW CAN I PUT the keys 'name' HERE ????
(getDicts returns the above list of dictionaries)

If getDicts returns a list of python dictionaries then you are going to require an outer loop (to run thru the list) and an inner loop (to run thru the keys of the current dictionary). Something like this will get you going in the right direction:

<dtml-let dictList="getDicts">
   <dtml-in dictList prefix=aDict>
       <dtml-in "aDict_item.keys()">
<dtml-var sequence-item>, <dtml-var "aDict_item[_['sequence-item']]">

However, it would be much easier to change your getDicts routine to format the data you need for your OPTION statements, instead of extracting this information via dtml.



Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to