> On 29 Sep 2015, at 11:21 am, Graham Dumpleton <[email protected]> 
> wrote:
> 
> 
>> On 29 Sep 2015, at 11:17 am, Graham Dumpleton <[email protected]> 
>> wrote:
>> 
>> 
>>> On 29 Sep 2015, at 10:38 am, Josh Rodriguez <[email protected]> wrote:
>>> 
>>> I'm trying to use Flask (via mod_wsgi) and mod_dav in the same location. I 
>>> want mod_wsgi/Python to handle GET and POST requests (because I want to 
>>> return enhanced HTML directory listings) while mod_dav handles methods like 
>>> OPTIONS and PROPFIND.
>>> 
>>> I'm getting an 400 error with the log message "The URL contains extraneous 
>>> path components. The resource could not be identified." when I try to 
>>> access a resource via WebDAV.
>>> 
>>> I think I've figured out what's up.
>>> 
>>> I'm using WSGIScriptAlias as follows:
>>> 
>>> `WSGIScriptAlias / /usr/local/apache2/htdocs/test/test.wsgi`
>>> 
>>> But when I use a WebDAV client to connect to `/files/`, I find that the 
>>> path that's passed to mod_dav has turned into:
>>> 
>>> `/usr/local/apache2/htdocs/test/test.wsgi/files`
>>> 
>>> Which makes sense, given the alias directive.
>>> 
>>> My question is, is there a way to keep this from happening for WebDAV 
>>> requests? I'm assuming I can't do anything in Flask, that I need to catch 
>>> and modify the request before it reaches mod_dav. 
>> 
>> As a first guess, try adding:
>> 
>>   <Location /files>
>>   SetHandler default-handler
>>   </Location>
>> 
>> I am not sure whether this will interact with WebDav properly or not, but I 
>> think would normally stop mod_wsgi at least interfering with requests under 
>> that URL. It may be necessary to work out what the handler name for WebDav 
>> is and use it, although from memory I suspect it doesn’t use the handler 
>> concept.
> 
> Okay. Didn’t grok what you want properly.
> 
> That will only disable it for selected sub URLs, not by method type.
> 
> I will have to think some more. Unfortunately the Limit/LimitExcept 
> directives don’t I believe work for handlers, only auth control.

Lets try again.

Presuming you want the whole site to be WebDav, but with GET/POST only redirect 
to a Python script for outputting something different, try the following:

1. Use WSGIScriptAlias to mount your Flask application to generate the special 
listing under a special unique sub URL which isn’t going to match anything 
valid that WebDav may generate.

    WSGIScriptAlias /.my-special-directory-listing 
/usr/local/apache2/htdocs/test/test.wsgi

2. Enable mod_actions in Apache configuration.

3. Add a Script directive mapping GET/POST to that special Python script.

    Script GET /.my-special-directory-listing
    Script POST /.my-special-directory-listing

It is possible that the original information about the URL used may not be in 
the normal WSGI environ variables where Flask expects them. You may need to use 
a WSGI middleware around Flask to tweak the WSGI environ variables, copying 
values from different values that Apache passes through. Look through what you 
might get for the following to see where the original details may lie.

CONTEXT_DOCUMENT_ROOT: '/Library/WebServer/Documents'
CONTEXT_PREFIX: ''
DOCUMENT_ROOT: '/Library/WebServer/Documents'
PATH_INFO: '/index.html.en'
PATH_TRANSLATED: '/Library/WebServer/Documents/index.html.en'
QUERY_STRING: ''
REDIRECT_STATUS: '200'
REDIRECT_URL: '/index.html.en'
REQUEST_METHOD: 'POST'
REQUEST_URI: '/'
SCRIPT_FILENAME: '/Library/WebServer/Documents/environ.wsgi'
SCRIPT_NAME: '/.special-listing’

This may be necessary due to how Apache does internal redirects to invoke the 
script for that method type.

Please let me know the results as I will be curious.

Graham

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to