Hi, Is is just me or does stuff inside a <dtml-comment> get parsed? So if you have: <dtml-comment> ... some syntactically bad dtml ... </dtml-comment> You still can't save the page 'cos the the parser throws up an error. That seems silly to me. Anyone else agree? cheers, Chris
Yeah, that's the way it works. I'm not sure why, though I remember someone trying to explain it to me around the time of the last Python conference. On Sat, 19 Aug 2000, Chris Withers wrote:
Hi,
Is is just me or does stuff inside a <dtml-comment> get parsed?
So if you have:
<dtml-comment>
... some syntactically bad dtml ...
</dtml-comment>
You still can't save the page 'cos the the parser throws up an error.
That seems silly to me. Anyone else agree?
cheers,
Chris
_______________________________________________ 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 )
Chris McDonough wrote:
Yeah, that's the way it works. I'm not sure why, though I remember someone trying to explain it to me around the time of the last Python conference.
That's not very nice :( Any reason why it can't be changed to be as expected? cheers, Chris
Chris McDonough wrote:
That's not very nice :(
Any reason why it can't be changed to be as expected?
I think it can safely be changed to not evaluate what's between the comment tags. Patches accepted, as always. :-)
I'd love to, btu I wouldn't know where to start. Besides, I'm busy fighting with trying to do dtml-tree with objects returned by a dtml-in :(( cheers, Chris
Hi, Chris Withers wrote:
Hi,
Is is just me or does stuff inside a <dtml-comment> get parsed?
So if you have:
<dtml-comment>
... some syntactically bad dtml ...
</dtml-comment>
You still can't save the page 'cos the the parser throws up an error.
That seems silly to me. Anyone else agree?
No, I disagree. Why do you want bad dtml even inside comments? dtml-comment is a tag like all the other tags. It does not control the parser. One advantage is, you may nest comment-tags. Regards Tino Wildenhain
Tino Wildenhain wrote:
Hi,
Chris Withers wrote:
Hi,
Is is just me or does stuff inside a <dtml-comment> get parsed?
So if you have:
<dtml-comment>
... some syntactically bad dtml ...
</dtml-comment>
You still can't save the page 'cos the the parser throws up an error.
That seems silly to me. Anyone else agree?
No, I disagree. Why do you want bad dtml even inside comments?
For example to find out what exactly is bad about them - i.e., you develop something, you cannot save it, ok, lets comment out the part I am not sure about and try again. Or work in progress (hey, I've gotta sleep sometime) that you want to be stored in the ZODB even though it's not finished. Astonishingly, some really difficult 3am problems become surprisingly easy at 9am after a few hour's sleep.
dtml-comment is a tag like all the other tags. It does not control the parser. One advantage is, you may nest comment-tags.
True. But still, the parser could read over all comments as long as the <dtml-comment> tags are properly nested. Jan
+-------[ Jan H. Haul ]---------------------- | Tino Wildenhain wrote: | | > dtml-comment is a tag like all the other tags. It does not | > control the parser. One advantage is, you may nest comment-tags. | | True. | But still, the parser could read over all comments as long as the | <dtml-comment> tags are properly nested. But then you'd have to parse the contents to find out if the comments are properly nested... I've looked at this briefly today, and the code inside DT_String.py is recursively ugly... d;) It doesn't look difficult to provide what you want, but, I'm not motivated enough to fix it either at this stage. d8) -- Totally Holistic Enterprises Internet| P:+61 7 3870 0066 | Andrew Milton The Internet (Aust) Pty Ltd | F:+61 7 3870 4477 | ACN: 082 081 472 ABN: 83 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
Andrew Kenneth Milton wrote:
But then you'd have to parse the contents to find out if the comments are properly nested...
Well, the parsing should be pretty simple: 1. find <dtml-comment> 2. search for </dtml-comment> 3. if found: ignore that block of text else if end of text reached: bitch like hell ;-) What's wrong with that?
I've looked at this briefly today, and the code inside DT_String.py is recursively ugly... d;)
You do surprise me ;-)
It doesn't look difficult to provide what you want, but, I'm not motivated enough to fix it either at this stage. d8)
Aww... go on, you know you want to really ;-) cheers, Chris
+-------[ Chris Withers ]---------------------- | Andrew Kenneth Milton wrote: | > But then you'd have to parse the contents to find out if the comments are | > properly nested... | | Well, the parsing should be pretty simple: | 1. find <dtml-comment> | 2. search for </dtml-comment> Or <dtml-comment> | 3. if found: | ignore that block of text | else if end of text reached: | bitch like hell ;-) | | What's wrong with that? It's wrong :-) <dtml-comment> crap more crap <dtml-comment> Lots of crap </dtml-comment> </dtml-comment> In order to parse that fragment, you need to parse the blocks in case you find another opening block, so that you can recursively process comments. | > I've looked at this briefly today, and the code inside DT_String.py is | > recursively ugly... d;) | | You do surprise me ;-) | | > It doesn't look difficult to provide what you want, but, I'm not motivated | > enough to fix it either at this stage. d8) | | Aww... go on, you know you want to really ;-) Now you know the problem domain, it shouldn't be hard for you to create a cut-down equivalent of the DT_String parser that only parses comment blocks. Take you less time than writing these emails I'm sure d;) -- Totally Holistic Enterprises Internet| P:+61 7 3870 0066 | Andrew Milton The Internet (Aust) Pty Ltd | F:+61 7 3870 4477 | ACN: 082 081 472 ABN: 83 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
Andrew Kenneth Milton wrote:
| What's wrong with that?
It's wrong :-)
<dtml-comment> crap more crap <dtml-comment> Lots of crap </dtml-comment> </dtml-comment>
In order to parse that fragment, you need to parse the blocks in case you find another opening block, so that you can recursively process comments.
Yeah, fair point...
| > It doesn't look difficult to provide what you want, but, I'm not motivated | > enough to fix it either at this stage. d8) | | Aww... go on, you know you want to really ;-)
Now you know the problem domain, it shouldn't be hard for you to create a cut-down equivalent of the DT_String parser that only parses comment blocks.
You obviously have a better understanding of DT_String than me and so would be much better suited to the task ;-) Good luck, we're all rootin' for ya :P Chris PS:
Take you less time than writing these emails I'm sure d;) Er... no!
I missed the beginning of this thread, so I'm not sure if this will help. I've attached a patch file which will add a DTML-commentline tag. This is different from the standard DTML-comment in that it does not require an end tag. Here's an example of its use: <ul> <dtml-commentline <dtml-in "PARENTS[1].objectValues()" sort=id> <li><dtml-var title_or_id> <dtml-commentline </dtml-in> </ul> This segment prints the 'title_or_id' for the current method, and does not execute the loop. Obviously the DTML-in syntax isn't correct, but that's part of how the commentline tag works. It eats up everything in its own <> markers, and allows the DTML parser to ignore it. It *does not* go all the way to the end of the input line, as the name might imply. Doug Chris Withers wrote:
Andrew Kenneth Milton wrote:
| What's wrong with that?
It's wrong :-)
<dtml-comment> crap more crap <dtml-comment> Lots of crap </dtml-comment> </dtml-comment>
In order to parse that fragment, you need to parse the blocks in case you find another opening block, so that you can recursively process comments.
Yeah, fair point...
| > It doesn't look difficult to provide what you want, but, I'm not motivated | > enough to fix it either at this stage. d8) | | Aww... go on, you know you want to really ;-)
Now you know the problem domain, it shouldn't be hard for you to create a cut-down equivalent of the DT_String parser that only parses comment blocks.
You obviously have a better understanding of DT_String than me and so would be much better suited to the task ;-)
Good luck, we're all rootin' for ya :P
Chris
PS:
Take you less time than writing these emails I'm sure d;) Er... no!
_______________________________________________ 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 )
Index: DT_String.py =================================================================== RCS file: /cvs-repository/Zope2/lib/python/DocumentTemplate/DT_String.py,v retrieving revision 1.38 diff -r1.38 DT_String.py 91c91 < from DT_Var import Var, Call, Comment ---
from DT_Var import Var, Call, CommentLine, Comment 143a144 'commentline': CommentLine, Index: DT_Var.py =================================================================== RCS file: /cvs-repository/Zope2/lib/python/DocumentTemplate/DT_Var.py,v retrieving revision 1.36 diff -r1.36 DT_Var.py 448c448 < class Comment:
class CommentLine: 462,463c462 < name='comment' < blockContinuations=()
name='commentline'
470a470,473
class Comment(CommentLine): name='comment' blockContinuations=()
In article <20000904220808.B1642@zeus.theinternet.com.au>, Andrew Kenneth Milton <akm@mail.theinternet.com.au> wrote: [snip]
It's wrong :-)
<dtml-comment> crap more crap <dtml-comment> Lots of crap </dtml-comment> </dtml-comment>
In order to parse that fragment, you need to parse the blocks in case you find another opening block, so that you can recursively process comments.
[snip] <dtml-if "0"> crap more crap <dtml-if "0"> Lots of crap </dtml-if> </dtml-if> by analogy with the common practice of #if 0 in C
+-------[ Kip Rugger ]---------------------- | | [snip] | | <dtml-if "0"> | crap | more crap | <dtml-if "0"> | Lots of crap | </dtml-if> | </dtml-if> | | by analogy with the common practice of #if 0 in C Won't work, the container will still be parsed for correctness at 'save' time. The problem isn't getting nested comments per se, we already have that. The problem is to completely ignore the contents of the comment tag whilst still allowing nested comments. Th second part of the problem is that ChrisW(hinger) really wants it, but, doesn't want to do what is necessary to do it. So the problem is simplified to not actually doing anything except talking about doing it. d8) Thankyou for playing d8) -- Totally Holistic Enterprises Internet| P:+61 7 3870 0066 | Andrew Milton The Internet (Aust) Pty Ltd | F:+61 7 3870 4477 | ACN: 082 081 472 ABN: 83 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
Andrew Kenneth Milton wrote:
Th second part of the problem is that ChrisW(hinger) really wants it,
"really wants it" might be a little strong... I'm not loosing any sleep...
but, doesn't want to do what is necessary to do it.
Swishdot or fixing DTML... take your pick :P (TreeTag would still get it first anyway...)
So the problem is simplified to not actually doing anything except talking about doing it. d8)
Well, since you actually have knowledge of the DT_String parser (well, more than I do at any rate...) you'd be better suited to doing less talking... *grinz* Chris
+-------[ Chris Withers ]---------------------- | Andrew Kenneth Milton wrote: | > Th second part of the problem is that ChrisW(hinger) really wants it, | | "really wants it" might be a little strong... I'm not loosing any | sleep... | | > but, | > doesn't want to do what is necessary to do it. | | Swishdot or fixing DTML... take your pick :P | (TreeTag would still get it first anyway...) Well since I don't use S*dot... :-) -- Totally Holistic Enterprises Internet| P:+61 7 3870 0066 | Andrew Milton The Internet (Aust) Pty Ltd | F:+61 7 3870 4477 | ACN: 082 081 472 ABN: 83 082 081 472 | M:+61 416 022 411 | Carpe Daemon PO Box 837 Indooroopilly QLD 4068 |akm@theinternet.com.au|
Andrew, Did you see my solution to this? <!--#comment this is all commented stuff. <dtml-in "invalid_dtml_syntax"@#$#@%^> <dtml-do wreak_havoc> </dtml-unless> --></dtml-comment> I also posted a patch that would allow you to use syntax like this: <!--#c <dtml-with bad_code> This neither renders nor preprocesses. </dtml-in> --> Same effect, but a bit cleaner. If you'd like a copy of that patch, send me an e-mail. Take care, T.J. -----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Andrew Kenneth Milton Sent: Monday, September 04, 2000 5:11 PM To: Kip Rugger Cc: zope@zope.org Subject: Re: [Zope] <dtml-comment> doesn't? Please fix... ;-) Won't work, the container will still be parsed for correctness at 'save' time. The problem isn't getting nested comments per se, we already have that. The problem is to completely ignore the contents of the comment tag whilst still allowing nested comments.
Andrew Kenneth Milton <akm@mail.theinternet.com.au> wrote:
+-------[ Kip Rugger ]---------------------- | | [snip] | | <dtml-if "0"> | crap | more crap | <dtml-if "0"> | Lots of crap | </dtml-if> | </dtml-if> | | by analogy with the common practice of #if 0 in C
Won't work, the container will still be parsed for correctness at 'save' time. The problem isn't getting nested comments per se, we already have that. The problem is to completely ignore the contents of the comment tag whilst still allowing nested comments.
Th second part of the problem is that ChrisW(hinger) really wants it, but, doesn't want to do what is necessary to do it. So the problem is simplified to not actually doing anything except talking about doing it. d8)
Thankyou for playing d8)
Since I put my stupid foot into it, I just had to write the patch. For penitence and to learn about DocumentTemplate. This should let you nest <dtml-comment> arb stuff </dtml-comment> without any syntactical value being ascribed to the contents. I am too new to Zope to know if this is even desirable :-) so I just offer it as more of an amusement than anything else. Patch against 2.2.1 source. --- DT_String.py.orig Thu Aug 17 08:46:48 2000 +++ DT_String.py Thu Sep 7 22:27:42 2000 @@ -237,7 +237,11 @@ if s: result.append(s) start=l+len(tag) - if hasattr(command,'blockContinuations'): + if command == Comment: + start = self.parse_comment(text, start, result, tagre, tag, l, + command, args) + + elif hasattr(command,'blockContinuations'): start=self.parse_block(text, start, result, tagre, tag, l, args, command) else: @@ -280,7 +284,11 @@ try: tag, args, command, coname= self._parseTag(tagre,scommand,sa) except ParseError, m: self.parse_error(m[0],m[1], text, l) - if command: + if command == Comment: + start=l+len(tag) + start = self.parse_comment(text, start, result, tagre, tag, l, + command, args) + elif command: start=l+len(tag) if hasattr(command, 'blockContinuations'): # New open tag. Need to find closing tag. @@ -325,6 +333,35 @@ start=self.parse_close(text, start, tagre, tag, l, command,args) elif not coname: return start + + def parse_comment(self, text, start, result, tagre, + stag, sloc, sargs, scommand): + nest = 1 + while 1: + + l=tagre.search(text,start) + if l < 0: self.parse_error('No closing tag', stag, text, sloc) + + tag, name = tagre.group(0, 'name') + start = l + len(tag) + if name == 'comment': + try: + end = tagre.group('end') + except: + try: + end = tagre.group('fmt') + if end != ']': end = '' + except: + self.parse_error('Delimiter problems', + stag, text, sloc) + if end == '': + nest = nest + 1 + else: + nest = nest - 1 + + if nest == 0: + start=self.skip_eol(text, start) + return start shared_globals__roles__=() shared_globals={}
Tino Wildenhain wrote:
So if you have:
<dtml-comment>
... some syntactically bad dtml ...
</dtml-comment>
You still can't save the page 'cos the the parser throws up an error.
That seems silly to me. Anyone else agree?
No, I disagree. Why do you want bad dtml even inside comments? dtml-comment is a tag like all the other tags. It does not control the parser. One advantage is, you may nest comment-tags.
Tino, That maybe an advantage (though I don't recall ever nesting comments). Then some of us need a <dtml-disable> tag. <VBG> -- Tim Cook -- FreePM Project Coordinator - http://www.freepm.org OS Healthcare Alliance Supporter - http://www.oshca.org
participants (10)
-
Andrew Kenneth Milton -
Chris McDonough -
Chris Withers -
Doug Hellmann -
Jan H. Haul -
kbr@pangea.ca -
rugger@pangea.ca -
T.J. Mannos -
Tim Cook -
Tino Wildenhain