Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Apache/mod_python: Registering a request handler dynamically

Reply
Thread Tools

Apache/mod_python: Registering a request handler dynamically

 
 
Samuel
Guest
Posts: n/a
 
      12-28-2008
Hi,

Is there a way to dynamically overwrite the request handler from within
mod_python scripts? Something along those lines:

---------------
from mod_python import apache

def myhandler(request):
request.content_type = 'text/plain'
request.write('Hello world')

apache.set_default_handler(myhandler)
---------------

I specifically want to avoid changing the Apache directive, as this code
is supposed to function in a place where the user has no permission to
override the Apache directive.

The reason is that I am trying to hide the difference between different
environments (such as mod_python or CGI) from the developer, such that
the following is possible:

---------------
#!/usr/bin/python
import os, os.path
os.chdir(os.path.dirname(__file__))
from PleaseHideMyEnvironment import RequestHandler

def index(request):
request.write('Hello World')

RequestHandler(index)
---------------

So at the time at which RequestHandler() is created, I need a way to make
sure that mod_python calls to the RequestHandler instead of the normal
handler, whenever a new request is made.

Any idea?

-Samuel
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How does a handler render the request to another handler in the MVC of SPRING 2.0.1 framework? rayzyang@gmail.com Java 0 05-30-2007 11:28 AM
Re: registering/re-registering ASP.NET 1.1.4322 with IIS Juan T. Llibre ASP .Net 2 12-16-2006 12:29 AM
Problem with IE6 not registering an event handler Andrew Ip Javascript 4 11-29-2006 03:05 PM
Registering a data class with a handler class Chris Jewell C++ 7 07-21-2006 03:38 PM
registering events for dynamically declared DataGrids Faredoon Irani via .NET 247 ASP .Net Web Controls 0 08-05-2004 09:39 AM



Advertisments