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):
|
if not len(read_collections):
|
||||||
return NOT_ALLOWED
|
return NOT_ALLOWED
|
||||||
|
|
||||||
collection = read_collections[0]
|
|
||||||
|
|
||||||
headers = {"Content-Type": "text/xml"}
|
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
|
return client.MULTI_STATUS, headers, answer
|
||||||
|
|
||||||
# pylint: enable=W0612,W0613,R0201
|
# pylint: enable=W0612,W0613,R0201
|
||||||
|
@ -479,7 +479,7 @@ def put(path, ical_request, collection):
|
|||||||
collection.append(name, ical_request)
|
collection.append(name, ical_request)
|
||||||
|
|
||||||
|
|
||||||
def report(path, xml_request, collection):
|
def report(path, xml_request, items):
|
||||||
"""Read and answer REPORT requests.
|
"""Read and answer REPORT requests.
|
||||||
|
|
||||||
Read rfc3253-3.6 for info.
|
Read rfc3253-3.6 for info.
|
||||||
@ -491,7 +491,7 @@ def report(path, xml_request, collection):
|
|||||||
prop_element = root.find(_tag("D", "prop"))
|
prop_element = root.find(_tag("D", "prop"))
|
||||||
props = [prop.tag for prop in prop_element]
|
props = [prop.tag for prop in prop_element]
|
||||||
|
|
||||||
if collection:
|
if items:
|
||||||
if root.tag in (_tag("C", "calendar-multiget"),
|
if root.tag in (_tag("C", "calendar-multiget"),
|
||||||
_tag("CR", "addressbook-multiget")):
|
_tag("CR", "addressbook-multiget")):
|
||||||
# Read rfc4791-7.9 for info
|
# Read rfc4791-7.9 for info
|
||||||
@ -515,23 +515,13 @@ def report(path, xml_request, collection):
|
|||||||
# Writing answer
|
# Writing answer
|
||||||
multistatus = ET.Element(_tag("D", "multistatus"))
|
multistatus = ET.Element(_tag("D", "multistatus"))
|
||||||
|
|
||||||
collection_tag = collection.tag
|
if items:
|
||||||
collection_items = collection.items
|
collection = items[0]
|
||||||
collection_headers = collection.headers
|
collection_tag = collection.tag
|
||||||
collection_timezones = collection.timezones
|
collection_headers = collection.headers
|
||||||
|
collection_timezones = collection.timezones
|
||||||
|
|
||||||
for hreference in hreferences:
|
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:
|
for item in items:
|
||||||
if tag_filters and item.tag not in tag_filters:
|
if tag_filters and item.tag not in tag_filters:
|
||||||
continue
|
continue
|
||||||
@ -540,7 +530,11 @@ def report(path, xml_request, collection):
|
|||||||
multistatus.append(response)
|
multistatus.append(response)
|
||||||
|
|
||||||
href = ET.Element(_tag("D", "href"))
|
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)
|
response.append(href)
|
||||||
|
|
||||||
propstat = ET.Element(_tag("D", "propstat"))
|
propstat = ET.Element(_tag("D", "propstat"))
|
||||||
@ -554,8 +548,11 @@ def report(path, xml_request, collection):
|
|||||||
if tag == _tag("D", "getetag"):
|
if tag == _tag("D", "getetag"):
|
||||||
element.text = item.etag
|
element.text = item.etag
|
||||||
elif tag == _tag("D", "getcontenttype"):
|
elif tag == _tag("D", "getcontenttype"):
|
||||||
element.text = "%s; component=%s" % (
|
if isinstance(item, ical.Component):
|
||||||
item.mimetype, item.tag.lower())
|
element.text = "%s; component=%s" % (
|
||||||
|
item.mimetype, item.tag.lower())
|
||||||
|
else:
|
||||||
|
element.text = item.mimetype
|
||||||
elif tag in (_tag("C", "calendar-data"),
|
elif tag in (_tag("C", "calendar-data"),
|
||||||
_tag("CR", "address-data")):
|
_tag("CR", "address-data")):
|
||||||
if isinstance(item, ical.Component):
|
if isinstance(item, ical.Component):
|
||||||
|
Loading…
Reference in New Issue
Block a user