Is there any way to do looping from within DTML? For example, I'd like to execute a method a certain number of times using a counter. Here's some pseudo-code to demonstrate: <!--#while "i < total_count"--> <!--#call some_method--> <!--#call "REQUEST.set('i', i+1)"--> <!--#/while--> If I can do looping, is there a way to break out of a loop? Thanks in advance.
On Mon, 16 Aug 1999 craigv@jps.net wrote:
Is there any way to do looping from within DTML? For example, I'd like to execute a method a certain number of times using a counter. Here's some pseudo-code to demonstrate:
<!--#while "i < total_count"--> <!--#call some_method--> <!--#call "REQUEST.set('i', i+1)"--> <!--#/while-->
If I can do looping, is there a way to break out of a loop? Nope. You cannot do general looping, as a while construct would allow you to build nonterminating loops.
You can try this: <dtml-in "_.range(100)"> <dtml-var sequence-item> <BR> </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
At 10:12 pm -0700 16/8/99, craigv@jps.net wrote:
Is there any way to do looping from within DTML? For example, I'd like to execute a method a certain number of times using a counter. Here's some pseudo-code to demonstrate:
<!--#while "i < total_count"--> <!--#call some_method--> <!--#call "REQUEST.set('i', i+1)"--> <!--#/while-->
This loops total_count times and prints the number of the sequence <dtml-in "_.range(total_count)"> <dtml-var sequence-item> </dtml-in>
If I can do looping, is there a way to break out of a loop?
not sure about that bit! hth tone out ------ Dr Tony McDonald, FMCC, Networked Learning Environments Project http://nle.ncl.ac.uk/ The Medical School, Newcastle University Tel: +44 191 222 5888 Fingerprint: 3450 876D FA41 B926 D3DD F8C3 F2D0 C3B9 8B38 18A2
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 ----- Original Message ----- From: Tony McDonald <tony.mcdonald@ncl.ac.uk> To: <craigv@jps.net>; <zope@zope.org> Sent: Tuesday, August 17, 1999 10:50 AM Subject: Re: [Zope] Looping in DTML
At 10:12 pm -0700 16/8/99, craigv@jps.net wrote:
Is there any way to do looping from within DTML? For example, I'd like to execute a method a certain number of times using a counter. Here's some pseudo-code to demonstrate:
<!--#while "i < total_count"--> <!--#call some_method--> <!--#call "REQUEST.set('i', i+1)"--> <!--#/while-->
This loops total_count times and prints the number of the sequence
<dtml-in "_.range(total_count)"> <dtml-var sequence-item> </dtml-in>
If I can do looping, is there a way to break out of a loop?
not sure about that bit!
hth tone out ------ Dr Tony McDonald, FMCC, Networked Learning Environments Project http://nle.ncl.ac.uk/ The Medical School, Newcastle University Tel: +44 191 222 5888 Fingerprint: 3450 876D FA41 B926 D3DD F8C3 F2D0 C3B9 8B38 18A2
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
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... hth tone ------ Dr Tony McDonald, FMCC, Networked Learning Environments Project http://nle.ncl.ac.uk/ The Medical School, Newcastle University Tel: +44 191 222 5888 Fingerprint: 3450 876D FA41 B926 D3DD F8C3 F2D0 C3B9 8B38 18A2
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
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
ahhh... good point! :) ------ Dr Tony McDonald, FMCC, Networked Learning Environments Project http://nle.ncl.ac.uk/ The Medical School, Newcastle University Tel: +44 191 222 5888 Fingerprint: 3450 876D FA41 B926 D3DD F8C3 F2D0 C3B9 8B38 18A2
The _.range method doesn't appear to be available in Zope 1.10. Is this correct or am I missing something?
This loops total_count times and prints the number of the sequence
<dtml-in "_.range(total_count)"> <dtml-var sequence-item> </dtml-in>
If I can do looping, is there a way to break out of a loop?
not sure about that bit!
hth tone out ------ Dr Tony McDonald, FMCC, Networked Learning Environments Project http://nle.ncl.ac.uk/ The Medical School, Newcastle University Tel: +44 191 222 5888 Fingerprint: 3450 876D FA41 B926 D3DD F8C3 F2D0 C3B9 8B38 18A2
_______________________________________________ Zope maillist - Zope@zope.org http://www.zope.org/mailman/listinfo/zope
(To receive general Zope announcements, see: http://www.zope.org/mailman/listinfo/zope-announce
For developer-specific issues, zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )
At 10:28 am -0700 17/8/99, craigv@jps.net wrote:
The _.range method doesn't appear to be available in Zope 1.10. Is this correct or am I missing something?
oops....I've just checked my Zope 1.10 distribution and it isn't in the DocumentTemplate directory, so it isn't in Zope 1.10, just Zope 2.0. tone ------ Dr Tony McDonald, FMCC, Networked Learning Environments Project http://nle.ncl.ac.uk/ The Medical School, Newcastle University Tel: +44 191 222 5888 Fingerprint: 3450 876D FA41 B926 D3DD F8C3 F2D0 C3B9 8B38 18A2
participants (4)
-
Andreas Kostyrka -
craigv@jps.net -
Phil Harris -
Tony McDonald