[ZPT] CVS: Zope/lib/python/Products/PageTemplates - PageTemplate.py:1.21.2.4 PageTemplateFile.py:1.12.2.1 TALES.py:1.28.2.5 ZopePageTemplate.py:1.30.2.4
Shane Hathaway
shane@cvs.zope.org
Tue, 2 Apr 2002 17:55:04 -0500
Update of /cvs-repository/Zope/lib/python/Products/PageTemplates
In directory cvs.zope.org:/tmp/cvs-serv29342
Modified Files:
Tag: shane-better-tracebacks-branch
PageTemplate.py PageTemplateFile.py TALES.py
ZopePageTemplate.py
Log Message:
- Updated the attributes of traceback supplement objects.
- Used a simpler pt_source_file. A new URL protocol is not needed.
- Made PageTemplateFiles anti-persistent using __getstate__ rather than
__setstate__. Earlier warning.
=== Zope/lib/python/Products/PageTemplates/PageTemplate.py 1.21.2.3 => 1.21.2.4 ===
class PageTemplateTracebackSupplement:
- """Implementation of Products.ErrorReporter.ITracebackSupplement"""
+ #__implements__ = ITracebackSupplement
+
def __init__(self, pt):
- self.manageable_object = pt
- try:
- errors = pt.pt_errors()
- except: # We're already trying to report an error, don't make another.
- errors = None
- self.errors = errors
+ self.object = pt
+ w = pt.pt_warnings()
+ e = pt.pt_errors()
+ if e:
+ w = list(w) + list(e)
+ self.warnings = w
- def getInfo(self, as_html=0):
- errors = self.errors
- if not errors:
- return None
- if not as_html:
- return ' - Errors:\n %s' % '\n '.join(errors)
- else:
- from cgi import escape
- s = '<br />'.join(map(escape, errors))
- return '<b>Errors:</b><br />%s' % s
=== Zope/lib/python/Products/PageTemplates/PageTemplateFile.py 1.12 => 1.12.2.1 ===
return PageTemplate.pt_macros(self)
+ def pt_source_file(self):
+ """Returns a file name to be compiled into the TAL code."""
+ return self.__name__ # Don't reveal filesystem paths
+
def _cook_check(self):
if self._v_last_read and not DevelopmentMode:
return
@@ -132,6 +136,6 @@
__roles__ = ComputedAttribute(_get__roles__, 1)
- def __setstate__(self, state):
+ def __getstate__(self):
raise StorageError, ("Instance of AntiPersistent class %s "
"cannot be stored." % self.__class__.__name__)
=== Zope/lib/python/Products/PageTemplates/TALES.py 1.28.2.4 => 1.28.2.5 ===
+
class TALESTracebackSupplement:
- """Implementation of Products.ErrorReporter.ITracebackSupplement"""
+ """Implementation of ITracebackSupplement"""
def __init__(self, context, expression):
self.context = context
- self.expression = repr(expression)
+ self.source_url = context.source_file
self.line = context.position[0]
self.column = context.position[1]
+ self.expression = repr(expression)
- source_file = context.source_file
- if (isinstance(source_file, StringType) and
- source_file.startswith('traversal:')):
- p = source_file[10:]
- # XXX There should be a better way to find the Zope app root.
- root = self.context.contexts.get('root', None)
- if root is not None:
- try:
- object = root.unrestrictedTraverse(p)
- except:
- # Hmm, couldn't find the script??
- pass
- else:
- self.manageable_object = object
-
def getInfo(self, as_html=0):
import pprint
data = self.context.contexts.copy()
- if data.has_key('request'):
- data['request'] = '(not shown)'
s = pprint.pformat(data)
if not as_html:
return ' - Names:\n %s' % s.replace('\n', '\n ')
=== Zope/lib/python/Products/PageTemplates/ZopePageTemplate.py 1.30.2.3 => 1.30.2.4 ===
"""Returns a file name to be compiled into the TAL code."""
try:
- # URL-like syntax.
- return 'traversal:' + '/'.join(self.getPhysicalPath())
+ return '/'.join(self.getPhysicalPath())
except:
# This page template is being compiled without an
# acquisition context, so we don't know where it is. :-(