11#
22# This module was written by Ka-Ping Yee, <[email protected] >. 33#
4- # $Id: cgitb.py,v 1.7 2002-09-25 02:10:25 richard Exp $
4+ # $Id: cgitb.py,v 1.8 2003-01-21 23:54:28 richard Exp $
55
66__doc__ = """
77Extended CGI traceback handler by Ka-Ping Yee, <[email protected] >. @@ -25,9 +25,12 @@ def niceDict(indent, dict):
2525 return '\n ' .join (l )
2626
2727def pt_html (context = 5 ):
28- l = ['<h1>Templating Error</h1>'
29- '<p class="help">Debugging information follows</p>'
30- '<ol>' ]
28+ esc = cgi .escape
29+ l = ['<h1>Templating Error</h1>' ,
30+ '<p><b>%s</b>: %s</p>' % (esc (str (sys .exc_type )),
31+ esc (str (sys .exc_value ))),
32+ '<p class="help">Debugging information follows</p>' ,
33+ '<ol>' ,]
3134 from roundup .cgi .PageTemplates .Expressions import TraversalError
3235 t = inspect .trace (context )
3336 t .reverse ()
@@ -38,20 +41,20 @@ def pt_html(context=5):
3841 if isinstance (ti , TraversalError ):
3942 s = []
4043 for name , info in ti .path :
41- s .append ('<li>"%s" (%s)</li>' % (name ,cgi . escape (repr (info ))))
44+ s .append ('<li>"%s" (%s)</li>' % (name , esc (repr (info ))))
4245 s = '\n ' .join (s )
4346 l .append ('<li>Looking for "%s", current path:<ol>%s</ol></li>' % (
4447 ti .name , s ))
4548 else :
46- l .append ('<li>In %s</li>' % cgi . escape (str (ti )))
49+ l .append ('<li>In %s</li>' % esc (str (ti )))
4750 if locals .has_key ('__traceback_supplement__' ):
4851 ts = locals ['__traceback_supplement__' ]
4952 if len (ts ) == 2 :
5053 supp , context = ts
5154 s = 'A problem occurred in your template "%s".' % str (context .id )
5255 if context ._v_errors :
5356 s = s + '<br>' + '<br>' .join (
54- [cgi . escape (x ) for x in context ._v_errors ])
57+ [esc (x ) for x in context ._v_errors ])
5558 l .append ('<li>%s</li>' % s )
5659 elif len (ts ) == 3 :
5760 supp , context , info = ts
0 commit comments