Follow the depth in REPORT requests
This commit is contained in:
parent
066dffd614
commit
9556508b2a
@ -568,11 +568,10 @@ class Application(object):
|
||||
if not len(read_collections):
|
||||
return NOT_ALLOWED
|
||||
|
||||
collection = read_collections[0]
|
||||
|
||||
headers = {"Content-Type": "text/xml"}
|
||||
|
||||
answer = xmlutils.report(environ["PATH_INFO"], content, collection)
|
||||
answer = xmlutils.report(
|
||||
environ["PATH_INFO"], content, read_collections)
|
||||
return client.MULTI_STATUS, headers, answer
|
||||
|
||||
# pylint: enable=W0612,W0613,R0201
|
||||
|
@ -479,7 +479,7 @@ def put(path, ical_request, collection):
|
||||
collection.append(name, ical_request)
|
||||
|
||||
|
||||
def report(path, xml_request, collection):
|
||||
def report(path, xml_request, items):
|
||||
"""Read and answer REPORT requests.
|
||||
|
||||
Read rfc3253-3.6 for info.
|
||||
@ -491,7 +491,7 @@ def report(path, xml_request, collection):
|
||||
prop_element = root.find(_tag("D", "prop"))
|
||||
props = [prop.tag for prop in prop_element]
|
||||
|
||||
if collection:
|
||||
if items:
|
||||
if root.tag in (_tag("C", "calendar-multiget"),
|
||||
_tag("CR", "addressbook-multiget")):
|
||||
# Read rfc4791-7.9 for info
|
||||
@ -515,23 +515,13 @@ def report(path, xml_request, collection):
|
||||
# Writing answer
|
||||
multistatus = ET.Element(_tag("D", "multistatus"))
|
||||
|
||||
collection_tag = collection.tag
|
||||
collection_items = collection.items
|
||||
collection_headers = collection.headers
|
||||
collection_timezones = collection.timezones
|
||||
if items:
|
||||
collection = items[0]
|
||||
collection_tag = collection.tag
|
||||
collection_headers = collection.headers
|
||||
collection_timezones = collection.timezones
|
||||
|
||||
for hreference in hreferences:
|
||||
# Check if the reference is an item or a collection
|
||||
name = name_from_path(hreference, collection)
|
||||
if name:
|
||||
# Reference is an item
|
||||
path = "/".join(hreference.split("/")[:-1]) + "/"
|
||||
items = (item for item in collection_items if item.name == name)
|
||||
else:
|
||||
# Reference is a collection
|
||||
path = hreference
|
||||
items = collection.components
|
||||
|
||||
for item in items:
|
||||
if tag_filters and item.tag not in tag_filters:
|
||||
continue
|
||||
@ -540,7 +530,11 @@ def report(path, xml_request, collection):
|
||||
multistatus.append(response)
|
||||
|
||||
href = ET.Element(_tag("D", "href"))
|
||||
href.text = _href("%s/%s" % (path.rstrip("/"), item.name))
|
||||
if isinstance(item, ical.Component):
|
||||
href.text = _href("%s/%s" % (
|
||||
collection.path.rstrip("/"), item.name))
|
||||
else:
|
||||
href.text = _href(item.path)
|
||||
response.append(href)
|
||||
|
||||
propstat = ET.Element(_tag("D", "propstat"))
|
||||
@ -554,8 +548,11 @@ def report(path, xml_request, collection):
|
||||
if tag == _tag("D", "getetag"):
|
||||
element.text = item.etag
|
||||
elif tag == _tag("D", "getcontenttype"):
|
||||
element.text = "%s; component=%s" % (
|
||||
item.mimetype, item.tag.lower())
|
||||
if isinstance(item, ical.Component):
|
||||
element.text = "%s; component=%s" % (
|
||||
item.mimetype, item.tag.lower())
|
||||
else:
|
||||
element.text = item.mimetype
|
||||
elif tag in (_tag("C", "calendar-data"),
|
||||
_tag("CR", "address-data")):
|
||||
if isinstance(item, ical.Component):
|
||||
|
Loading…
Reference in New Issue
Block a user