The owner field should be an URL. Fixes delays in iCal.

This commit is contained in:
Lukasz Langa 2011-06-01 15:30:47 +02:00
parent 8bcdb5b1dc
commit 5b9180c295
2 changed files with 17 additions and 7 deletions

View File

@ -389,6 +389,13 @@ class Calendar(object):
with open(props_path, 'w') as prop_file: with open(props_path, 'w') as prop_file:
json.dump(properties, prop_file) json.dump(properties, prop_file)
@property
def owner_url(self):
if self.owner:
return '/{}/'.format(self.owner).replace('//', '/')
else:
return None
@property @property
def url(self): def url(self):
return '/{}/'.format(self.local_path).replace('//', '/') return '/{}/'.format(self.local_path).replace('//', '/')

View File

@ -214,18 +214,15 @@ def _propfind_response(path, item, props):
for tag in props: for tag in props:
element = ET.Element(tag) element = ET.Element(tag)
is404 = False is404 = False
if tag == _tag("D", "owner"): if tag == _tag("D", "getcontenttype"):
if item.owner:
element.text = item.owner
elif tag == _tag("D", "getcontenttype"):
element.text = "text/calendar" element.text = "text/calendar"
elif tag == _tag("D", "getetag"): elif tag == _tag("D", "getetag"):
element.text = item.etag element.text = item.etag
elif tag == _tag("D", "principal-URL"): elif tag == _tag("D", "principal-URL"):
# TODO: use a real principal URL, read rfc3744-4.2 for info # TODO: use a real principal URL, read rfc3744-4.2 for info
tag = ET.Element(_tag("D", "href")) tag = ET.Element(_tag("D", "href"))
if item.owner: if item.owner_url:
tag.text = "/{}/".format(item.owner).replace("//", "/") tag.text = item.owner_url
else: else:
tag.text = path tag.text = path
element.append(tag) element.append(tag)
@ -259,11 +256,13 @@ def _propfind_response(path, item, props):
element.append(supported) element.append(supported)
elif is_calendar: elif is_calendar:
if tag == _tag("D", "resourcetype"): if tag == _tag("D", "resourcetype"):
if is_calendar and not item.is_principal: if not item.is_principal:
tag = ET.Element(_tag("C", "calendar")) tag = ET.Element(_tag("C", "calendar"))
element.append(tag) element.append(tag)
tag = ET.Element(_tag("D", "collection")) tag = ET.Element(_tag("D", "collection"))
element.append(tag) element.append(tag)
elif tag == _tag("D", "owner") and item.owner_url:
element.text = item.owner_url
elif tag == _tag("CS", "getctag"): elif tag == _tag("CS", "getctag"):
element.text = item.etag element.text = item.etag
else: else:
@ -272,6 +271,10 @@ def _propfind_response(path, item, props):
element.text = calendar_props[human_tag] element.text = calendar_props[human_tag]
else: else:
is404 = True is404 = True
# not for calendars
elif tag == _tag("D", "resourcetype"):
tag = ET.Element(_tag("D", "collection"))
element.append(tag)
else: else:
is404 = True is404 = True