Ok here goes:

Install these patches on a 2.3.0b1 installation. The files to patch are
found in {Zope Dir}/lib/python/DocumentTemplate.

Thus far it seems stable, and I would like for anyone willing to test it
out.

WHY SHOULD YOU?
Although the original purpose of this patch is solve my own problem, it
also solves a behavioral bug in <dtml-comment>. That is you no longer
need correctly formed and balanced dtml code inside of a
<dtml-comment></dtml-comment> pair. This allows them to function as you
would expect. Code inside the comment tags is simply ignored.

If you develop your own dtml tag class that you want to use to create
blocks of something other than dtml, simply add the class attribute
disable_dtml_block_parsing=1 along with blockContinuations=() in the
tag's class definition.

Here are the patches:

*** DT_String.old       Mon Jan 22 13:06:33 2001
--- DT_String.py        Mon Jan 22 15:55:57 2001
***************
*** 272,277 ****
--- 272,308 ----
          sname=stag
          sstart=start
          sa=sargs
+  
+       if hasattr(scommand, 'blockContinuations') and\
+            hasattr(scommand, 'disable_dtml_block_parsing'):
+             # Tag doesn't want the block parsed as dtml, so just find
the
+             # end tag and don't parse what's inside
+ 
+             while 1:
+                 l=tagre.search(text,start)
+                 if l < 0: self.parse_error('No closing tag', stag,
text, sloc)
+ 
+                 try: 
+                     tag, args, command, coname=
self._parseTag(tagre,scommand,sa)
+                 except: 
+                     start = l + 1 # Skip malformed tags without
raising exceptions
+                 else:
+                     start = l + len(tag)
+ 
+                     if not command and not coname:
+                         # Block end tag
+                         section = String(text[sstart:l],
__name__=sname)
+                         section._v_blocks = section.blocks =
[section.raw]
+                         section._v_cooked = None
+                         blocks.append((tname, sargs, section))
+                         try:
+                             r=scommand(blocks)
+                             if hasattr(r,'simple_form'):
r=r.simple_form
+                             result.append(r)
+                         except ParseError, m:
self.parse_error(m[0],stag,text,l)
+ 
+                         return start
+ 
          while 1:
  
              l=tagre.search(text,start)


*** DT_Var.old  Mon Jan 22 15:27:30 2001
--- DT_Var.py   Mon Jan 22 15:28:14 2001
***************
*** 461,466 ****
--- 461,467 ----
      ''' 
      name='comment'
      blockContinuations=()
+     disable_dtml_block_parsing = 1
  
      def __init__(self, args, fmt=''): pass


Feedback on this is definitely welcome. If it is generally well-liked, I
will submit it to the collector.
-- 
| Casey Duncan
| Kaivo, Inc.
| [EMAIL PROTECTED]
`------------------>

_______________________________________________
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to