Commit 1a08344c authored by iv's avatar iv

WebDAV works on WebDAV root.

parent 7d175c02
...@@ -133,6 +133,7 @@ def before_request(): ...@@ -133,6 +133,7 @@ def before_request():
return response return response
g.status = status_code g.status = status_code
debug('headers: ' + str(headers))
g.headers = headers g.headers = headers
class WebDAV(MethodView): class WebDAV(MethodView):
...@@ -168,6 +169,7 @@ class WebDAV(MethodView): ...@@ -168,6 +169,7 @@ class WebDAV(MethodView):
""" """
status = g.status status = g.status
headers = g.headers headers = g.headers
debug('pathname: ' + pathname)
localpath = app.fs_handler.uri2local(URI_BEGINNING_PATH['webdav'] + pathname) localpath = app.fs_handler.uri2local(URI_BEGINNING_PATH['webdav'] + pathname)
data = '' data = ''
...@@ -235,8 +237,9 @@ class WebDAV(MethodView): ...@@ -235,8 +237,9 @@ class WebDAV(MethodView):
self.get_body()) self.get_body())
try: try:
response = make_response(pf.create_response() + '\n', status, headers) response = make_response(pf.create_response() + '\n', status, headers)
except IOError: except IOError, e:
response = make_response('', 404, headers) debug(e)
response = make_response('Not found', 404, headers)
return response return response
...@@ -358,9 +361,13 @@ class WebDAV(MethodView): ...@@ -358,9 +361,13 @@ class WebDAV(MethodView):
return make_response('', g.status, g.headers) return make_response('', g.status, g.headers)
webdav_view = WebDAV.as_view('dav')
app.add_url_rule('/webdav/', defaults={'pathname': ''},
view_func=webdav_view)
app.add_url_rule(URI_BEGINNING_PATH['webdav'] + '<path:pathname>', app.add_url_rule(URI_BEGINNING_PATH['webdav'] + '<path:pathname>',
view_func=WebDAV.as_view('dav')) view_func=webdav_view)
@app.route(URI_BEGINNING_PATH['authorization'], methods=['GET', 'POST']) @app.route(URI_BEGINNING_PATH['authorization'], methods=['GET', 'POST'])
......
...@@ -77,7 +77,7 @@ class FilesystemHandler(): ...@@ -77,7 +77,7 @@ class FilesystemHandler():
def uri2local(self,uri): def uri2local(self,uri):
""" map uri in baseuri and local part """ """ map uri in baseuri and local part """
path = os.path.normpath(uri) path = os.path.normpath(uri) + '/'
if path.startswith(self.baseuri): if path.startswith(self.baseuri):
path = path[len(self.baseuri):] path = path[len(self.baseuri):]
filepath = os.path.join(self.directory, path) filepath = os.path.join(self.directory, path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment