S
Samuel
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
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