|
@@ -156,6 +156,7 @@ def xml_report(base_prefix: str, path: str, xml_request: Optional[ET.Element],
|
|
|
Read rfc3253-3.6 for info.
|
|
Read rfc3253-3.6 for info.
|
|
|
|
|
|
|
|
"""
|
|
"""
|
|
|
|
|
+ logger.debug("TRACE/REPORT/xml_report: base_prefix=%r path=%r", base_prefix, path)
|
|
|
multistatus = ET.Element(xmlutils.make_clark("D:multistatus"))
|
|
multistatus = ET.Element(xmlutils.make_clark("D:multistatus"))
|
|
|
if xml_request is None:
|
|
if xml_request is None:
|
|
|
return client.MULTI_STATUS, multistatus
|
|
return client.MULTI_STATUS, multistatus
|
|
@@ -239,6 +240,7 @@ def xml_report(base_prefix: str, path: str, xml_request: Optional[ET.Element],
|
|
|
filter_copy = copy.deepcopy(filter_)
|
|
filter_copy = copy.deepcopy(filter_)
|
|
|
|
|
|
|
|
if expand is not None:
|
|
if expand is not None:
|
|
|
|
|
+ logger.debug("TRACE/REPORT/xml_report: expand")
|
|
|
for comp_filter in filter_copy.findall(".//" + xmlutils.make_clark("C:comp-filter")):
|
|
for comp_filter in filter_copy.findall(".//" + xmlutils.make_clark("C:comp-filter")):
|
|
|
if comp_filter.get("name", "").upper() == "VCALENDAR":
|
|
if comp_filter.get("name", "").upper() == "VCALENDAR":
|
|
|
continue
|
|
continue
|
|
@@ -275,21 +277,15 @@ def xml_report(base_prefix: str, path: str, xml_request: Optional[ET.Element],
|
|
|
|
|
|
|
|
found_props = []
|
|
found_props = []
|
|
|
not_found_props = []
|
|
not_found_props = []
|
|
|
- item_etag: str = ""
|
|
|
|
|
|
|
|
|
|
for prop in props:
|
|
for prop in props:
|
|
|
element = ET.Element(prop.tag)
|
|
element = ET.Element(prop.tag)
|
|
|
- if prop.tag == xmlutils.make_clark("D:getetag"):
|
|
|
|
|
- if expand is not None:
|
|
|
|
|
- item_etag = item.etag
|
|
|
|
|
- else:
|
|
|
|
|
- element.text = item.etag
|
|
|
|
|
- found_props.append(element)
|
|
|
|
|
- elif prop.tag == xmlutils.make_clark("D:getcontenttype"):
|
|
|
|
|
|
|
+ if prop.tag == xmlutils.make_clark("D:getcontenttype"):
|
|
|
element.text = xmlutils.get_content_type(item, encoding)
|
|
element.text = xmlutils.get_content_type(item, encoding)
|
|
|
found_props.append(element)
|
|
found_props.append(element)
|
|
|
elif prop.tag in (
|
|
elif prop.tag in (
|
|
|
xmlutils.make_clark("C:calendar-data"),
|
|
xmlutils.make_clark("C:calendar-data"),
|
|
|
|
|
+ xmlutils.make_clark("D:getetag"),
|
|
|
xmlutils.make_clark("CR:address-data")):
|
|
xmlutils.make_clark("CR:address-data")):
|
|
|
element.text = item.serialize()
|
|
element.text = item.serialize()
|
|
|
|
|
|
|
@@ -326,11 +322,24 @@ def xml_report(base_prefix: str, path: str, xml_request: Optional[ET.Element],
|
|
|
continue
|
|
continue
|
|
|
|
|
|
|
|
n_vevents += n_vev
|
|
n_vevents += n_vev
|
|
|
- found_props.append(expanded_element)
|
|
|
|
|
|
|
+ if prop.tag == xmlutils.make_clark("D:getetag"):
|
|
|
|
|
+ if n_vev > 0:
|
|
|
|
|
+ logger.debug("TRACE/REPORT/xml_report: getetag/expanded element")
|
|
|
|
|
+ element.text = item.etag
|
|
|
|
|
+ found_props.append(element)
|
|
|
|
|
+ else:
|
|
|
|
|
+ logger.debug("TRACE/REPORT/xml_report: getetag/no expanded element")
|
|
|
|
|
+ else:
|
|
|
|
|
+ logger.debug("TRACE/REPORT/xml_report: default")
|
|
|
|
|
+ found_props.append(expanded_element)
|
|
|
else:
|
|
else:
|
|
|
- found_props.append(element)
|
|
|
|
|
- if hasattr(item.vobject_item, "vevent_list"):
|
|
|
|
|
- n_vevents += len(item.vobject_item.vevent_list)
|
|
|
|
|
|
|
+ if prop.tag == xmlutils.make_clark("D:getetag"):
|
|
|
|
|
+ element.text = item.etag
|
|
|
|
|
+ found_props.append(element)
|
|
|
|
|
+ else:
|
|
|
|
|
+ found_props.append(element)
|
|
|
|
|
+ if hasattr(item.vobject_item, "vevent_list"):
|
|
|
|
|
+ n_vevents += len(item.vobject_item.vevent_list)
|
|
|
# Avoid DoS with too many events
|
|
# Avoid DoS with too many events
|
|
|
if max_occurrence and n_vevents > max_occurrence:
|
|
if max_occurrence and n_vevents > max_occurrence:
|
|
|
raise ValueError("REPORT occurrences limit of {} hit"
|
|
raise ValueError("REPORT occurrences limit of {} hit"
|
|
@@ -345,7 +354,7 @@ def xml_report(base_prefix: str, path: str, xml_request: Optional[ET.Element],
|
|
|
if found_props or not_found_props:
|
|
if found_props or not_found_props:
|
|
|
multistatus.append(xml_item_response(
|
|
multistatus.append(xml_item_response(
|
|
|
base_prefix, uri, found_props=found_props,
|
|
base_prefix, uri, found_props=found_props,
|
|
|
- not_found_props=not_found_props, found_item=True, item_etag=item_etag))
|
|
|
|
|
|
|
+ not_found_props=not_found_props, found_item=True))
|
|
|
|
|
|
|
|
return client.MULTI_STATUS, multistatus
|
|
return client.MULTI_STATUS, multistatus
|
|
|
|
|
|
|
@@ -664,7 +673,7 @@ def _find_overridden(
|
|
|
def xml_item_response(base_prefix: str, href: str,
|
|
def xml_item_response(base_prefix: str, href: str,
|
|
|
found_props: Sequence[ET.Element] = (),
|
|
found_props: Sequence[ET.Element] = (),
|
|
|
not_found_props: Sequence[ET.Element] = (),
|
|
not_found_props: Sequence[ET.Element] = (),
|
|
|
- found_item: bool = True, item_etag: str = "") -> ET.Element:
|
|
|
|
|
|
|
+ found_item: bool = True) -> ET.Element:
|
|
|
response = ET.Element(xmlutils.make_clark("D:response"))
|
|
response = ET.Element(xmlutils.make_clark("D:response"))
|
|
|
|
|
|
|
|
href_element = ET.Element(xmlutils.make_clark("D:href"))
|
|
href_element = ET.Element(xmlutils.make_clark("D:href"))
|
|
@@ -678,10 +687,6 @@ def xml_item_response(base_prefix: str, href: str,
|
|
|
status = ET.Element(xmlutils.make_clark("D:status"))
|
|
status = ET.Element(xmlutils.make_clark("D:status"))
|
|
|
status.text = xmlutils.make_response(code)
|
|
status.text = xmlutils.make_response(code)
|
|
|
prop_element = ET.Element(xmlutils.make_clark("D:prop"))
|
|
prop_element = ET.Element(xmlutils.make_clark("D:prop"))
|
|
|
- if (item_etag != "") and (code == 200):
|
|
|
|
|
- prop_etag = ET.Element(xmlutils.make_clark("D:getetag"))
|
|
|
|
|
- prop_etag.text = item_etag
|
|
|
|
|
- prop_element.append(prop_etag)
|
|
|
|
|
for prop in props:
|
|
for prop in props:
|
|
|
prop_element.append(prop)
|
|
prop_element.append(prop)
|
|
|
propstat.append(prop_element)
|
|
propstat.append(prop_element)
|
|
@@ -735,6 +740,7 @@ def retrieve_items(
|
|
|
else:
|
|
else:
|
|
|
yield item, False
|
|
yield item, False
|
|
|
if collection_requested:
|
|
if collection_requested:
|
|
|
|
|
+ logger.debug("TRACE/REPORT/retrieve_items: get_filtered")
|
|
|
yield from collection.get_filtered(filters)
|
|
yield from collection.get_filtered(filters)
|
|
|
|
|
|
|
|
|
|
|