Fix "fix this" in xmlutils
This commit is contained in:
parent
ecd0a16214
commit
453a8ba636
@ -33,6 +33,8 @@ from datetime import datetime, timedelta, timezone
|
|||||||
from http import client
|
from http import client
|
||||||
from urllib.parse import unquote, urlparse
|
from urllib.parse import unquote, urlparse
|
||||||
|
|
||||||
|
from . import storage
|
||||||
|
|
||||||
|
|
||||||
MIMETYPES = {
|
MIMETYPES = {
|
||||||
"VADDRESSBOOK": "text/vcard",
|
"VADDRESSBOOK": "text/vcard",
|
||||||
@ -534,8 +536,7 @@ def propfind(path, xml_request, read_collections, write_collections, user):
|
|||||||
|
|
||||||
def _propfind_response(path, item, props, user, write=False):
|
def _propfind_response(path, item, props, user, write=False):
|
||||||
"""Build and return a PROPFIND response."""
|
"""Build and return a PROPFIND response."""
|
||||||
# TODO: fix this
|
is_collection = isinstance(item, storage.BaseCollection)
|
||||||
is_collection = hasattr(item, "list")
|
|
||||||
if is_collection:
|
if is_collection:
|
||||||
is_leaf = bool(item.get_meta("tag"))
|
is_leaf = bool(item.get_meta("tag"))
|
||||||
collection = item
|
collection = item
|
||||||
@ -547,18 +548,11 @@ def _propfind_response(path, item, props, user, write=False):
|
|||||||
href = ET.Element(_tag("D", "href"))
|
href = ET.Element(_tag("D", "href"))
|
||||||
if is_collection:
|
if is_collection:
|
||||||
# Some clients expect collections to end with /
|
# Some clients expect collections to end with /
|
||||||
uri = item.path + "/"
|
uri = "/%s/" % item.path if item.path else "/"
|
||||||
else:
|
else:
|
||||||
# TODO: fix this
|
uri = "/" + posixpath.join(collection.path, item.href)
|
||||||
if path.split("/")[-1] == item.href:
|
|
||||||
# Happening when depth is 0
|
|
||||||
uri = path
|
|
||||||
else:
|
|
||||||
# Happening when depth is 1
|
|
||||||
uri = "/".join((path, item.href))
|
|
||||||
|
|
||||||
# TODO: fix this
|
href.text = _href(collection, uri)
|
||||||
href.text = _href(collection, uri.replace("//", "/"))
|
|
||||||
response.append(href)
|
response.append(href)
|
||||||
|
|
||||||
propstat404 = ET.Element(_tag("D", "propstat"))
|
propstat404 = ET.Element(_tag("D", "propstat"))
|
||||||
@ -831,13 +825,7 @@ def report(path, xml_request, collection):
|
|||||||
else:
|
else:
|
||||||
not_found_props.append(element)
|
not_found_props.append(element)
|
||||||
|
|
||||||
# TODO: fix this
|
uri = "/" + posixpath.join(collection.path, item.href)
|
||||||
if hreference.split("/")[-1] == item.href:
|
|
||||||
# Happening when depth is 0
|
|
||||||
uri = hreference
|
|
||||||
else:
|
|
||||||
# Happening when depth is 1
|
|
||||||
uri = posixpath.join(hreference, item.href)
|
|
||||||
multistatus.append(_item_response(
|
multistatus.append(_item_response(
|
||||||
uri, found_props=found_props,
|
uri, found_props=found_props,
|
||||||
not_found_props=not_found_props, found_item=True))
|
not_found_props=not_found_props, found_item=True))
|
||||||
|
Loading…
Reference in New Issue
Block a user