[mod_python] Apache directory listing

Graham Dumpleton graham.dumpleton at gmail.com
Tue May 29 19:23:51 EDT 2007

On 30/05/07, Aaron Gallagher <habnabit at gmail.com> wrote:
> Also, I seem to actually be having bizarre problems with my
> redirects. When I request /a/b/c/d/, my handler catches the bad URL
> and executes this code:
> req.internal_redirect('/?__404')
> return apache.DONE
> What happens is I get a page that has a text/plain mime type with a
> 200 response code that looks essentially like this (stripping out a
> lot of HTML):
> Page not found: /d/
> Page not found: /c/d/
> Page not found: /b/c/d/
> Page not found: /a/b/c/d/
> I found that after the redirect, the handler (which is a
> fixuphandler) doesn't recur, but return apache.DONE, and then another
> handler is called. My only thought could be that this is intrinsic to
> the fixuphandler, but that seems silly. Skipping the redirect and
> just returning 404 seems to work, and it doesn't return four not
> found pages.
> What do I need to do to fix this?

This is probably the problem with autoindex I briefly mentioned. To do
an index it actually does a sub request as far as the fixup handler
phase for every item which it might list in the index to determine if
it has access rights and should be listing it. If you have handlers
for these phases it will trigger them for the subrequest as well which
might cause issues. One can detect if such a handler is called in
subrequest by looking whether req.prev or req.main (cant remember
which), is not None.

When I get a chance to at least get directory index to week as you
indicate what you want, then we can start stepping through these
others issues.


More information about the Mod_python mailing list