Graham Dumpleton
grahamd at dscpl.com.au
Sun Sep 12 19:14:40 EDT 2004
On 12/09/2004, at 6:53 AM, FC wrote: > > Hello, > > I'm playing with mod_python and the servlet module from Daniel > Popowich and I wanted to know how can I have python code and images in > the same directory. > > My htaccess file look like this: > > SetHandler mod_python > PythonHandler mod_python.servlet > PythonDebug on > > Apache try to run every file through the servelet module. I have also > try to change SetHandler in my htaccess file to AddHander mod_python > .mps and AddHandler mod_python .py but that doesn't work. I haven't used mpservlets and can't try it as I don't have Apache 2.0, so take the following however you want. :-) In the code for mpservlets it has: # get the filname which is either an apache-configured # UberServlet (one servlet to handle all requests) or possibly a # modpython servlet. filename = req.get_options().get('UberServlet') or _sm.verify_filename(req) # if the file doesn't exist return 404 if not os.path.isfile(filename): return apache.HTTP_NOT_FOUND # if it's not a mps file, decline the request base, ext = os.path.splitext(filename) if ext != MPS: return apache.DECLINED The end result of this is that if mpservlets doesn't think it can do anything with the request, it will return apache.DECLINED. When this happens, one should expect Apache then to take over, and provided the image file exists which the code above already actually checked for, Apache should serve it up normally. In my experience, this is what happens with mod_python 2.7.10 and Apache 1.3, although having MultiViews on as an option in Apache can sometimes screw it up a bit. Thus I run with: Options -MultiViews The only thing therefore which I can see which would stuff it up is the first part of the code above. Ie., the fiddling to get the actual filename. If an UberServlet was defined, it wouldn't work as I described, nor would it if the name of the image file began with an underscore or dot as verify_filename() marks them as forbidden. The filename being requested must also have an extension. If it doesn't the verify_filename() code will add the mpservlets extension on the end and look for that instead. Don't know if this will help or not, but that is how the code looks like it works to me. -- Graham Dumpleton (grahamd at dscpl.com.au)
|