Log message for revision 78366:
  Merged r78365 from 2.10 branch.
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Products/PageTemplates/ZopePageTemplate.py
  U   Zope/trunk/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt  2007-07-26 22:04:15 UTC (rev 78365)
+++ Zope/trunk/doc/CHANGES.txt  2007-07-26 22:10:30 UTC (rev 78366)
@@ -132,6 +132,9 @@
 
     Bugs Fixed
 
+      - ZopePageTemplate's pt_edit did not recognize content type arguments
+        which had a charset information included.
+
       - "version.txt" file was being written to the wrong place by the
         Makefile, causing Zope to report "unreleased version" even for
         released versions.

Modified: Zope/trunk/lib/python/Products/PageTemplates/ZopePageTemplate.py
===================================================================
--- Zope/trunk/lib/python/Products/PageTemplates/ZopePageTemplate.py    
2007-07-26 22:04:15 UTC (rev 78365)
+++ Zope/trunk/lib/python/Products/PageTemplates/ZopePageTemplate.py    
2007-07-26 22:10:30 UTC (rev 78366)
@@ -126,7 +126,7 @@
         encoding = None
         output_encoding = None
 
-        if content_type in ('text/xml',):
+        if content_type.startswith('text/xml'):
 
             if is_unicode:
                 encoding = None
@@ -134,9 +134,8 @@
             else:
                 encoding = encodingFromXMLPreamble(text)
                 output_encoding = 'utf-8'
-            
 
-        elif content_type in ('text/html',) :
+        elif content_type.startswith('text/html'):
 
             charset = charsetFromMetaEquiv(text)
 
@@ -156,8 +155,8 @@
                     output_encoding = 'iso-8859-15'
 
         else:
-            utext, encoding = convertToUnicode(text, 
-                                               content_type, 
+            utext, encoding = convertToUnicode(text,
+                                               content_type,
                                                preferred_encodings)
             output_encoding = encoding
 

Modified: 
Zope/trunk/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
===================================================================
--- Zope/trunk/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py  
2007-07-26 22:04:15 UTC (rev 78365)
+++ Zope/trunk/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py  
2007-07-26 22:10:30 UTC (rev 78366)
@@ -165,6 +165,13 @@
         self.assertEqual(zpt.read(), s)
         self.assertEqual(isinstance(zpt.read(), unicode), True)
 
+    def testEditWithContentTypeCharset(self):
+        manage_addPageTemplate(self.app, 'test', xml_utf8, encoding='utf-8')
+        zpt = self.app['test']
+        xml_unicode = unicode(xml_utf8, 'utf-8').strip()
+        zpt.pt_edit(xml_unicode, 'text/xml')
+        zpt.pt_edit(xml_unicode, 'text/xml; charset=utf-8')
+        self.assertEqual(zpt.read(), xml_unicode)
 
     def _createZPT(self):
         manage_addPageTemplate(self.app, 'test', text=utf8_str, 
encoding='utf-8')

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to