[Python-Dev] Re: cgitb.py for Python 2.2

Michel Pelletier michel@digicool.com
Tue, 31 Jul 2001 21:10:56 -0700

Ka-Ping Yee wrote:
> The point was to provide an instant, effortless improvement for all
> of the Python CGI scripts out there.  If programmers have to manually
> edit all of their CGI scripts to insert
>     import sys, cgitb
>     sys.excepthook = cgitb.excepthook
> then it's just as annoying as inserting
>     import sys
>     sys.stderr = sys.stdout

But Zope would have to do:

  import sys
  _sys_excepthook = sys.excepthook
  from cgi import FieldStorage, escape
  sys.excepthook = _sys_excepthook

and I don't think we'd be the only one that would have to do that.  Zope
has the environment variable set when accessed from CGI, but its stderr
gets redirected to a log file for plain text human consumption. 
importing cgi would have an unintended side effect. I would prefer an
explicit interface than a side effect.  +1 on it being in the standard
lib, or course.