Kaynağa Gözat

Add getetag and getcontenttype support for propfind requests (Sunbird 1.0 ready).

Guillaume Ayoub 16 yıl önce
ebeveyn
işleme
6545bc8273
2 değiştirilmiş dosya ile 14 ekleme ve 0 silme
  1. 4 0
      radicale/calendar.py
  2. 10 0
      radicale/xmlutils.py

+ 4 - 0
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):

+ 10 - 0
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