[mod_python] Directory or Location?

emf i at mindlace.net
Thu Jun 12 08:55:22 EST 2003


--On 12 Thursday, June 2003 01:50 -0400 "Timothy M. Brauch" 
<tbrauch at mindless.com> wrote:


> What is the difference between using "Location" and "Directory"?
> When do I use each one?

I battled with this for hours the other day, so maybe I can help.

This is the important document: 
<http://httpd.apache.org/docs/sections.html>

The key thing to take away is: Location gets applied after Directory.

What I wanted was to handle everything with my PythonHandler but 
exclude certain directories.*

So at first I tried a Directory directive with SetHandler 
python-program and other directory directives with SetHandler None; the 
latter only worked for the exact directory name, and only if I 
specified the absolute path (more general regular expressions, like 
"^/donthandlethis*", didn't work).

Finally I used <Location /donthandlethis> SetHandler None </Location> 
for those directories I didn't want handled by my handler, and now 
everything works fine.

* I battled for a while with TransHandler, but it seems to me that if 
you write a TransHandler it must do everything that the regular 
TransHandler does as well as whatever you want; there's no way to make 
a TransHandler that only translates some requests, and punts the rest 
to apache's normal handling. (someone please correct me if I'm wrong.)

Additionally, I never got 
req.add_handler("PythonHandler",myhandlername) to do what I expected - 
i.e. act like SetHandler for that request (but if it doesn't work that 
way, how come you can't specify extension in .add_handler() ?

HTH,

~mindlace
http://mindlace.net


More information about the Mod_python mailing list