[CMF-checkins] CVS: Products/CMFDefault - Document.py:1.73
Jens Vagelpohl
jens at dataflake.org
Wed Oct 27 05:26:17 EDT 2004
Update of /cvs-repository/Products/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv7864/CMFDefault
Modified Files:
Document.py
Log Message:
- Document/NewsItem: If the "plain text" format is selected the
content will no longer be tested for HTML and reduced to text
between opening and closing "body" tags
(http://www.zope.org/Collectors/CMF/214)
- Document/NewsItem: A call to setFormat will now re-cook the
document content if the format has been changed (arising from
discussion about http://www.zope.org/Collectors/CMF/214)
=== Products/CMFDefault/Document.py 1.72 => 1.73 ===
--- Products/CMFDefault/Document.py:1.72 Sat Sep 25 16:32:07 2004
+++ Products/CMFDefault/Document.py Wed Oct 27 05:25:47 2004
@@ -165,7 +165,7 @@
contents=file.read()
if contents:
text = contents
- if html_headcheck(text):
+ if html_headcheck(text) and text_format.lower() != 'plain':
text = bodyfinder(text)
self.setFormat(text_format)
self._edit(text=text, text_format=text_format, safety_belt=safety_belt)
@@ -325,6 +325,8 @@
""" Set text format and Dublin Core resource format.
"""
value = str(format)
+ old_value = self.text_format
+
if value == 'text/html' or value == 'html':
self.text_format = 'html'
elif value == 'text/plain':
@@ -334,6 +336,16 @@
self.text_format = 'plain'
else:
self.text_format = 'structured-text'
+
+ # Did the format change? We might need to re-cook the content.
+ if value != old_value:
+ if html_headcheck(self.text) and value != 'plain':
+ self.text = bodyfinder(self.text)
+
+ self._edit( self.text
+ , text_format=self.text_format
+ , safety_belt=self._safety_belt
+ )
## FTP handlers
security.declareProtected(ModifyPortalContent, 'PUT')
More information about the CMF-checkins
mailing list