[Zope3-checkins]
SVN: Zope3/trunk/src/zope/pagetemplate/pagetemplatefile.py
Refactoring: method extracted
Dmitry Vasiliev
dima at hlabs.spb.ru
Wed Jul 20 10:08:36 EDT 2005
Log message for revision 37345:
Refactoring: method extracted
Changed:
U Zope3/trunk/src/zope/pagetemplate/pagetemplatefile.py
-=-
Modified: Zope3/trunk/src/zope/pagetemplate/pagetemplatefile.py
===================================================================
--- Zope3/trunk/src/zope/pagetemplate/pagetemplatefile.py 2005-07-20 07:35:36 UTC (rev 37344)
+++ Zope3/trunk/src/zope/pagetemplate/pagetemplatefile.py 2005-07-20 14:08:06 UTC (rev 37345)
@@ -50,24 +50,16 @@
path = package_home(_prefix)
return path
- def _cook_check(self):
- if self._v_last_read and not __debug__:
- return
+ def _read_file(self):
__traceback_info__ = self.filename
- try:
- mtime = os.path.getmtime(self.filename)
- except OSError:
- mtime = 0
- if self._v_program is not None and mtime == self._v_last_read:
- return
f = open(self.filename, "rb")
try:
text = f.read(XML_PREFIX_MAX_LENGTH)
except:
f.close()
raise
- t = sniff_type(text)
- if t == "text/xml":
+ type = sniff_type(text)
+ if type == "text/xml":
text += f.read()
else:
# For HTML, we really want the file read in text mode:
@@ -76,7 +68,20 @@
text = f.read()
text = unicode(text, self.encoding)
f.close()
- self.pt_edit(text, t)
+ return text, type
+
+ def _cook_check(self):
+ if self._v_last_read and not __debug__:
+ return
+ __traceback_info__ = self.filename
+ try:
+ mtime = os.path.getmtime(self.filename)
+ except OSError:
+ mtime = 0
+ if self._v_program is not None and mtime == self._v_last_read:
+ return
+ text, type = self._read_file()
+ self.pt_edit(text, type)
self._cook()
if self._v_errors:
logging.error('PageTemplateFile: Error in template: %s',
More information about the Zope3-Checkins
mailing list