[Zope-CVS] CVS: Products/ErrorReporter - ExceptionFormatter.py:1.3 ITracebackSupplement.py:1.3
Shane Hathaway
shane@cvs.zope.org
Tue, 5 Mar 2002 17:57:19 -0500
Update of /cvs-repository/Products/ErrorReporter
In directory cvs.zope.org:/tmp/cvs-serv12611/Products/ErrorReporter
Modified Files:
ExceptionFormatter.py ITracebackSupplement.py
Log Message:
Simplified the ITracebackSupplement interface.
=== Products/ErrorReporter/ExceptionFormatter.py 1.2 => 1.3 ===
def formatSupplement(self, supplement, tb):
result = []
- mo = supplement.getManageableObject()
+ mo = getattr(supplement, 'manageable_object', None)
if mo is not None:
path, url = self.getObjectPaths(mo)
if path is not None:
result.append(' - Object: %s (%s)' % (
self.escape(path), self.escape(url)))
- line = supplement.getLine()
+ line = getattr(supplement, 'line', 0)
if line == -1:
line = tb.tb_lineno
- col = supplement.getColumn()
+ col = getattr(supplement, 'column', 0)
if line:
if col:
result.append(' - Line %s, Column %s' % (
@@ -70,12 +70,15 @@
elif col:
result.append(' - Column %s' % self.escape(str(col)))
- expr = supplement.getExpression()
+ expr = getattr(supplement, 'expression', None)
if expr:
result.append(' - Expression: %s' % self.escape(str(expr)))
- extra = supplement.getInfo()
- if extra:
- result.append(extra)
+
+ getInfo = getattr(supplement, 'getInfo', None)
+ if getInfo is not None:
+ extra = getInfo()
+ if extra:
+ result.append(extra)
return self.line_sep.join(result)
def formatTracebackInfo(self, tbi):
@@ -173,17 +176,17 @@
def formatSupplement(self, supplement, tb):
result = []
- mo = supplement.getManageableObject()
+ mo = getattr(supplement, 'manageable_object', None)
if mo is not None:
path, url = self.getObjectPaths(mo)
if path is not None:
result.append('<b>Object: <a href="%s">%s</a></b>' % (
url, path))
- line = supplement.getLine()
+ line = getattr(supplement, 'line', 0)
if line == -1:
line = tb.tb_lineno
- col = supplement.getColumn()
+ col = getattr(supplement, 'column', 0)
if line:
if col:
result.append('<b>Line %s, Column %s</b>' % (
@@ -193,12 +196,15 @@
elif col:
result.append('<b>Column %s</b>' % self.escape(str(col)))
- expr = supplement.getExpression()
+ expr = getattr(supplement, 'expression', None)
if expr:
result.append('<b>Expression: %s</b>' % self.escape(str(expr)))
- extra = supplement.getInfo(as_html=1)
- if extra:
- result.append(extra)
+
+ getInfo = getattr(supplement, 'getInfo', None)
+ if getInfo is not None:
+ extra = getInfo(as_html=1)
+ if extra:
+ result.append(extra)
return self.line_sep.join(result)
def formatTracebackInfo(self, tbi):
=== Products/ErrorReporter/ITracebackSupplement.py 1.2 => 1.3 ===
information to supplement an exception traceback"""
- def getManageableObject():
- """Returns the script where the exception occurred.
+ manageable_object = Interface.Attribute(
+ 'manageable_object',
+ """Set to the script where the exception occurred.
Normally this generates a URL in the traceback to manage the object.
- Returns None if unknown or not available.
+ Set to None if unknown or not available.
"""
+ )
- def getLine():
- """Returns the line number (>=1) where the exception occurred.
+ line = Interface.Attribute(
+ 'line',
+ """Set to the line number (>=1) where the exception occurred.
- Returns 0 if the line number is unknown.
+ Set to 0 if the line number is unknown.
"""
+ )
- def getColumn():
- """Returns the column number (>=1) where the exception occurred.
+ column = Interface.Attribute(
+ 'column',
+ """Set to the column number (>=1) where the exception occurred.
- Returns 0 if the column number is unknown.
+ Set to 0 if the column number is unknown.
"""
+ )
- def getExpression():
- """Returns the expression that was being evaluated.
+ expression = Interface.Attribute(
+ 'expression',
+ """Set to the expression that was being evaluated.
- Returns None if not available or not applicable.
+ Set to None if not available or not applicable.
"""
+ )
def getInfo(as_html=0):
"""Returns a string containing any other useful info.