Code Repositories xandikos / fe39026
Add support for activelocks/supportedlocks. Jelmer Vernooń≥ 3 years ago
4 changed file(s) with 109 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
1313
1414 - run caldav tester
1515
16 - implement filters in calendar-query
16 - support returning components in calendar-data
17 - support returning components in addressbook-data
18
19 - use full hrefs (For thunderbird)
1720
1821 - properties:
1922 - group-membership
2023 - calendar-proxy-read-for
2124 - calendar-proxy-write-for
2225 - {http://inf-it.com/ns/dav/}settings
23 - {DAV:}supportedlock
2426 - {http://inf-it.com/ns/dav/}headervalue
2527
2628 - reporters:
102102 def get_etag(self):
103103 return create_strong_etag(self.etag)
104104
105 def get_supported_locks(self):
106 return []
107
108 def get_active_locks(self):
109 return []
110
105111 def get_owner(self):
106112 return None
107113
168174 def get_owner(self):
169175 return None
170176
177 def get_supported_locks(self):
178 return []
179
180 def get_active_locks(self):
181 return []
182
171183
172184 class Collection(StoreBasedCollection,caldav.Calendar):
173185 """A generic WebDAV collection."""
265277 def get_etag(self):
266278 raise KeyError
267279
280 def get_supported_locks(self):
281 return []
282
283 def get_active_locks(self):
284 return []
285
268286 def members(self):
269287 ret = []
270288 p = self.backend._map_to_file_path(self.relpath)
301319
302320 def get_content_type(self):
303321 return 'text/html'
322
323 def get_supported_locks(self):
324 return []
325
326 def get_active_locks(self):
327 return []
304328
305329 def get_etag(self):
306330 return '"root-page"'
408432 access.OwnerProperty(),
409433 webdav.DAVCreationDateProperty(),
410434 carddav.AddressbookColorProperty(),
435 webdav.DAVSupportedLockProperty(),
436 webdav.DAVLockDiscoveryProperty(),
411437 ])
412438 self.register_reporters([
413439 caldav.CalendarMultiGetReporter(),
320320 el.text = resource.get_ctag()
321321
322322
323 LOCK_SCOPE_EXCLUSIVE = '{DAV:}exclusive'
324 LOCK_SCOPE_SHARED = '{DAV:}shared'
325 LOCK_TYPE_WRITE = '{DAV:}write'
326
327
328 ActiveLock = collections.namedtuple(
329 'ActiveLock',
330 ['lockscope', 'locktype', 'depth', 'owner', 'timeout','locktoken',
331 'lockroot'])
332
333
323334 class DAVResource(object):
324335 """A WebDAV resource."""
325336
336347 :return: A datetime object
337348 """
338349 raise NotImplementedError(self.get_creationdate)
350
351 def get_supported_locks(self):
352 """Get the list of supported locks.
353
354 This should return a list of (lockscope, locktype) tuples.
355 Known lockscopes are LOCK_SCOPE_EXCLUSIVE, LOCK_SCOPE_SHARED
356 Known locktypes are LOCK_TYPE_WRITE
357 """
358 raise NotImplementedError(self.get_supported_locks)
359
360 def get_active_locks(self):
361 """Return the list of active locks.
362
363 :return: A list of ActiveLock tuples
364 """
365 raise NotImplementedError(self.get_active_locks)
339366
340367 def get_content_type(self):
341368 """Get the content type for the resource.
591618 resource, depth):
592619 return self._populate(request_body, resources_by_hrefs, properties,
593620 href, resource)
621
622
623 class DAVSupportedLockProperty(DAVProperty):
624 """supportedlock property.
625
626 See rfc4918, section 15.10.
627 """
628
629 name = '{DAV:}supportedlock'
630 resource_type = None
631 protected = True
632
633 def get_value(self, resource, el):
634 for (lockscope, locktype) in resource.get_supported_locks():
635 entry = ET.SubElement(el, '{DAV:}lockentry')
636 scope_el = ET.SubElement(entry, '{DAV:}lockscope')
637 ET.SubElement(scope_el, lockscope)
638 type_el = ET.SubElement(entry, '{DAV:}locktype')
639 ET.SubElement(type_el, locktype)
640
641
642 class DAVLockDiscoveryProperty(DAVProperty):
643 """lockdiscovery property.
644
645 See rfc4918, section 15.8
646 """
647
648 name = '{DAV:}lockdiscovery'
649 resource_type = None
650 protected = True
651
652 def get_value(self, resource, el):
653 for activelock in resource.get_active_locks():
654 entry = ET.SubElement(el, '{DAV:}activelock')
655 type_el = ET.SubElement(entry, '{DAV:}locktype')
656 ET.SubElement(type_el, activelock.locktype)
657 scope_el = ET.SubElement(entry, '{DAV:}lockscope')
658 ET.SubElement(scope_el, activelock.lockscope)
659 ET.SubElement(entry, '{DAV:}depth').text = str(activelock.depth)
660 if activelock.owner:
661 ET.SubElement(entry, '{DAV:}owner').text = activelock.owner
662 if activelock.timeout:
663 ET.SubElement(entry, '{DAV:}timeout').text = activelock.timeout
664 if activelock.locktoken:
665 locktoken_el = ET.SubElement(entry, '{DAV:}locktoken')
666 href = ET.SubElement(locktoken_el, '{DAV:}href')
667 href.text = activelock.locktoken
668 if activelock.lockroot:
669 locktoken_el = ET.SubElement(entry, '{DAV:}lockroot')
670 href = ET.SubElement(locktoken_el, '{DAV:}href')
671 href.text = activelock.lockroot
594672
595673
596674 class WellknownResource(DAVResource):
3232 - (15.7) getlastmodified [not supported]
3333 - (15.8) lockdiscovery [not supported]
3434 - (15.9) resourcetype [supported]
35 - (15.10) supportedlock [not supported]
35 - (15.10) supportedlock [supported]
3636 - (RFC2518 ONLY - 13.10) source [not supported]
3737
3838 # rfc3253.txt (Versioning Extensions)