Very useful message -- Hah!

Mitch Chapman mitch.chapman at mciworld.com
Sun Dec 5 15:08:58 EST 1999


Dan Grassi wrote:
> 
> in article 384A9BE0.B345509 at inka.de, Michael Ströder at
> michael.stroeder at inka.de wrote on 12/5/99 12:07 PM:
> 
> > This message is produces by the web server, not Python.
> 
> Because python did not respond with an error message.

Actually, it did.  Given the Python script from your earlier post,
Python should have output the following to stderr:

  File "<stdin>", line 10
    print "ax"
    ^
SyntaxError: invalid syntax

The web server should have written all of this to its error log.

You're right, this is inconvenient for testing, because it makes you
check elsewhere to find out what went wrong.  This can be especially
frustrating if the web server caches its error log output -- like, for
instance, the web server that comes w. Solaris 2.6.

> >> I wrap all my CGIs in try/except clauses so that
> >> I can see the syntax error in the browser
> 
> For debuging purposes I do not see a problem with a message that states
> there was a syntax error on line x.  Or at a minimum python could return an
> error message of the user's choice.

Zope provides this behavior.  Last time I used Zope it could be
configured
to return error messages to the browser.  But it encoded them as HTML
comments, instead of displaying them directly in the page.  The
user-visible
page showed some sort of generic error message, which, IIRC, you could
customize.  To see the specific traceback, you just needed to
"View->Page Source" in Netscape.

Maybe you should have a look at Zope:  http://www.zope.org.

> But, all of this is just making excuses for the failings of python as a cgi
> language.

It would be more accurate to say that cgilib.py doesn't meet your
expectations.  I think Zope would be a better fit.

-- 
Mitch Chapman
mitch.chapman at mciworld.com




More information about the Python-list mailing list