comparison roundup/cgitb.py @ 602:c242455d9b46 config-0-4-0-branch

Brought the config branch up to date with HEAD
author Richard Jones <richard@users.sourceforge.net>
date Wed, 06 Feb 2002 04:05:55 +0000
parents bdc2ea127ae9
children
comparison
equal deleted inserted replaced
601:912029653c1c 602:c242455d9b46
1 # 1 #
2 # This module was written by Ka-Ping Yee, <ping@lfw.org>. 2 # This module was written by Ka-Ping Yee, <ping@lfw.org>.
3 # 3 #
4 # $Id: cgitb.py,v 1.7 2001-11-22 15:46:42 jhermann Exp $ 4 # $Id: cgitb.py,v 1.7.2.1 2002-02-06 04:05:53 richard Exp $
5 5
6 __doc__ = """ 6 __doc__ = """
7 Extended CGI traceback handler by Ka-Ping Yee, <ping@lfw.org>. 7 Extended CGI traceback handler by Ka-Ping Yee, <ping@lfw.org>.
8 """ 8 """
9 9
10 import sys, os, types, string, keyword, linecache, tokenize, inspect, pydoc 10 import sys, os, types, string, keyword, linecache, tokenize, inspect, pydoc
11
12 from i18n import _
11 13
12 def breaker(): 14 def breaker():
13 return ('<body bgcolor="#f0f0ff">' + 15 return ('<body bgcolor="#f0f0ff">' +
14 '<font color="#f0f0ff" size="-5"> > </font> ' + 16 '<font color="#f0f0ff" size="-5"> > </font> ' +
15 '</table>' * 5) 17 '</table>' * 5)
21 pyver = 'Python ' + string.split(sys.version)[0] + '<br>' + sys.executable 23 pyver = 'Python ' + string.split(sys.version)[0] + '<br>' + sys.executable
22 head = pydoc.html.heading( 24 head = pydoc.html.heading(
23 '<font size=+1><strong>%s</strong>: %s</font>'%(str(etype), str(evalue)), 25 '<font size=+1><strong>%s</strong>: %s</font>'%(str(etype), str(evalue)),
24 '#ffffff', '#aa55cc', pyver) 26 '#ffffff', '#aa55cc', pyver)
25 27
26 head = head + ('<p>A problem occurred while running a Python script. ' 28 head = head + (_('<p>A problem occurred while running a Python script. '
27 'Here is the sequence of function calls leading up to ' 29 'Here is the sequence of function calls leading up to '
28 'the error, with the most recent (innermost) call first. ' 30 'the error, with the most recent (innermost) call first. '
29 'The exception attributes are:') 31 'The exception attributes are:'))
30 32
31 indent = '<tt><small>%s</small>&nbsp;</tt>' % ('&nbsp;' * 5) 33 indent = '<tt><small>%s</small>&nbsp;</tt>' % ('&nbsp;' * 5)
32 traceback = [] 34 traceback = []
33 for frame, file, lnum, func, lines, index in inspect.trace(context): 35 for frame, file, lnum, func, lines, index in inspect.trace(context):
34 if file is None: 36 if file is None:
46 48
47 level = ''' 49 level = '''
48 <table width="100%%" bgcolor="#d8bbff" cellspacing=0 cellpadding=2 border=0> 50 <table width="100%%" bgcolor="#d8bbff" cellspacing=0 cellpadding=2 border=0>
49 <tr><td>%s %s</td></tr></table>''' % (link, call) 51 <tr><td>%s %s</td></tr></table>''' % (link, call)
50 52
51 if file is None: 53 if index is None or file is None:
52 traceback.append('<p>' + level) 54 traceback.append('<p>' + level)
53 continue 55 continue
54 56
55 # do a fil inspection 57 # do a fil inspection
56 names = [] 58 names = []
71 for name in names: 73 for name in names:
72 if name in frame.f_code.co_varnames: 74 if name in frame.f_code.co_varnames:
73 if locals.has_key(name): 75 if locals.has_key(name):
74 value = pydoc.html.repr(locals[name]) 76 value = pydoc.html.repr(locals[name])
75 else: 77 else:
76 value = '<em>undefined</em>' 78 value = _('<em>undefined</em>')
77 name = '<strong>%s</strong>' % name 79 name = '<strong>%s</strong>' % name
78 else: 80 else:
79 if frame.f_globals.has_key(name): 81 if frame.f_globals.has_key(name):
80 value = pydoc.html.repr(frame.f_globals[name]) 82 value = pydoc.html.repr(frame.f_globals[name])
81 else: 83 else:
82 value = '<em>undefined</em>' 84 value = _('<em>undefined</em>')
83 name = '<em>global</em> <strong>%s</strong>' % name 85 name = '<em>global</em> <strong>%s</strong>' % name
84 lvals.append('%s&nbsp;= %s' % (name, value)) 86 lvals.append('%s&nbsp;= %s' % (name, value))
85 if lvals: 87 if lvals:
86 lvals = string.join(lvals, ', ') 88 lvals = string.join(lvals, ', ')
87 lvals = indent + ''' 89 lvals = indent + '''
120 print breaker() 122 print breaker()
121 print html() 123 print html()
122 124
123 # 125 #
124 # $Log: not supported by cvs2svn $ 126 # $Log: not supported by cvs2svn $
127 # Revision 1.10 2002/01/16 04:49:45 richard
128 # Handle a special case that the CGI interface tickles. I need to check if
129 # this needs fixing in python's core.
130 #
131 # Revision 1.9 2002/01/08 11:56:24 richard
132 # missed an import _
133 #
134 # Revision 1.8 2002/01/05 02:22:32 richard
135 # i18n'ification
136 #
137 # Revision 1.7 2001/11/22 15:46:42 jhermann
138 # Added module docstrings to all modules.
139 #
125 # Revision 1.6 2001/09/29 13:27:00 richard 140 # Revision 1.6 2001/09/29 13:27:00 richard
126 # CGI interfaces now spit up a top-level index of all the instances they can 141 # CGI interfaces now spit up a top-level index of all the instances they can
127 # serve. 142 # serve.
128 # 143 #
129 # Revision 1.5 2001/08/07 00:24:42 richard 144 # Revision 1.5 2001/08/07 00:24:42 richard

Roundup Issue Tracker: http://roundup-tracker.org/