[CMF-checkins] CVS: CMF/CMFCore - utils.py:1.32

Tres Seaver tseaver@zope.com
Thu, 14 Nov 2002 01:26:42 -0500


Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv10827/CMFCore

Modified Files:
	utils.py 
Log Message:


    - Remove workaround in CMFCore.utils for recognizing links in
      StructuredText:  STX in CMF content should now recognize exactly
      the same links as the underlying Zope.  Note that we *do* still
      provide a customized HTML class, to permit embedding images without
      generating the "whole" page.  Collector #6, merged from
      CMF-1_3-branch.


=== CMF/CMFCore/utils.py 1.31 => 1.32 ===
--- CMF/CMFCore/utils.py:1.31	Wed Aug 21 10:48:01 2002
+++ CMF/CMFCore/utils.py	Thu Nov 14 01:26:42 2002
@@ -43,16 +43,11 @@
 except ImportError:
     UNIQUE = 2
 
-import StructuredText
-from StructuredText.HTMLWithImages import HTMLWithImages
-
-_STXDWI = StructuredText.DocumentWithImages.__class__
 
 security = ModuleSecurityInfo( 'Products.CMFCore.utils' )
 
 _dtmldir = os_path.join( package_home( globals() ), 'dtml' )
 
-
 #
 #   Simple utility functions, callable from restricted code.
 #
@@ -526,35 +521,12 @@
 #   XXX:    This section is mostly workarounds for things fixed in the
 #           core, and should go away soon.
 #
+from StructuredText import Basic as STXBasic
+from StructuredText import DocumentWithImages
+from StructuredText.HTMLClass import HTMLClass
+from StructuredText.HTMLWithImages import HTMLWithImages
 
-class CMFDocumentClass( StructuredText.DocumentWithImages.__class__ ):
-    """
-    Override DWI to get '_' into links, and also turn on inner/named links.
-    """
-    text_types = [
-        'doc_named_link',
-        'doc_inner_link',
-        ] + _STXDWI.text_types
-    
-    _URL_AND_PUNC = r'([a-zA-Z0-9_\@\.\,\?\=\&\+\!\/\:\;\-\#\~]+)'
-    def doc_href( self
-                , s
-                , expr1 = re.compile( _STXDWI._DQUOTEDTEXT
-                                    + "(:)"
-                                    + _URL_AND_PUNC
-                                    + _STXDWI._SPACES
-                                    ).search
-                , expr2 = re.compile( _STXDWI._DQUOTEDTEXT
-                                    + r'(\,\s+)'
-                                    + _URL_AND_PUNC
-                                    + _STXDWI._SPACES
-                                    ).search
-                ):
-        return _STXDWI.doc_href( self, s, expr1, expr2 )
-
-CMFDocumentClass = CMFDocumentClass()
-
-class CMFHtmlWithImages( HTMLWithImages ):
+class _CMFHtmlWithImages( HTMLWithImages ):
     """ Special subclass of HTMLWithImages, overriding document() """
 
     def document(self, doc, level, output):
@@ -566,18 +538,18 @@
         for c in doc.getChildNodes():
            getattr(self, self.element_types[c.getNodeName()])(c, level, output)
 
-CMFHtmlWithImages = CMFHtmlWithImages()
+CMFHtmlWithImages = _CMFHtmlWithImages()
 
 security.declarePublic('format_stx')
 def format_stx( text, level=1 ):
     """
         Render STX to HTML.
     """
-    st = StructuredText.Basic( text )   # Creates the basic DOM
-    if not st:                          # If it's an empty object
-        return ""                       # return now or have errors!
+    st = STXBasic( text )   # Creates the basic DOM
+    if not st:              # If it's an empty object
+        return ""           # return now or have errors!
 
-    doc = CMFDocumentClass( st )
+    doc = DocumentWithImages( st )
     html = CMFHtmlWithImages( doc, level )
     return html