durumdara
durumdara at gmail.com
Fri Sep 22 04:22:40 EDT 2006
Hi ! Eric Brunson írta: >> If I understand it good, I can specify one handler script for one >> directory. >> Anywhere, where I specify a handler, the handler script working for >> all .py (both for existing and not existing). > > Not precisely (and someone please help out if I express this > incorrectly). You can add a handler for dealing with .py files in > which case .py files will be handled by that handler, or you can set a > handler for URLs, which will perform a sort of module resolution > algorithm on the URL. In the first case, which I'm least familiar > with, if you associate a handler with a .py file, referencing a file > that doesn't exist will give you a 404 error. > When I used this model (see below), I not got error: every py filename accepted, but only mptest.py started: LoadModule python_module modules/mod_python.so <Directory c:/web/apache22/htdocs/> AddHandler python-program .py PythonHandler mptest PythonDebug On </Directory> mptest.py: from mod_python import apache def handler(req): req.content_type = 'text/html' req.write('Handler: mptest.py<br>') req.write('Actual (URL defined) filename: '+req.filename) req.write('<br>Some random number: ') import random req.write(str(random.randint(0,1000))) return apache.OK The URL I write: http://localhost:7080/index_ssss.py The result is: Handler: mptest.py Actual (URL defined) filename: C:/web/apache22/htdocs/index_ssss.py Some random number: 594 The index_ssss does not exists, but the handler catched it, and handle the request with mptest.py. So I don't get 404 error, but this is good for me: I can handle every problem in one script ! Thanks for your help: dd
|