[Zope] DTML parsing Python- tuples and lists

Andrew Diller dillera@isc.upenn.edu
Mon, 10 Apr 2000 15:20:17 -0400


On Sat, Apr 08, 2000 at 12:49:21PM -0700, Michel Pelletier wrote:
> 
> 
> Andrew Diller wrote:
> > 
> > Hello: I wondering how/if DTML can parse Python sequence types: the list and tuple.
> 
> The <dtml-in> tag iterates over sequences and it is loosely analogous to
> a python 'for'.
> 
> It is documented pretty thourougly in the DTML Programmers Guide on the
> Zope site.
> 

Yes, thanks. The biggest braincloud to disperse is the notion of the dtml-let and dtml-in sequence.

I managed to get it working with this code:

--------------
(this is taken from Amos's articles on xml.com)
-------------

<dtml-let results="findHost(username,password,host,domain)">
<dtml-in results >
<dtml-let X=sequence-item>
<dtml-in X>

<dtml-if sequence-end>
<table border=3 width=70%>
<TR BGCOLOR="#FFFF99">

<dtml-let Y=sequence-item>

<TD width=10%>
        Hostname:   </TD><TD> <dtml-var "Y['Hostname']">  </TD></TR>
<TD >   IP:         </TD><TD> <dtml-var "Y['IPv4Address']">           </TD></TR>
<TD >   Model:      </TD><TD> <dtml-var "Y['Model']">           </TD></TR>
<TD >   Vendor:     </TD><TD> <dtml-var "Y['Vendor']">           </TD></TR>
<TD >   EndUser:    </TD><TD> <dtml-var "Y['EndUser']">           </TD></TR>
<TD >   Room:       </TD><TD> <dtml-var "Y['Room']">           </TD></TR>
<TD >   HostType:   </TD><TD> <dtml-var "Y['HostType']">           </TD></TR>
<TD >   Contact:    </TD><TD> <dtml-var "Y['DNSContact']">           </TD></TR>
<TD >   Remarks:    </TD><TD> <dtml-var "Y['Remarks']">           </TD></TR>
<TD >   TTL:        </TD><TD> <dtml-var "Y['TTL']">           </TD></TR>
<TD >   ORG:        </TD><TD> <dtml-var "Y['ORG']">           </TD></TR>
<TD >   IP Range:   </TD><TD> <dtml-var "Y['IPv4Range']">           </TD></TR>
<TR><TD>  - End of Record-    </TD><TD>     <dtml-var "Y['Hostname']"></TD>

</dtml-let>
</table><HR>
</dtml-if>

</TR>
</dtml-in></dtml-let></dtml-in></dtml-let>

-------------

-andy