[mod_python] capturing and handling python errors in mod_python

Waitman Gobble waitman at waitman.net
Mon Nov 14 14:23:27 EST 2005

Ok, I think I get the gist of the 405 thing a little.

When I do "PythonHandler mod_python.publisher" in httpd.conf I am telling
it to use the publisher.py (in the lib of the source download). At least
this is my guess :-)

I am new to this, so I suppose I didn't understand before. But it looks
like I really shouldn't be writing to the request object (*if*) I am going
to use the mod_python.publisher. All I should do is return something
interesting from my functions. I am beginning to understand how
publisher.py works a bit better now.

from publisher.py

def handler(req):

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

So that is why I am getting a 405 on HEAD requests. I really like to do
HEAD requests and I have a feeling that search engine spiders like that
sort of activity as well.  Maybe publisher.py should allow it? Does anyone
know why this method was forbidden?

Waitman Gobble
(707) 237-6921

More information about the Mod_python mailing list