[mod_python] using publisher as a virtual dir with apache2/mp3

Manfred Stienstra manfred.stienstra at dwerg.net
Fri Mar 26 08:37:54 EST 2004


On Fri, 2004-03-26 at 03:58, Marc O. Sandlus wrote:
> and dir.py was something like:
> 
> |def file1(req):
> |  return "Hello World"
> 
> Requesting http://www.mydomain.com/file1 would return "Hello world".

Put this is a location or .htaccess:

SetHandler python-program
PythonHandler handler

In the python script:

from mod_python import apache

def file1(request):
    request.write("file1")

def file2(request):
    request.write("file2")

def dir1/file1(request):
    request.write("dir1/file1")

def handler(request):
    request.content_type = "text/plain"
    function = request.uri[1:].replace('/','_')
    if function[-1] == '_':
        function = function[:-1]
    try:
        function(request)
    except AttributeError: # I think (:
        return apache.DECLINED


Manfred



More information about the Mod_python mailing list