Re: [Myghty-users] DirectoryIndex and Myghty
Brought to you by:
zzzeek
From: Deron M. <der...@gm...> - 2006-06-02 19:46:27
|
On 6/2/06, Cole Tuininga <col...@gm...> wrote: > I'm running myghty 1.0.1 on top of python2.4.x from apache 2.0.x I'm assuming mod_python is in there someplace (?) > Here's the thing - Myghty (or is it mod_python?) doesn't seem to be > honoring my DirectoryIndex directive. I have a site with several > directories that I would like to default to using index.html if the > file is not specified, and there is no dhandler. > > Is there a way to convince Myghty to do such a thing? Thanks in advance. This is really a mod_python thing more than a Myghty issue; or more precisely, an Apache issue more than either. DirectoryIndex is a directive which gives the mod_dir Apache module instructions on what files to red (e.g., index.html) when it gets called to output content. It is otherwise completely ignored by the Apache core engine, mod_python, and Myghty. But the problem you have really comes down to which handler Apache is choosing to serve the URL. If you're using SetHandler without any restrictions (such as inside a <Files> section) then mod_python will always get the request, rather than the built-in default-handler (which is what then invokes mod_dir or mod_autoindex). I'm not sure of the best way to do what you want. But perhaps you can do Apache internal redirects, by using the mod_python r.internal_redirect() method. Then exclude all files named "index.html" from being handled by mod_python. <Files index.html> SetHandler None </Files> And in your dhandler: <%python> if .....: # call normal myghty components, etc. else: # no myghty components match, fall back to index.html dir = os.path.dirname( m.request_path ) r.internal_redirect('%s/index.html' % dir) </%python> You may also be able to play with returning apache.DECLINED from the mod_python request object, but I suspect there are too many tricks there to get it to work, especially since you're inside Myghty which is sitting on top of mod_python. Note...the above code is totally untested. -- Deron Meranda |