[Zope3-checkins] CVS: Zope3/src/zope/pagetemplate - pagetemplatefile.py:1.5

Fred L. Drake, Jr. fred@zope.com
Tue, 1 Apr 2003 14:36:15 -0500


Update of /cvs-repository/Zope3/src/zope/pagetemplate
In directory cvs.zope.org:/tmp/cvs-serv4249

Modified Files:
	pagetemplatefile.py 
Log Message:
When loading a PageTemplateFile that's not XML, make sure it ends up
loaded in text mode.  This was a problem for Windows.


=== Zope3/src/zope/pagetemplate/pagetemplatefile.py 1.4 => 1.5 ===
--- Zope3/src/zope/pagetemplate/pagetemplatefile.py:1.4	Tue Mar 25 06:23:10 2003
+++ Zope3/src/zope/pagetemplate/pagetemplatefile.py	Tue Apr  1 14:36:14 2003
@@ -63,7 +63,13 @@
             text = f.read()
         finally:
             f.close()
-        self.pt_edit(text, sniff_type(text))
+        t = sniff_type(text)
+        if t != "text/xml" and "\r" in text:
+            # For HTML, we really want the file read in text mode:
+            f = open(self.filename)
+            text = f.read()
+            f.close()
+        self.pt_edit(text, t)
         self._cook()
         if self._v_errors:
             logging.error('PageTemplateFile: Error in template: %s',