On 30 March 2010 18:29, Deron Meranda <[email protected]> wrote:
> On Tue, Mar 30, 2010 at 2:07 AM, Graham Dumpleton
> <[email protected]> wrote:
>> Try:
>>  WSGIHandlerScript httpd/unix-directory /some/path/autoindex.wsgi
>
> I was already using WSGIHandlerScript, but not in that way.
>
> The "httpd/unix-directory" argument was new to me.  I have a
> reasonable idea, but in case there's some subtleties, what exactly
> does it do?

In mod_mime, when determining content types of files and assigning
handlers for them, it maps directories to 'httpd/unix-directory'.

The mod_autoindex module is triggered off that value for request handler type.

By mapping WSGIScriptHandler for 'httpd/unix-directory' to a WSGI
script, allows you to get in before mod_autoindex and generate the
directory listing.

> Anyway I think I've got this working fine now.
>
>
>> I am not sure of the ordering though. The mod_autoindex module hooks as:
>>
>>      ap_hook_handler(handle_autoindex,NULL,NULL,APR_HOOK_MIDDLE);
>>
>> which is the same as mod_wsgi. Which goes first may be dictated by
>> which LoadModule appear first or last. So, play with the order of the
>> LoadModule lines.
>
> Yes, the relative module loading order does matter; mod_wsgi has
> to be loaded first.
>
> Otherwise mod_autoindex will get the request first.  Even if you use
>  Options -Indexes
> mod_autoindex will still handle the request (and return an HTTP 403
> Forbidden), rather than just deferring the it so that mod_wsgi could
> then have a chance at it.
>
> These unfortunate load order issues would not as much a problem if
> either (or both) of mod_autoindex and mod_wsgi had a way to defer
> handling in certain contexts.

There are ways of specifying the ordering between Apache modules at C
code level where it really needs to be done.

If you look in wsgi_register_hooks() function of mod_wsgi.c you will
see lots of this sort of stuff being done. If no such order is
specified, then falls back based on LoadModule order.

The problem is that you can only really use this if you know it needs
to be done. Because mod_python and mod_wsgi are generic methods for
providing handlers, you cant know how a user may do it.

Anyway, untried, but you may be able to use mod_rewrite to also do
this without relying on that special content type.

  WSGIHandlerScript application/x-wsgi-auto-index /some/path/autoindex.wsgi

  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule . - [H=application/x-wsgi-auto-index]

Ie., if target of request is directory, set handler to be that
matching what was registered by WSGIHandlerScript.

Graham

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to