$PYTHONDIR/site-packages/croissant/hello.py:
from mod_python import apache
def handler(req,str):
req.content_type = "text/plain"
req.write( str + '_handler_' )
return apache.OK
class requester(object):
def __init__(self, req):
self.a='_init_'
self.req = req
def run(self, req):
self.a=self.a+'_run_'
self.env = req.subprocess_env
return handler(req,self.a + '[' + self.env.get('REQUEST_URI') + ']' )
$HTDOCS/croissant/.htaccess:
SetHandler python-program
PythonHandler Croissant.hello::requester.run
then, http://localhost/croissant/somewhat/long/uri?insomnia=terrible results:
_init__run_[/croissant/somewhat/long/uri?insomnia=terrible]_handler_
Conclusion:
If we specify a class member as a PythonHandler, mod_python automatically instantiates the class.
We need not change httpd.conf to join a directory with mod_python. Just setup .htaccess -
Now I can roll with mod_python. ;')