[CMF-checkins] SVN: CMF/trunk/CMFDefault/ - simplified format handling, fixing some minor issues

Yvo Schubbe y.2007- at wcm-solutions.de
Wed Feb 7 04:37:45 EST 2007


Log message for revision 72413:
  - simplified format handling, fixing some minor issues

Changed:
  U   CMF/trunk/CMFDefault/DiscussionItem.py
  U   CMF/trunk/CMFDefault/Document.py
  U   CMF/trunk/CMFDefault/tests/test_Document.py

-=-
Modified: CMF/trunk/CMFDefault/DiscussionItem.py
===================================================================
--- CMF/trunk/CMFDefault/DiscussionItem.py	2007-02-07 09:25:52 UTC (rev 72412)
+++ CMF/trunk/CMFDefault/DiscussionItem.py	2007-02-07 09:37:45 UTC (rev 72413)
@@ -283,7 +283,8 @@
         self._container[id] = item
         item = item.__of__(self)
 
-        item._edit( text_format=text_format, text=text )
+        item.setFormat(text_format)
+        item._edit(text)
         item.addCreator(Creator)
         item.indexObject()
 

Modified: CMF/trunk/CMFDefault/Document.py
===================================================================
--- CMF/trunk/CMFDefault/Document.py	2007-02-07 09:25:52 UTC (rev 72412)
+++ CMF/trunk/CMFDefault/Document.py	2007-02-07 09:37:45 UTC (rev 72413)
@@ -84,8 +84,8 @@
         self.id = id
         self.title = title
         self.description = description
-        self._edit( text=text, text_format=text_format )
-        self.setFormat( text_format )
+        self.setFormat(text_format)
+        self._edit(text)
 
     security.declareProtected(ModifyPortalContent, 'manage_edit')
     manage_edit = DTMLFile('zmi_editDocument', _dtmldir)
@@ -101,14 +101,13 @@
                 + '?manage_tabs_message=Document+updated'
                 )
 
-    def _edit(self, text, text_format=''):
+    def _edit(self, text):
         """ Edit the Document and cook the body.
         """
         self.text = text
         self._size = len(text)
 
-        if not text_format:
-            text_format = self.text_format
+        text_format = self.text_format
         if text_format == 'html':
             self.cooked_text = text
         elif text_format == 'plain':
@@ -145,7 +144,7 @@
         if html_headcheck(text) and text_format.lower() != 'plain':
             text = bodyfinder(text)
         self.setFormat(text_format)
-        self._edit(text=text, text_format=text_format)
+        self._edit(text)
         self.reindexObject()
 
     security.declareProtected(ModifyPortalContent, 'setMetadata')
@@ -155,9 +154,8 @@
         headers['Subject'] = new_subject or self.Subject()
         new_contrib = contributorsplitter(headers)
         headers['Contributors'] = new_contrib or self.Contributors()
-        haveheader = headers.has_key
         for key, value in self.getMetadataHeaders():
-            if not haveheader(key):
+            if not key in headers:
                 headers[key] = value
         self._editMetadata(title=headers['Title'],
                           subject=headers['Subject'],
@@ -345,9 +343,7 @@
             if html_headcheck(self.text) and value != 'plain':
                 self.text = bodyfinder(self.text)
 
-            self._edit( self.text
-                      , text_format=self.text_format
-                      )
+            self._edit(self.text)
 
     ## FTP handlers
     security.declareProtected(ModifyPortalContent, 'PUT')
@@ -364,11 +360,11 @@
             return RESPONSE
 
         body = REQUEST.get('BODY', '')
-        headers, body, format = self.handleText(text=body)
         if REQUEST.get_header('Content-Type', '') == 'text/html':
-            text_format = 'html'
+            format = 'html'
         else:
-            text_format = format
+            format = None
+        headers, body, format = self.handleText(body, format)
 
         safety_belt = headers.get('SafetyBelt', '')
         if not self._safety_belt_update(safety_belt):
@@ -379,7 +375,7 @@
             RESPONSE.setStatus(450)
             return RESPONSE
 
-        self.setFormat(text_format)
+        self.setFormat(format)
         self.setMetadata(headers)
         self._edit(body)
         RESPONSE.setStatus(204)

Modified: CMF/trunk/CMFDefault/tests/test_Document.py
===================================================================
--- CMF/trunk/CMFDefault/tests/test_Document.py	2007-02-07 09:25:52 UTC (rev 72412)
+++ CMF/trunk/CMFDefault/tests/test_Document.py	2007-02-07 09:37:45 UTC (rev 72413)
@@ -146,7 +146,7 @@
         d = self._makeOne('foo')
         d.edit('structured-text', FAUX_HTML_LEADING_TEXT)
         fully_edited = d.cooked_text
-        d._edit(FAUX_HTML_LEADING_TEXT, 'structured-text')
+        d._edit(FAUX_HTML_LEADING_TEXT)
         partly_edited = d.cooked_text
         self.assertEquals(fully_edited, partly_edited)
 



More information about the CMF-checkins mailing list