From 6545bc82737a51869d72f8f988a8ae8ab7df6cba Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Wed, 9 Dec 2009 12:56:03 +0100 Subject: [PATCH] Add getetag and getcontenttype support for propfind requests (Sunbird 1.0 ready). --- radicale/calendar.py | 4 ++++ radicale/xmlutils.py | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/radicale/calendar.py b/radicale/calendar.py index 0b1c0f9..220af1f 100644 --- a/radicale/calendar.py +++ b/radicale/calendar.py @@ -60,6 +60,10 @@ class Calendar(object): """Return unicode calendar from the calendar.""" return unicode(support.read(self.cal), self.encoding) + def etag(self): + """Return etag from calendar.""" + return hash_tag(self.vcalendar()) + class Event(object): """Internal event class.""" def __init__(self, vcalendar): diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index a21055a..8e265ff 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -105,6 +105,16 @@ def propfind(xml_request, calendar, url): owner.text = calendar.owner prop.append(owner) + if _tag("D", "getcontenttype") in properties: + getcontenttype = ET.Element(_tag("D", "getcontenttype")) + getcontenttype.text = "text/calendar" + prop.append(getcontenttype) + + if _tag("D", "getetag") in properties: + getetag = ET.Element(_tag("D", "getetag")) + getetag.text = calendar.etag() + prop.append(getetag) + if _tag("CS", "getctag") in properties: getctag = ET.Element(_tag("CS", "getctag")) getctag.text = calendar.ctag