[mod_python] Apache/mod_python: Registering a request handler dynamically

Samuel Abels newsgroups at debain.org
Sun Dec 28 19:14:31 EST 2008


On Mon, 2008-12-29 at 10:26 +1100, Graham Dumpleton wrote:
> Going back to your original request to be able to write:
> 
>   apache.set_default_handler(myhandler)
> 
> This can simply not work as the script file will not be loaded until a
> request arrives which maps to that script, which is by then too late
> to run that code.

By that time it is mapped to the script, but is it also mapped to the
specific function? In other words, perhaps there is a way to map all
requests that are mapped to the file to one specific function? This
would obviously have to interact with whatever handler was already
selected.

> One can provide handlers for various phases of Apache
> programmatically, but it requires you to have written at least one
> hook function to register it.
> This requires configuration to even have
> that run and the registration is only for that specific request and
> cannot be registered for all requests.

I see how this would work, but yeah, it won't help for what I'm trying
to do.

> > I am using WSGI as one alternative. The point is in adding fallback
> > solutions.
> 
> Then you are looking at it the wrong way. You should be targeting WSGI
> API exclusively for how your application talks to the web server

I've been using a bridge even when binding to CGI exclusively, mostly
because I wanted a class-based interface and a clean API around it. The
same goes for WSGI.

> Part of the problem as I sort of see it, is it looks like you have
> made the decision to write your application against the mod_python
> specific APIs and are now stuck because you have to make it work on
> other hosting solutions, by creating your own custom adapters and fake
> requests objects that look like mod_python request object.

Nothing like that - I am adding the support for mod_python only just
now.

-Samuel



More information about the Mod_python mailing list