<div>This is the code that I have:</div>
<span tal:repeat="bitem_id bitem_ids" tal:omit-tag=""><br>
<span tal:define="bitem python:here.basketItemManager.getItem(bitem_id);<br>
item python:here.marketItems.getItem(bitem.marketItemId)"<br>
tal:omit-tag=""><br>
<div> </div>
<div>This is the code that I would like to write:</div>
<span tal:repeat="bitem_id bitem_ids" tal:omit-tag=""<br>
"""for each new bitem_id increment x"""><br>
<span tal:define="bitem python:here.basketItemManager.getItem(bitem_id);<br>
item python:here.marketItems.getItem(bitem.marketItemId)"<br>
tal:omit-tag=""><br>
<div><br>
How can I do that?<br>
TIA,<br>
Tony<br>
<br>
-----Original Message-----<br>
From: tonylabarbara@aol.com<br>
To: jhreis@gmail.com; zope@zope.org<br>
Sent: Mon, 30 Jul 2007 2:30 pm<br>
Subject: Re: [Zope] Increment In PT?<br>
<br>
</div>
<div id=AOLMsgPart_3_7a3d0e67-624a-43fd-9003-a52988ab05ae>
<div>It's complaining that:</div>
<div><STRONG>Error Type: TypeError</STRONG><br>
<STRONG>Error Value: string indices must be integers</STRONG><br>
</div>
<div>I tried back ticks and that still gave the same error.<br>
TIA,<br>
Tony<br>
</div>
<BLOCKQUOTE style="PADDING-LEFT: 3px; BORDER-LEFT: blue 2px solid"><tal:loop repeat="item bitems"><br>
<input type="hidden" tal:attributes="value item/name; name string:item_name_${repeat/item/number}"><br>
<input type="hidden" tal:attributes="value item/id; name string:item_number_${repeat/item/number}"> <br>
</tal:loop><br>
</BLOCKQUOTE><br>
<br>
<br>
-----Original Message-----<br>
From: José Henrique <<A href="mailto:jhreis@gmail.com">jhreis@gmail.com</A>><br>
To: <A href="mailto:zope@zope.org">zope@zope.org</A><br>
Sent: Mon, 30 Jul 2007 2:07 pm<br>
Subject: Re: [Zope] Increment In PT?<br>
<br>
<div id=AOLMsgPart_3_245c7f9e-8639-46df-99e0-47f87ae7b1a9>Try this way:<br>
<br>
<tal:loop repeat="item bitems"><br>
<input type="hidden" tal:attributes="value item/name; name string:item_name_${repeat/item/number}"><br>
<input type="hidden" tal:attributes="value item/id; name string:item_number_${repeat/item/number}"> <br>
</tal:loop><br>
<br>
Zenrique.<br>
<br>
<div><SPAN class=gmail_quote>2007/7/30, Peter Bengtsson <<A href="mailto:peter@fry-it.com">peter@fry-it.com</A>>:</SPAN>
<BLOCKQUOTE class=gmail_quote style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">You should now have all the parts.<br>
Instead of iterating over python:range(1000) do it on bitem_ids instead.<br>
<br>
You don't have to use a <br /> tag. You can use<br>
<input tal:attributes="value iter/number" /> <br>
if you want.<br>
You increment it by calling tal:iter/next whichever way you do it.<br>
<br>
<A href="mailto:tonylabarbara@aol.com">tonylabarbara@aol.com</A> wrote:<br>
> I would think this should be pretty easy in the PT itself, given what <br>
> you've shared so far. But I'm still not quite there. Here's what I've got:<br>
><br>
> <span tal:repeat="bitem_id bitem_ids" tal:omit-tag=""><br>
> <div tal:define="iter <br>
> python:modules['ZTUtils'].Iterator(range(1000))"><br>
> <br tal:define="x iter/next" tal:replace="iter/number" /><br>
><br>
> Now, I don't really want that <br /> tag there, because it's printing a <br>
> number to screen that I don't want there. However, it only prints the<br>
> number "1" twice, once for each product, when it should print 1 then 2,<br>
> I would think. (I presume I should just take the tal:replace out and <br>
> leave the definition, but it's still not incrementing!) Later in the<br>
> script I have this:<br>
><br>
> <input type="hidden" tal:attributes="value item/name;<br>
> name python:'item_name_' + `x`"> <br>
> <input type="hidden" tal:attributes="value item/id; name<br>
> python:'item_number_' + `x`"><br>
><br>
> and other similar lines. What I'm trying to effectuate is that the "x" <br>
> gets replaced with an incremented number. Can you help just a little more?<br>
> TIA,<br>
> Tony<br>
><br>
> -----Original Message-----<br>
> From: Peter Bengtsson <<A href="mailto:peter@fry-it.com"> peter@fry-it.com</A>><br>
> To: <A href="mailto:tonylabarbara@aol.com">tonylabarbara@aol.com</A><br>
> Cc: <A href="mailto:zope@zope.org">zope@zope.org</A><br>
> Sent: Mon, 30 Jul 2007 1:32 pm<br>
> Subject: Re: [Zope] Increment In PT? <br>
><br>
> You can use the ZTUtils Iterator()<br>
><br>
> <div tal:define="iter python:modules['ZTUtils'].Iterator(range(1000))"><br>
> <br tal:define="dummy iter/next" tal:replace="iter/number" /> <br>
> <br tal:define="dummy iter/next" tal:replace="iter/number" /><br>
> <br tal:define="dummy iter/next" tal:replace="iter/number" /><br>
> </div><br>
><br>
> Which might give you some freedom such as iter/Roman or iter/odd<br>
> The above is practically the same as:<br>
><br>
> <br tal:repeat="i python:range(3)" tal:replace="i" /> <br>
><br>
> Generally, if you can, use a Python Script or something. The Iterator<br>
> is/was used in Plone templates to increment the tab index.<br>
><br>
> <A href="mailto:tonylabarbara@aol.com">tonylabarbara@aol.com </A><mailto:<A href="mailto:tonylabarbara@aol.com">tonylabarbara@aol.com</A>> wrote:<br>
> > Hi;<br>
> > I´m trying to increment a variable in a page template. Here´s the ><br>
> general idea in my code: <br>
> > > <div metal:define-macro="main" tal:define="x python:0"><br>
> > > <tal:block tal:define="x python:x + 1"><br>
> > <td><br>
> > <input type="hidden" tal:attributes="value item/name; name > <br>
> python:'item_name_' + `x`"><br>
> > > > Now, all of that works...once. That is, it increments from 0 to<br>
> 1, but > not from 1 to 2! Each time I pass through the td element, I<br>
> need it to > increment. I tried putting the tal definition in the td,<br>
> but then it > didn´t even increment once! What do?<br>
> > TIA,<br>
> > Tony<br>
> > ------------------------------------------------------------------------ <br>
> > AOL now offers free email to everyone. Find out more about what's<br>
> free > from AOL at *AOL.com*<br>
> <<A href="http://www.aol.com/?ncid=AOLAOF00020000000437" target=_blank>http://www.aol.com?ncid=AOLAOF00020000000437 </A><br>
> <<A href="http://www.aol.com/?ncid=AOLAOF00020000000437" target=_blank>http://www.aol.com/?ncid=AOLAOF00020000000437</A>>>.<br>
> > > ><br>
> ------------------------------------------------------------------------ <br>
> > > _______________________________________________<br>
> > Zope maillist - <A href="mailto:Zope@zope.org">Zope@zope.org</A> <mailto:<A href="mailto:Zope@zope.org">Zope@zope.org</A>><br>
> > <A href="http://mail.zope.org/mailman/listinfo/zope" target=_blank>http://mail.zope.org/mailman/listinfo/zope</A><br>
> > ** No cross posts or HTML encoding! **<br>
> > (Related lists - > <A href="http://mail.zope.org/mailman/listinfo/zope-announce" target=_blank>http://mail.zope.org/mailman/listinfo/zope-announce</A><br>
> > <A href="http://mail.zope.org/mailman/listinfo/zope-dev" target=_blank>http://mail.zope.org/mailman/listinfo/zope-dev</A> )<br>
><br>
> -- Peter Bengtsson,<br>
> work <A href="http://www.fry-it.com/" target=_blank>www.fry-it.com</A> <<A href="http://www.fry-it.com/" target=_blank>http://www.fry-it.com/</A>><br>
> home <A href="http://www.peterbe.com/" target=_blank>www.peterbe.com</A> <<A href="http://www.peterbe.com/" target=_blank> http://www.peterbe.com/</A>><br>
> hobby <A href="http://www.issuetrackerproduct.com/" target=_blank>www.issuetrackerproduct.com</A> <<A href="http://www.issuetrackerproduct.com/" target=_blank>http://www.issuetrackerproduct.com/</A>><br>
> ------------------------------------------------------------------------ <br>
> AOL now offers free email to everyone. Find out more about what's free<br>
> from AOL at *AOL.com* <<A href="http://www.aol.com/?ncid=AOLAOF00020000000437" target=_blank>http://www.aol.com?ncid=AOLAOF00020000000437</A> >.<br>
<br>
--<br>
Peter Bengtsson,<br>
work <A href="http://www.fry-it.com/" target=_blank>www.fry-it.com</A><br>
home <A href="http://www.peterbe.com/" target=_blank>www.peterbe.com</A><br>
hobby <A href="http://www.issuetrackerproduct.com/" target=_blank>www.issuetrackerproduct.com </A><br>
_______________________________________________<br>
Zope maillist - <A href="mailto:Zope@zope.org">Zope@zope.org</A><br>
<A href="http://mail.zope.org/mailman/listinfo/zope" target=_blank>http://mail.zope.org/mailman/listinfo/zope </A><br>
** No cross posts or HTML encoding! **<br>
(Related lists -<br>
<A href="http://mail.zope.org/mailman/listinfo/zope-announce" target=_blank>http://mail.zope.org/mailman/listinfo/zope-announce</A><br>
<A href="http://mail.zope.org/mailman/listinfo/zope-dev" target=_blank>http://mail.zope.org/mailman/listinfo/zope-dev</A> )<br>
</BLOCKQUOTE></div>
<br>
</div>
<div id=AOLMsgPart_4_245c7f9e-8639-46df-99e0-47f87ae7b1a9 style="FONT-SIZE: 12px; MARGIN: 0px; COLOR: #000; FONT-FAMILY: Tahoma, Verdana, Arial, Sans-Serif; BACKGROUND-COLOR: #fff"><PRE style="FONT-SIZE: 9pt"><TT>_______________________________________________
Zope maillist - <A href="mailto:Zope@zope.org">Zope@zope.org</A>
<A href="http://mail.zope.org/mailman/listinfo/zope" target=_blank>http://mail.zope.org/mailman/listinfo/zope</A>
** No cross posts or HTML encoding! **
(Related lists -
<A href="http://mail.zope.org/mailman/listinfo/zope-announce" target=_blank>http://mail.zope.org/mailman/listinfo/zope-announce</A>
<A href="http://mail.zope.org/mailman/listinfo/zope-dev" target=_blank>http://mail.zope.org/mailman/listinfo/zope-dev</A> )
</TT></PRE></div>
<div class=AOLPromoFooter>
<HR style="MARGIN-TOP: 10px">
AOL now offers free email to everyone. Find out more about what's free from AOL at <A href="http://www.aol.com/?ncid=AOLAOF00020000000437" target=_blank><B>AOL.com</B></A>.<br>
</div>
</div>
<!-- end of AOLMsgPart_3_7a3d0e67-624a-43fd-9003-a52988ab05ae -->
<div id=AOLMsgPart_4_7a3d0e67-624a-43fd-9003-a52988ab05ae style="FONT-SIZE: 12px; MARGIN: 0px; COLOR: #000; FONT-FAMILY: Tahoma, Verdana, Arial, Sans-Serif; BACKGROUND-COLOR: #fff"><PRE style="FONT-SIZE: 9pt"><TT>_______________________________________________
Zope maillist - <A href="mailto:Zope@zope.org">Zope@zope.org</A>
<A href="http://mail.zope.org/mailman/listinfo/zope" target=_blank>http://mail.zope.org/mailman/listinfo/zope</A>
** No cross posts or HTML encoding! **
(Related lists -
<A href="http://mail.zope.org/mailman/listinfo/zope-announce" target=_blank>http://mail.zope.org/mailman/listinfo/zope-announce</A>
<A href="http://mail.zope.org/mailman/listinfo/zope-dev" target=_blank>http://mail.zope.org/mailman/listinfo/zope-dev</A> )
</TT></PRE></div>
<!-- end of AOLMsgPart_4_7a3d0e67-624a-43fd-9003-a52988ab05ae -->