[Zope-Checkins] CVS: Zope3/lib/python/Zope/Publisher/HTTP - BrowserPayload.py:1.1.2.11
Shane Hathaway
shane@cvs.zope.org
Mon, 18 Mar 2002 15:07:23 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Publisher/HTTP
In directory cvs.zope.org:/tmp/cvs-serv23827
Modified Files:
Tag: Zope-3x-branch
BrowserPayload.py
Log Message:
Made use of the HTML exception formatter.
=== Zope3/lib/python/Zope/Publisher/HTTP/BrowserPayload.py 1.1.2.10 => 1.1.2.11 ===
from Zope.Publisher.Converters import get_converter
from Zope.Publisher.Exceptions import Redirect, Unauthorized
+from Zope.Exceptions.ExceptionFormatter import format_exception
latin1_alias_match = re.compile(
@@ -506,8 +507,8 @@
# for apps to control the status code.
response.setStatus(tname)
- tb = escape(traceback_string(t, v, exc_info[2]))
- body = self._html(title, "<pre>\n%s\n</pre>" % tb)
+ tb = ''.join(format_exception(t, v, exc_info[2], 1))
+ body = self._html(title, "%s" % tb)
response.setBody(body)
@@ -596,39 +597,4 @@
REC=RECORD|RECORDS
EMPTY=16
CONVERTED=32
-
-
-def format_exception(etype,value,tb,limit=None):
- import traceback
- result=['Traceback (innermost last):']
- if limit is None:
- if hasattr(sys, 'tracebacklimit'):
- limit = sys.tracebacklimit
- n = 0
- while tb is not None and (limit is None or n < limit):
- f = tb.tb_frame
- lineno = tb.tb_lineno
- co = f.f_code
- filename = co.co_filename
- name = co.co_name
- locals = f.f_locals
- globals = f.f_globals
- modname = globals.get('__name__', filename)
- result.append(' Module %s, line %d, in %s'
- % (modname,lineno,name))
- try: result.append(' (Object: %s)' %
- locals[co.co_varnames[0]].__name__)
- except: pass
- try: result.append(' (Info: %s)' %
- str(locals['__traceback_info__']))
- except: pass
- tb = tb.tb_next
- n = n+1
- result.append(' '.join(traceback.format_exception_only(etype, value)))
- return result
-
-
-def traceback_string(t,v,tb):
- tb=format_exception(t,v,tb,200)
- return '\n'.join(tb)