[ZPT] CVS: Packages/Products/PageTemplates (Products/DC/PageTemplates) - PageTemplate.py:1.11
evan@serenade.digicool.com
evan@serenade.digicool.com
Fri, 18 May 2001 14:13:03 -0400
Update of /cvs-repository/Packages/Products/PageTemplates
In directory serenade:/home/evan/Zope/pt/lib/python/Products/PageTemplates
Modified Files:
PageTemplate.py
Log Message:
Don't cache macro errors, and cook even if text hasn't changed.
--- Updated File PageTemplate.py in package Packages/Products/PageTemplates --
--- PageTemplate.py 2001/05/11 23:44:51 1.10
+++ PageTemplate.py 2001/05/18 18:13:02 1.11
@@ -119,8 +119,7 @@
self.content_type = str(content_type)
if hasattr(text, 'read'):
text = text.read()
- if self._text <> text:
- self.write(text)
+ self.write(text)
def pt_getContext(self):
c = {'template': self,
@@ -169,7 +168,8 @@
errend = find(text, '-->')
if errend >= 0:
text = text[errend + 4:]
- self._text = text
+ if self._text != text:
+ self._text = text
self._cook()
def read(self):
@@ -179,17 +179,13 @@
try:
return self.pt_render(source=1)
except:
- tb = traceback.extract_tb(sys.exc_info()[2])
- tb.reverse()
- self._v_errors = ["Macro expansion failed",
- "%s: %s" % sys.exc_info()[:2],
- ] + map(str, tb)
+ return ('%s\n Macro expansion failed\n %s\n-->\n%s' %
+ (self._error_start, "%s: %s" % sys.exc_info()[:2],
+ self._text) )
- if self.html():
- return ('%s\n %s\n-->\n%s' % (self._error_start,
- join(self._v_errors, '\n '),
- self._text))
- return self._text
+ return ('%s\n %s\n-->\n%s' % (self._error_start,
+ join(self._v_errors, '\n '),
+ self._text))
def _cook(self):
"""Compile the TAL and METAL statments.