Yo Zopistas! Let's say that I want to make a list of nodes from the top down (the reverse of PARENTS). Easy enough: <dtml-call "REQUEST.set('topdown', [])"> <dtml-in PARENTS skip_unauthorized> <dtml-call "topdown.insert(0, _['sequence-item'])"> </dtml-in> However, what I really want to do is quit reversing when I get up to a particular level, say the point at which I get to my Portal folder. I think I need to insert a line just before the </dtml-in> that says (untested :-) <dtml-break "_['sequence-item'].meta_type == 'Portal'"> But I find no documentation on a break command. Is there any such construct in dtml? Assuming not, any other elegant solution to this? -- Dennis Nichols nichols@tradingconnections.com
----- Original Message ----- From: Dennis Nichols <nichols@tradingconnections.com>
Let's say that I want to make a list of nodes from the top down (the reverse of PARENTS). Easy enough:
<dtml-call "REQUEST.set('topdown', [])"> <dtml-in PARENTS skip_unauthorized> <dtml-call "topdown.insert(0, _['sequence-item'])"> </dtml-in>
However, what I really want to do is quit reversing when I get up to a particular level, say the point at which I get to my Portal folder.
But I find no documentation on a break command. Is there any such construct in dtml?
'Fraid not. The best I can think of offhand is: <dtml-call "REQUEST.set('topdown', [])"> <dtml-call "REQUEST.set('loopdone', 0)"> <dtml-in PARENTS skip_unauthorized> <dtml-unless loopdone> <dtml-call "topdown.insert(0, _['sequence-item'])"> <dtml-if "...last iteration..."> <dtml-call "REQUEST.set('loopdone', 1)"> </dtml-if> </dtml-unless> </dtml-in> Cheers, Evan @ digicool & 4-am
On Wed, May 10, 2000 at 11:56:07AM -0500, Dennis Nichols wrote:
<dtml-call "REQUEST.set('topdown', [])"> <dtml-in PARENTS skip_unauthorized> <dtml-call "topdown.insert(0, _['sequence-item'])"> </dtml-in>
However, what I really want to do is quit reversing when I get up to a particular level, say the point at which I get to my Portal folder. I think I need to insert a line just before the </dtml-in> that says (untested :-)
<dtml-break "_['sequence-item'].meta_type == 'Portal'">
A kludgey way would be to set a request variable meaning "not done" before the loop, and put a dtml-if around your dtml-call to test whether you're done. -- -Mike Orr, mso@mso.oz.net -or- mso@oz.net (permanent: mso@jimpick.com) http://mso.oz.net/ English * Esperanto * Russkiy * Deutsch * Espan~ol
How about something like: <sort of tested> <dtml-try> <dtml-call "REQUEST.set('topdown', [])"> <dtml-in PARENTS skip_unauthorized> <dtml-if "_['sequence-item'].meta_type == 'Portal'"> <dtml-raise 'PortalFound> >/dtml-if> <dtml-call "topdown.insert(0, _['sequence-item'])"> </dtml-in> <dtml-except> <dtml-comment> Ignore the raised error, I'm only kidding </dtml-comment> </dtml-in> </sort of tested> hth Phil phil.harris@zope.co.uk ----- Original Message ----- From: "Mike Orr" <mso@sense-sea-MegaSub-1-220.oz.net> To: <zope@zope.org> Sent: 10 May 2000 19:19 Subject: Re: [Zope] I seem to be missing a "break" DTML tag
On Wed, May 10, 2000 at 11:56:07AM -0500, Dennis Nichols wrote:
<dtml-call "REQUEST.set('topdown', [])"> <dtml-in PARENTS skip_unauthorized> <dtml-call "topdown.insert(0, _['sequence-item'])"> </dtml-in>
However, what I really want to do is quit reversing when I get up to a particular level, say the point at which I get to my Portal folder. I think I need to insert a line just before the </dtml-in> that says (untested :-)
<dtml-break "_['sequence-item'].meta_type == 'Portal'">
A kludgey way would be to set a request variable meaning "not done" before the loop, and put a dtml-if around your dtml-call to test whether you're done.
-- -Mike Orr, mso@mso.oz.net -or- mso@oz.net (permanent: mso@jimpick.com) http://mso.oz.net/ English * Esperanto * Russkiy * Deutsch * Espan~ol
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Wow !! Thanks, Phil, this is the more "elegant" way to solve this problem ! I guess many of us have once been facing this problem, and your solution is more "readable" than the other one. By the way, is there a way to know the complexity of each dtml tag ? I mean, is a dtml-try more costly than waiting for the loop to complete (I guess/hope it's not...) ? Is there a way to have such a piece of information without having to set up large and tiring profiling techniques ? Thanks for your help, Regards, P.-J. Phil Harris wrote:
How about something like:
<sort of tested>
<dtml-try> <dtml-call "REQUEST.set('topdown', [])"> <dtml-in PARENTS skip_unauthorized> <dtml-if "_['sequence-item'].meta_type == 'Portal'"> <dtml-raise 'PortalFound> >/dtml-if> <dtml-call "topdown.insert(0, _['sequence-item'])"> </dtml-in> <dtml-except> <dtml-comment> Ignore the raised error, I'm only kidding </dtml-comment> </dtml-in>
</sort of tested>
hth
Phil phil.harris@zope.co.uk
----- Original Message ----- From: "Mike Orr" <mso@sense-sea-MegaSub-1-220.oz.net> To: <zope@zope.org> Sent: 10 May 2000 19:19 Subject: Re: [Zope] I seem to be missing a "break" DTML tag
On Wed, May 10, 2000 at 11:56:07AM -0500, Dennis Nichols wrote:
<dtml-call "REQUEST.set('topdown', [])"> <dtml-in PARENTS skip_unauthorized> <dtml-call "topdown.insert(0, _['sequence-item'])"> </dtml-in>
However, what I really want to do is quit reversing when I get up to a particular level, say the point at which I get to my Portal folder. I think I need to insert a line just before the </dtml-in> that says (untested :-)
<dtml-break "_['sequence-item'].meta_type == 'Portal'">
A kludgey way would be to set a request variable meaning "not done" before the loop, and put a dtml-if around your dtml-call to test whether you're done.
-- -Mike Orr, mso@mso.oz.net -or- mso@oz.net (permanent: mso@jimpick.com) http://mso.oz.net/ English * Esperanto * Russkiy * Deutsch * Espan~ol
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (5)
-
Dennis Nichols -
Evan Simpson -
Mike Orr -
Phil Harris -
Pierre-Julien Grizel