[mod_python] Mod_python + arguments

Joshua Schmidlkofer menion at asylumwear.com
Fri Jan 23 11:58:22 EST 2004


My mod_python script is not getting any arguments.  I have googled a
bit, and looked my small archive of the mailing list.  I don't see the
problem being references.

Stock RedHat 9:
   mod_python-3.0.1-3
   httpd-2.0.40-21.9
   python-2.2.2-26

I can upgrade if needed, but I just wondered if that is necessary.

Apache config:
<snip>

<Location /proxy>
    SetHandler python-program
    PythonPath "sys.path + ['/var/www/html/proxy']"
    PythonHandler handler
    #PythonHandler mod_python.publisher
</Location>

<snip>



Here is my url:
http://localhost/proxy/handler?crow=bar&name=foo

here are a few things:
uri: (None, None, None, None, None, None, '/proxy/handler', 'crow=bar&name=foo', None)

I can't get named arguments, and *args, and **kwargs reveals nothing:

<snip>
  kwargs:{}
    args:()
<snip>


my script:

<snip>
from mod_python import apache

def handler(req, *args, **kwargs):
    req.content_type = "text/html"
    req.send_http_header()

    extra = ""
    for k,v in locals().items():
        if k == 'extra': continue
        extra += "<p>%s:%s\n" % (str(k),str(v))
        continue

    extra += "<br><hr>\n"
    extra += "Args:<p>len: %d<br><p>contents: %s\n" % (len(args),str(args))
    
    extra += "<br><hr>\n"
    extra += "uri: %s<br><br>\n" % str(req.parsed_uri)
    extra += "args: %s<br><br>\n" % str(req.args)
    extra += "req: %s\n" % str(dir(req))
   
    extra += "<br><hr>\n"
    extra += "<br>Apache: %s\n" % str(dir(apache))

    req.write(content % extra)

    return apache.OK
<snip>





More information about the Mod_python mailing list