[mod_python] capturing and handling python errors in mod_python

Waitman Gobble waitman at waitman.net
Mon Nov 14 14:30:08 EST 2005


Changing publisher.py as follows:

def handler(req):

    req.allow_methods(["GET", "POST","HEAD"])
    if req.method not in ["GET", "POST", "HEAD"]:
        raise apache.SERVER_RETURN, apache.HTTP_METHOD_NOT_ALLOWED

(added "HEAD" to two lines)

seems to allow proper HEAD requests:

# HEAD http://pyblog.com/index/d
404 Not Found

# HEAD http://pyblog.com/doit/naughty
200 OK

# HEAD http://pyblog.com/doit/good
500 Internal Server Error

If you know why HEAD should be forbidden, let me know.

I'd still like to catch uncaught exceptions somehow.

Thank you,

-- 
Waitman Gobble
http://waitman.net/
(707) 237-6921



More information about the Mod_python mailing list