Graham Dumpleton
grahamd at dscpl.com.au
Mon May 8 02:01:39 EDT 2006
gOLeM wrote .. > from mod_python import apache > > def handler(req, arg = "1"): > req.content_type = 'text/html' > myfile = open("/var/www/html/ajax/index.html", "r"); > for line in myfile.readlines() : > req.write(line) > return apache.OK > > this is myhandler.py > > > <Directory "/var/www/html/xxxxxxxxx"> > AddHandler mod_python .py > PythonHandler myhandler > PythonDebug On > </Directory> > > when i try http://localhost/myhandler.py?arg=2 > it is not taking the value of arg as 2. Is it the expected behaviour > or am i doing something wrong? You are mixing mod_python.publisher concepts with basic mod_python handler concepts. If using a basic mod_python handler you will need to use util.FieldStorage explicitly to decode form parameters. Thus something (untested and I haven't used it directly for a while) like: from mod_python import util def handler(req): form = util.FieldStorage(req) arg = form.getfirst("arg", "1") req.content_type = 'text/html' myfile = open("/var/www/html/ajax/index.html", "r"); for line in myfile.readlines() : req.write(line) return apache.OK See util.FieldStorage documentation. http://www.modpython.org/live/current/doc-html/pyapi-util-fstor.html http://www.modpython.org/live/current/doc-html/pyapi-util-fstor-fld.html Anyway, even if wrong, should point you in right direction. :-) Graham
|