[Zope-Checkins] CVS: Zope3/lib/python/Zope/Exceptions - ExceptionFormatter.py:1.1.2.2 ITracebackSupplement.py:1.1.2.2
Shane Hathaway
shane@cvs.zope.org
Thu, 14 Mar 2002 17:48:33 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Exceptions
In directory cvs.zope.org:/tmp/cvs-serv29492
Modified Files:
Tag: Zope-3x-branch
ExceptionFormatter.py ITracebackSupplement.py
Log Message:
- Fixed line endings.
- Replaced ITraceback.manageable_object with source_url, which moves
dependencies on computing URLs out to code where exceptions occur.
=== Zope3/lib/python/Zope/Exceptions/ExceptionFormatter.py 1.1.2.1 => 1.1.2.2 ===
return ' - %s' % line
- def formatObjectInfo(self, mo):
- """Returns a line about the object.
-
- Someday this should be replaced with code that
- produces a URL for editing the object.
- """
- result = []
- class_ = getattr(mo, '__class__', None)
- ob_type = getattr(class_, '__name__', 'Object')
- s = repr(mo)
- path = self.getObjectPath(mo)
- if path:
- s = s + ' at ' + '/'.join(path)
- result.append(self.formatSupplementLine(s))
- return result
+ def formatSourceURL(self, url):
+ return [self.formatSupplementLine(url)]
def formatSupplement(self, supplement, tb):
result = []
fmtLine = self.formatSupplementLine
- mo = getattr(supplement, 'manageable_object', None)
- if mo is not None:
- result.extend(self.formatObjectInfo(mo))
+ url = getattr(supplement, 'source_url', None)
+ if url is not None:
+ result.extend(self.formatSourceURL(url))
line = getattr(supplement, 'line', 0)
if line == -1:
@@ -202,16 +189,16 @@
def formatException(self, etype, value, tb):
# The next line provides a way to detect recursion.
__exception_formatter__ = 1
- result = [self.getPrefix()]
+ result = [self.getPrefix() + '\n']
limit = self.getLimit()
n = 0
while tb is not None and (limit is None or n < limit):
if tb.tb_frame.f_locals.get('__exception_formatter__'):
# Stop recursion.
- result.append('(Recursive formatException() stopped)')
+ result.append('(Recursive formatException() stopped)\n')
break
line = self.formatLine(tb)
- result.append(line)
+ result.append(line + '\n')
tb = tb.tb_next
n = n + 1
exc_line = self.formatExceptionOnly(etype, value)
=== Zope3/lib/python/Zope/Exceptions/ITracebackSupplement.py 1.1.2.1 => 1.1.2.2 ===
"""
- manageable_object = Attribute(
- 'manageable_object',
- """Optional. Set to the script where the exception occurred.
+ source_url = Attribute(
+ 'source_url',
+ """Optional. Set to URL of the script where the exception occurred.
Normally this generates a URL in the traceback that the user
can visit to manage the object. Set to None if unknown or