Softly ignore /user/ PROPFIND and REPORT requests (references #181)

This commit is contained in:
Guillaume Ayoub 2011-02-12 12:05:02 +01:00
parent 9b535ba4b2
commit 2e1b51e3c1
2 changed files with 21 additions and 10 deletions

View File

@ -55,6 +55,11 @@ def _check(request, function):
"""Check if user has sufficient rights for performing ``request``.""" """Check if user has sufficient rights for performing ``request``."""
# ``_check`` decorator can access ``request`` protected functions # ``_check`` decorator can access ``request`` protected functions
# pylint: disable=W0212 # pylint: disable=W0212
# If we have no calendar, don't check rights
if not request._calendar:
return function(request)
authorization = request.headers.get("Authorization", None) authorization = request.headers.get("Authorization", None)
if authorization: if authorization:
challenge = authorization.lstrip("Basic").strip().encode("ascii") challenge = authorization.lstrip("Basic").strip().encode("ascii")

View File

@ -95,12 +95,15 @@ def propfind(path, xml_request, calendar, depth):
# Writing answer # Writing answer
multistatus = ET.Element(_tag("D", "multistatus")) multistatus = ET.Element(_tag("D", "multistatus"))
if calendar:
if depth == "0": if depth == "0":
items = [calendar] items = [calendar]
else: else:
# depth is 1, infinity or not specified # depth is 1, infinity or not specified
# we limit ourselves to depth == 1 # we limit ourselves to depth == 1
items = [calendar] + calendar.events + calendar.todos items = [calendar] + calendar.events + calendar.todos
else:
items = []
for item in items: for item in items:
is_calendar = isinstance(item, ical.Calendar) is_calendar = isinstance(item, ical.Calendar)
@ -191,12 +194,15 @@ def report(path, xml_request, calendar):
prop_list = prop_element.getchildren() prop_list = prop_element.getchildren()
props = [prop.tag for prop in prop_list] props = [prop.tag for prop in prop_list]
if calendar:
if root.tag == _tag("C", "calendar-multiget"): if root.tag == _tag("C", "calendar-multiget"):
# Read rfc4791-7.9 for info # Read rfc4791-7.9 for info
hreferences = set((href_element.text for href_element hreferences = set((href_element.text for href_element
in root.findall(_tag("D", "href")))) in root.findall(_tag("D", "href"))))
else: else:
hreferences = (path,) hreferences = (path,)
else:
hreferences = ()
# Writing answer # Writing answer
multistatus = ET.Element(_tag("D", "multistatus")) multistatus = ET.Element(_tag("D", "multistatus"))