[Zope] Looping in DTML

Andreas Kostyrka andreas@mtg.co.at
Tue, 17 Aug 1999 12:33:30 +0200 (CEST)


On Tue, 17 Aug 1999, Tony McDonald wrote:

> At 11:06 am +0100 17/8/99, Phil Harris wrote:
> >As for breaking out of a loop, how about (extremely untested):
> >
> ><dtml-try>
> > <dtml-in "_.range(total_count)">
> >   <dtml-var sequence-item>
> >   <dtml-if some_thing>
> >     <dtml-raise someexception></dtml-raise>
> >   </dtml-if>
> > </dtml-in>
> ><dtml-except someexception>
> >  <dtml-comment>
> >    do nothing
> >  </dtml-comment>
> ></dtml-try>
> >
> >the raise tag should then jump to the except tag and therefore out of the
> >loop or something like that, maybe, possibly, ;).
> >
> >HTH
> >
> >Phil
> >phil@philh.org
> 
> (Phils machine goes --bleep--)
> 
> I *was* going to mention about <dtml-raise > but I knew Phil would be 
> lurking, and he doesn't get out much! :)
> 
> To add *some* content to this mail, I *think* you can do _.xrange() 
> too, so that largeish loops can also be done...checking 
> source....(DT_Util.py) nope. I was wrong. No xrange, but _.range() 
> has got a limit of 1000, so you won't be doing any infinite loops 
> using *that* function...
Well, I'm not sure that the 1000 limit does any good ;)
<dtml-in "_.range(999)">
  <dtml-let out=sequence-item>
  <dtml-in "_.range(999)">
    <dtml-var "out*999+_['sequence-item']"><BR>
  </dtml-in>
</dtml-in>

Andreas
--
Andreas Kostyrka                     | andreas@mtg.co.at
phone: +43/1/7070750                 | phone: +43/676/4091256   
MTG Handelsges.m.b.H.                | fax:   +43/1/7065299
Raiffeisenstr. 16/9                  | 2320 Zwoelfaxing AUSTRIA