[CMF-checkins] CVS: CMF - Document.py:1.3

Jeffrey Shell jeffrey@digicool.com
Thu, 22 Mar 2001 16:28:21 -0500 (EST)


Update of /cvs-repository/CMF/CMFDefault
In directory korak:/home/jeffrey/InstanceHomes/cmf-dev/CMF/CMFDefault

Modified Files:
	Document.py 
Log Message:
Fixed CMF Tracker item (207), "HTML test when editing a Portal
Document is ambiguous".  Now, the same regular expression used to
scoop out the contents of the <body> tags, which is case insensitive,
is also used to detect whether the document may be HTML.

Verified by Unit Tests in CMFDefault/tests/test_document.py



--- Updated File Document.py in package CMF --
--- Document.py	2001/02/27 21:51:01	1.2
+++ Document.py	2001/03/22 21:28:20	1.3
@@ -136,7 +136,7 @@
 
     def edit(self, text_format, text, file=''):
         """
-            Edit the Document
+        Edit the Document
         """
         self.text = text
         headers = {}
@@ -147,14 +147,15 @@
 
         # Now parse out HTML if its applicable, or the plain text,
         # getting any headers passed along in the document
-        ishtml = (text_format == 'html') or (string.find(text,'</body>') > -1)
+        bodyfound = bodyfinder.search(text)
+        ishtml = (text_format == 'html') or (bodyfound is not None)
         if ishtml:
             parser = SimpleHTMLParser()
             parser.feed(text)
             headers.update(parser.metatags)
             if parser.title: headers['Title'] = parser.title
-            b = bodyfinder.search(text)
-            if b: text = self.text = b.group('bodycontent')
+            if bodyfound:
+                text = self.text = bodyfound.group('bodycontent')
             text_format = self.text_format = 'html'
         else:
             headers, text = parseHeadersBody(text, headers)
@@ -181,6 +182,10 @@
     edit = WorkflowAction(edit)
 
     def _parse(self):
+        """\
+        If the format is structured text, this method turns our body text
+        into HTML for 'cooked_text', used by the default skins for Document.
+        """
         if self.text_format=='structured-text':
             ct = self._format_text(text=self.text)
             if type(ct) is not type(''):