[mod_python] add_handler

Randall Kern randy at teamkern.net
Sat Nov 4 23:42:09 EST 2000

Sorry if this has been covered before, I checked the archives and google, but couldn't find anything.

I am using a PythonTransHandler to map certain requests to files, and then invoke a PythonHandler for those files using request.add_handler.  However, my main handler function is never called.

in /foo/foo.py:

from mod_python import apache

def handler(req):
    req.write("Hello World!\nProcessing on behalf of %s\nFrom foo.py" % req.filename
    return apache.OK

def transhandler(req):

    if stuff:  # stuff is actually a rather complex bit of code...
        req.add_handler("PythonHandler", "foo::handler", "/foo")
        apache.log_error("just called add_handler")
        return apache.OK

    return apache.DECLINED

My error_log file does in fact get the entry "just called...", but the browser always gets the contents of req.filename, NOT the "Hello World..." message from foo.handler.

If I add a SetHandler python-program to my httpd.conf file, the handler() function gets called. It's only when I try to dynamically add the handler that it doesn't work.



P.S. python 2.0, apache 1.3.14, mod_python 2.6.3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.modpython.org/pipermail/mod_python/attachments/20001104/65674beb/attachment-0003.htm

More information about the Mod_python mailing list