[ZPT] referencing items in lists

Chui G. Tey chui.tey@advdata.com.au
Fri, 2 Nov 2001 16:58:05 +1000


This is a multi-part message in MIME format.

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

This ought to be simple:
=20
I'm trying to do this:
=20
    <span tal:define=3D"mybookmarks python:('zope.org',  'Zope'),
('python.org', 'Python')"
          >
      <a tal:repeat=3D"bookmark mybookmarks"
         href=3D"dummy" span tal:attributes=3D"python: bookmark[0]"
tal:content=3D"bookmark[1]">
       Dummy link
      </a>
   </span>

To produce this:
=20
 <a href=3D"zope.org">Zope</a>
 <a href=3D"python.org">Python</a>
=20
But PageTemplates complain:
=20
<!-- Page Template Diagnostics
 Compilation failed
 Products.PageTemplates.TALES.CompilerError: Invalid variable name
"bookmark[0]"
-->
=20
How do I access the items of an Iterator in this case?
=20
Chui

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">


<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial size=3D2>This =
ought to be=20
simple:</FONT></SPAN></DIV>
<DIV><SPAN class=3D417095106-02112001></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial size=3D2>I'm =
trying to do=20
this:</FONT></SPAN></DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;=20
&lt;span tal:define=3D"mybookmarks python:('zope.org',&nbsp; 'Zope'),=20
('python.org',=20
'Python')"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;a tal:repeat=3D"bookmark=20
mybookmarks"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
href=3D"dummy"=20
span tal:attributes=3D"python: bookmark[0]"=20
tal:content=3D"bookmark[1]"&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Dummy=20
link<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/a&gt;<BR>&nbsp;&nbsp;=20
&lt;/span&gt;<BR></FONT></SPAN></DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial size=3D2>To =
produce=20
this:</FONT></SPAN></DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial =
size=3D2>&nbsp;&lt;a=20
href=3D"zope.org"&gt;Zope&lt;/a&gt;</FONT></SPAN></DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial =
size=3D2>&nbsp;&lt;a=20
href=3D"python.org"&gt;Python&lt;/a&gt;</FONT></SPAN></DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial size=3D2>But =
PageTemplates=20
complain:</FONT></SPAN></DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial =
size=3D2>&lt;!-- Page=20
Template Diagnostics<BR>&nbsp;Compilation=20
failed<BR>&nbsp;Products.PageTemplates.TALES.CompilerError: Invalid =
variable=20
name "bookmark[0]"<BR>--&gt;</FONT></SPAN></DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial size=3D2>How do =
I access the=20
items of an Iterator in this case?</FONT></SPAN></DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial=20
size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=3D417095106-02112001><FONT face=3DArial=20
size=3D2>Chui</FONT></SPAN></DIV></BODY></HTML>

------_=_NextPart_001_01C1636B.B87ED910--