[mod_python] does add_handler even work?

Johannes Erdfelt johannes at erdfelt.com
Tue Oct 12 18:37:08 EDT 2004


I'm trying to develop a mod_python application, but I'm having problems
using Apache 2.0.51 and mod_python 3.1.3.

I'm trying to use the add_handler() method from the request object to
add a request handler after I've determined the URL is one I want to
handle. Unfortunately, it doesn't seem to work. I always get a 404
error.

Some example code I've written:

from mod_python import apache

def authenhandler(req):
  req.add_handler("PythonHandler", "aptest")
  return apache.OK

def handler(req):
  req.content_type = 'text/plain'
  req.write("foobar\nbaz\n")
  return apache.OK

Then in my Apache configuration, I have:

PythonPath "sys.path+['/tmp/python']
PythonAuthenHandler aptest
PythonHandler aptest

I've tried using the Init, Trans and Fixup handlers too, with no
success.

If I add a SetHandler, then everything works, but then other modules
like PHP and mod_autoindex stop working.

Has anyone been able to use add_handler successfully?

Unrelated to the actual problem I'm having with add_handler(), the
reason I want to do this is because AddHandler isn't sufficient (I want
to handle multiple types of filename extensions and no extension).

JE



More information about the Mod_python mailing list