[Zope] Can dtml-in iterate over a list of lists?

Menard.Jean-Francois@hydro.qc.ca Menard.Jean-Francois@hydro.qc.ca
Thu, 19 Apr 2001 15:35:18 -0400


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C0C907.DD4EB1D0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Try:

<tr><td class=3D"1"><dtml-var "_['sequence-item'][0]"></td></tr>
<tr><td class=3D"1"><dtml-var "_['sequence-item'][1]"></td></tr>

Hope this helps!

Jean-Fran=E7ois M=E9nard
Intranet DPAS
Pratiques d'affaires et orientations
*        (514) 840-3000  poste 3939
*  (514) 840-5585
*  menard.jean-francois@hydro.qc.ca
*         855 Ste-Catherine est, 6e =E9tage
              Montr=E9al, Qu=E9. H2L 4P5


-----Message d'origine-----
De : Dunigan, Craig [mailto:craig.dunigan@esker.com]
Envoy=E9 : jeudi 19 avril 2001 15:01
=C0 : 'zope@zope.org'
Objet : [Zope] Can dtml-in iterate over a list of lists?


I have a Python script called "listArticles" that accepts a sort =
parameter
called "EWSortOrder," and returns a sorted list of lists.  I would like =
to
display the list of lists using a DTML method called "ArticleList" that
looks something like this:

<table>
<dtml-in expr=3D"listArticles(EWSortOrder)">
<tr><td class=3D"1">sequence-item[0]</td></tr>
<tr><td class=3D"2">sequence-item[1]</td></tr>
....
</dtml-in>
</table>

where sequence-item is obviously the list in the current iteration, but
clearly Zope isn't recognizing it as a list:

Error Type: KeyError
Error Value: sequence-item[0]

Traceback (innermost last):
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 222, =
in
publish_module
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 187, =
in
publish
  File /opt/Zope/ZopeInst/lib/python/Zope/__init__.py, line 221, in
zpublisher_exception_hook
    (Object: CatalogAware)
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 171, =
in
publish
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/mapply.py, line 160, in
mapply
    (Object: ArticleList)
  File /opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 112, =
in
call_object
    (Object: ArticleList)
  File /opt/Zope/ZopeInst/lib/python/OFS/DTMLMethod.py, line 189, in
__call__
    (Object: ArticleList)
  File /opt/Zope/ZopeInst/lib/python/DocumentTemplate/DT_String.py, =
line
538, in __call__
    (Object: ArticleList)
  File /opt/Zope/ZopeInst/lib/python/DocumentTemplate/DT_In.py, line =
711, in
renderwob
    (Object: listArticles(EWSortOrder))
  File /opt/Zope/ZopeInst/lib/python/DocumentTemplate/DT_Var.py, line =
276,
in render
    (Object: sequence-item[0])
KeyError: (see above)

Can I do this, and if so, how can I let dtml-in know to expect a list =
each
time?  I can't nest dtml-in's because each item in the sub-list is =
processed
a little differently.

Craig Dunigan
Web Programmer
Esker Software - Extending the Reach of Information
mailto:craig.dunigan@esker.com
Ph. 608.273.6000
Fax 608.273.8227
http://www.esker.com

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

------_=_NextPart_001_01C0C907.DD4EB1D0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>RE: [Zope] Can dtml-in iterate over a list of lists?</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>Try:</FONT>
</P>

<P><FONT SIZE=3D2>&lt;tr&gt;&lt;td =
class=3D&quot;1&quot;&gt;&lt;dtml-var =
&quot;_['sequence-item'][0]&quot;&gt;&lt;/td&gt;&lt;/tr&gt;</FONT>
<BR><FONT SIZE=3D2>&lt;tr&gt;&lt;td =
class=3D&quot;1&quot;&gt;&lt;dtml-var =
&quot;_['sequence-item'][1]&quot;&gt;&lt;/td&gt;&lt;/tr&gt;</FONT>
</P>

<P><FONT SIZE=3D2>Hope this helps!</FONT>
</P>

<P><FONT SIZE=3D2>Jean-Fran=E7ois M=E9nard</FONT>
<BR><FONT SIZE=3D2>Intranet DPAS</FONT>
<BR><FONT SIZE=3D2>Pratiques d'affaires et orientations</FONT>
<BR><FONT SIZE=3D2>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (514) =
840-3000&nbsp; poste 3939</FONT>
<BR><FONT SIZE=3D2>*&nbsp; (514) 840-5585</FONT>
<BR><FONT SIZE=3D2>*&nbsp; menard.jean-francois@hydro.qc.ca</FONT>
<BR><FONT SIZE=3D2>*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
855 Ste-Catherine est, 6e =E9tage</FONT>
<BR><FONT =
SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp; Montr=E9al, Qu=E9. H2L 4P5</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>-----Message d'origine-----</FONT>
<BR><FONT SIZE=3D2>De : Dunigan, Craig [<A =
HREF=3D"mailto:craig.dunigan@esker.com">mailto:craig.dunigan@esker.com</=
A>]</FONT>
<BR><FONT SIZE=3D2>Envoy=E9 : jeudi 19 avril 2001 15:01</FONT>
<BR><FONT SIZE=3D2>=C0 : 'zope@zope.org'</FONT>
<BR><FONT SIZE=3D2>Objet : [Zope] Can dtml-in iterate over a list of =
lists?</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>I have a Python script called =
&quot;listArticles&quot; that accepts a sort parameter</FONT>
<BR><FONT SIZE=3D2>called &quot;EWSortOrder,&quot; and returns a sorted =
list of lists.&nbsp; I would like to</FONT>
<BR><FONT SIZE=3D2>display the list of lists using a DTML method called =
&quot;ArticleList&quot; that</FONT>
<BR><FONT SIZE=3D2>looks something like this:</FONT>
</P>

<P><FONT SIZE=3D2>&lt;table&gt;</FONT>
<BR><FONT SIZE=3D2>&lt;dtml-in =
expr=3D&quot;listArticles(EWSortOrder)&quot;&gt;</FONT>
<BR><FONT SIZE=3D2>&lt;tr&gt;&lt;td =
class=3D&quot;1&quot;&gt;sequence-item[0]&lt;/td&gt;&lt;/tr&gt;</FONT>
<BR><FONT SIZE=3D2>&lt;tr&gt;&lt;td =
class=3D&quot;2&quot;&gt;sequence-item[1]&lt;/td&gt;&lt;/tr&gt;</FONT>
<BR><FONT SIZE=3D2>....</FONT>
<BR><FONT SIZE=3D2>&lt;/dtml-in&gt;</FONT>
<BR><FONT SIZE=3D2>&lt;/table&gt;</FONT>
</P>

<P><FONT SIZE=3D2>where sequence-item is obviously the list in the =
current iteration, but</FONT>
<BR><FONT SIZE=3D2>clearly Zope isn't recognizing it as a list:</FONT>
</P>

<P><FONT SIZE=3D2>Error Type: KeyError</FONT>
<BR><FONT SIZE=3D2>Error Value: sequence-item[0]</FONT>
</P>

<P><FONT SIZE=3D2>Traceback (innermost last):</FONT>
<BR><FONT SIZE=3D2>&nbsp; File =
/opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 222, =
in</FONT>
<BR><FONT SIZE=3D2>publish_module</FONT>
<BR><FONT SIZE=3D2>&nbsp; File =
/opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 187, =
in</FONT>
<BR><FONT SIZE=3D2>publish</FONT>
<BR><FONT SIZE=3D2>&nbsp; File =
/opt/Zope/ZopeInst/lib/python/Zope/__init__.py, line 221, in</FONT>
<BR><FONT SIZE=3D2>zpublisher_exception_hook</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; (Object: CatalogAware)</FONT>
<BR><FONT SIZE=3D2>&nbsp; File =
/opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 171, =
in</FONT>
<BR><FONT SIZE=3D2>publish</FONT>
<BR><FONT SIZE=3D2>&nbsp; File =
/opt/Zope/ZopeInst/lib/python/ZPublisher/mapply.py, line 160, in</FONT>
<BR><FONT SIZE=3D2>mapply</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; (Object: ArticleList)</FONT>
<BR><FONT SIZE=3D2>&nbsp; File =
/opt/Zope/ZopeInst/lib/python/ZPublisher/Publish.py, line 112, =
in</FONT>
<BR><FONT SIZE=3D2>call_object</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; (Object: ArticleList)</FONT>
<BR><FONT SIZE=3D2>&nbsp; File =
/opt/Zope/ZopeInst/lib/python/OFS/DTMLMethod.py, line 189, in</FONT>
<BR><FONT SIZE=3D2>__call__</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; (Object: ArticleList)</FONT>
<BR><FONT SIZE=3D2>&nbsp; File =
/opt/Zope/ZopeInst/lib/python/DocumentTemplate/DT_String.py, =
line</FONT>
<BR><FONT SIZE=3D2>538, in __call__</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; (Object: ArticleList)</FONT>
<BR><FONT SIZE=3D2>&nbsp; File =
/opt/Zope/ZopeInst/lib/python/DocumentTemplate/DT_In.py, line 711, =
in</FONT>
<BR><FONT SIZE=3D2>renderwob</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; (Object: =
listArticles(EWSortOrder))</FONT>
<BR><FONT SIZE=3D2>&nbsp; File =
/opt/Zope/ZopeInst/lib/python/DocumentTemplate/DT_Var.py, line =
276,</FONT>
<BR><FONT SIZE=3D2>in render</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; (Object: sequence-item[0])</FONT>
<BR><FONT SIZE=3D2>KeyError: (see above)</FONT>
</P>

<P><FONT SIZE=3D2>Can I do this, and if so, how can I let dtml-in know =
to expect a list each</FONT>
<BR><FONT SIZE=3D2>time?&nbsp; I can't nest dtml-in's because each item =
in the sub-list is processed</FONT>
<BR><FONT SIZE=3D2>a little differently.</FONT>
</P>

<P><FONT SIZE=3D2>Craig Dunigan</FONT>
<BR><FONT SIZE=3D2>Web Programmer</FONT>
<BR><FONT SIZE=3D2>Esker Software - Extending the Reach of =
Information</FONT>
<BR><FONT SIZE=3D2><A =
HREF=3D"mailto:craig.dunigan@esker.com">mailto:craig.dunigan@esker.com</=
A></FONT>
<BR><FONT SIZE=3D2>Ph. 608.273.6000</FONT>
<BR><FONT SIZE=3D2>Fax 608.273.8227</FONT>
<BR><FONT SIZE=3D2><A HREF=3D"http://www.esker.com" =
TARGET=3D"_blank">http://www.esker.com</A></FONT>
</P>

<P><FONT =
SIZE=3D2>_______________________________________________</FONT>
<BR><FONT SIZE=3D2>Zope maillist&nbsp; -&nbsp; Zope@zope.org</FONT>
<BR><FONT SIZE=3D2><A =
HREF=3D"http://lists.zope.org/mailman/listinfo/zope" =
TARGET=3D"_blank">http://lists.zope.org/mailman/listinfo/zope</A></FONT>=

<BR><FONT SIZE=3D2>**&nbsp;&nbsp; No cross posts or HTML =
encoding!&nbsp; **</FONT>
<BR><FONT SIZE=3D2>(Related lists - </FONT>
<BR><FONT SIZE=3D2>&nbsp;<A =
HREF=3D"http://lists.zope.org/mailman/listinfo/zope-announce" =
TARGET=3D"_blank">http://lists.zope.org/mailman/listinfo/zope-announce</=
A></FONT>
<BR><FONT SIZE=3D2>&nbsp;<A =
HREF=3D"http://lists.zope.org/mailman/listinfo/zope-dev" =
TARGET=3D"_blank">http://lists.zope.org/mailman/listinfo/zope-dev</A> =
)</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C0C907.DD4EB1D0--