diff options
author | Fred Drake <fdrake@acm.org> | 2003-04-01 19:36:14 +0000 |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2003-04-01 19:36:14 +0000 |
commit | 5c80a4d248621c235329b7d2727fb8c191e1884e (patch) | |
tree | 5f071566eca8c8ba983e2c45ae0d11b700583d21 | |
parent | 64a1c97b60ecf21b8b21b95e9f016169a428ba4b (diff) | |
download | zope-pagetemplate-5c80a4d248621c235329b7d2727fb8c191e1884e.tar.gz |
When loading a PageTemplateFile that's not XML, make sure it ends up
loaded in text mode. This was a problem for Windows.
-rw-r--r-- | pagetemplatefile.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pagetemplatefile.py b/pagetemplatefile.py index da73aa9..6e7e0fc 100644 --- a/pagetemplatefile.py +++ b/pagetemplatefile.py @@ -16,7 +16,7 @@ Zope object encapsulating a Page Template from the filesystem. """ -__version__ = '$Revision: 1.4 $'[11:-2] +__version__ = '$Revision: 1.5 $'[11:-2] __metaclass__ = type @@ -63,7 +63,13 @@ class PageTemplateFile(PageTemplate): 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', |