[Zope] while

Patrick Lewis pl@teleport.com
Wed, 26 Jul 2000 17:41:20 -0700


This is real ugly, but you asked (untested, but you get the idea):

<dtml-try>
  <dtml-in "_.range(1000)">
    <dtml-if whileCondition>  <!-- Your logic test -->
      <!-- Do stuff in while loop -->
    <dtml-else>
      <dtml-raise type="conditionFalse">errormsg</dtml-raise>
    </dtml-if>
  </dtml-in>
<dtml-except conditionFalse>
  <!-- Fall out of 'while' loop.  -->
<dtml-else>
  <dtml-raise type="RangeError">Oops! Exception never raised.</dtml-raise>
</dtml-try>

This only works if the loop will cycle less than 1000 times.  Needless to
say, this is done a lot easier in Python.

On Wed, Jul 26, 2000 at 05:46:18PM -0500, Leichtman, David J wrote:
> 
> But that's more like a for loop. No test condition.
> Basically, I want to keep redoing a method until a condition is met.
> 
> -----Original Message-----
> From: Daniel Rusch [mailto:drusch@globalcrossing.com]
> Sent: Wednesday, July 26, 2000 3:19 PM
> To: Leichtman, David J
> Cc: 'zope@zope.org'
> Subject: Re: [Zope] while
> 
> 
> Try:
> 
> <dtml-in "_.range(1,10)">
>  <dtml-var sequence-item>
> </dtml-in>
> 
> "Leichtman, David J" wrote:
> 
> > Is there an easy way to simulate the functionality of a while loop in
> DTML?
> >

-- 
Patrick Lewis <pl@teleport.com>