<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[13896] CalendarServer/trunk/twistedcaldav</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/13896">13896</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-08-19 14:25:04 -0700 (Tue, 19 Aug 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Clean up some WebDAV property apis.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktwistedcaldavresourcepy">CalendarServer/trunk/twistedcaldav/resource.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavstorebridgepy">CalendarServer/trunk/twistedcaldav/storebridge.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunktwistedcaldavresourcepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/resource.py (13895 => 13896)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/resource.py        2014-08-19 17:49:19 UTC (rev 13895)
+++ CalendarServer/trunk/twistedcaldav/resource.py        2014-08-19 21:25:04 UTC (rev 13896)
</span><span class="lines">@@ -431,6 +431,8 @@
</span><span class="cx"> # caldavxml.DefaultAlarmVToDoDate.qname(),
</span><span class="cx">
</span><span class="cx"> customxml.PubSubXMPPPushKeyProperty.qname(),
</span><ins>+
+ caldavxml.ScheduleCalendarTransp.qname(),
</ins><span class="cx"> )
</span><span class="cx">
</span><span class="cx"> if self.isAddressBookCollection() and not self.isDirectoryBackedAddressBookCollection():
</span><span class="lines">@@ -490,95 +492,27 @@
</span><span class="cx"> return super(CalDAVResource, self).liveProperties() + baseProperties
</span><span class="cx">
</span><span class="cx">
</span><del>- def isShadowableProperty(self, qname):
- """
- Shadowable properties are ones on shared resources where a "default" exists until
- a user overrides with their own value.
- """
- return qname in (
- caldavxml.CalendarDescription.qname(),
- caldavxml.CalendarTimeZone.qname(),
- carddavxml.AddressBookDescription.qname(),
- )
-
-
- def isGlobalProperty(self, qname):
- """
- A global property is one that is the same for all users.
- """
- if qname in self.liveProperties():
- if qname in (
- element.DisplayName.qname(),
- ):
- return False
- else:
- return True
- else:
- return False
-
-
</del><span class="cx"> @inlineCallbacks
</span><del>- def hasProperty(self, property, request):
- """
- Need to special case schedule-calendar-transp for backwards compatability.
- """
- res = (yield self._hasGlobalProperty(property, request))
- returnValue(res)
-
-
- def _hasGlobalProperty(self, property, request):
- """
- Need to special case schedule-calendar-transp for backwards compatability.
- """
-
- if type(property) is tuple:
- qname = property
- else:
- qname = property.qname()
-
- # Force calendar collections to always appear to have the property
- if qname == caldavxml.ScheduleCalendarTransp.qname() and self.isCalendarCollection():
- return succeed(True)
-
- else:
- return super(CalDAVResource, self).hasProperty(property, request)
-
-
- @inlineCallbacks
</del><span class="cx"> def readProperty(self, property, request):
</span><span class="cx"> if type(property) is tuple:
</span><span class="cx"> qname = property
</span><span class="cx"> else:
</span><span class="cx"> qname = property.qname()
</span><span class="cx">
</span><del>- if self.isCalendarCollection() or (self.isAddressBookCollection() and not self.isDirectoryBackedAddressBookCollection()):
</del><ins>+ # Push notification DAV property "pushkey"
+ if qname == customxml.PubSubXMPPPushKeyProperty.qname() and (
+ self.isCalendarCollection() or (self.isAddressBookCollection() and not self.isDirectoryBackedAddressBookCollection())
+ ):
</ins><span class="cx">
</span><del>- # Push notification DAV property "pushkey"
- if qname == customxml.PubSubXMPPPushKeyProperty.qname():
</del><ins>+ if hasattr(self, "_newStoreObject"):
+ notifier = self._newStoreObject.getNotifier("push")
+ if notifier is not None:
+ propVal = customxml.PubSubXMPPPushKeyProperty(notifier.nodeName())
+ returnValue(propVal)
</ins><span class="cx">
</span><del>- if hasattr(self, "_newStoreObject"):
- notifier = self._newStoreObject.getNotifier("push")
- if notifier is not None:
- propVal = customxml.PubSubXMPPPushKeyProperty(notifier.nodeName())
- returnValue(propVal)
</del><ins>+ returnValue(customxml.PubSubXMPPPushKeyProperty())
</ins><span class="cx">
</span><del>- returnValue(customxml.PubSubXMPPPushKeyProperty())
-
- res = (yield self._readGlobalProperty(qname, property, request))
- returnValue(res)
-
-
- def _readSharedProperty(self, qname, request):
-
- # Default behavior - read per-user dead property
- p = self.deadProperties().get(qname)
- return p
-
-
- @inlineCallbacks
- def _readGlobalProperty(self, qname, property, request):
-
- if qname == element.Owner.qname():
</del><ins>+ elif qname == element.Owner.qname():
</ins><span class="cx"> owner = (yield self.owner(request))
</span><span class="cx"> returnValue(element.Owner(owner))
</span><span class="cx">
</span><span class="lines">@@ -715,13 +649,6 @@
</span><span class="cx"> "%r is not a WebDAVElement instance" % (property,)
</span><span class="cx"> )
</span><span class="cx">
</span><del>- self._preProcessWriteProperty(property, request)
-
- res = (yield self._writeGlobalProperty(property, request))
- returnValue(res)
-
-
- def _preProcessWriteProperty(self, property, request, isShare=False):
</del><span class="cx"> if property.qname() == caldavxml.SupportedCalendarComponentSet.qname():
</span><span class="cx"> if not self.isPseudoCalendarCollection():
</span><span class="cx"> raise HTTPError(StatusResponse(
</span><span class="lines">@@ -745,33 +672,15 @@
</span><span class="cx"> responsecode.FORBIDDEN,
</span><span class="cx"> "Property %s may only be set on calendar collection." % (property,)
</span><span class="cx"> ))
</span><del>- if not property.valid():
- raise HTTPError(ErrorResponse(
- responsecode.FORBIDDEN,
- (caldav_namespace, "valid-calendar-data"),
- description="Invalid property"
- ))
</del><span class="cx">
</span><span class="cx"> # Validate default alarm properties (do this even if the default alarm feature is off)
</span><del>- elif property.qname() in (
- caldavxml.DefaultAlarmVEventDateTime.qname(),
- caldavxml.DefaultAlarmVEventDate.qname(),
- caldavxml.DefaultAlarmVToDoDateTime.qname(),
- caldavxml.DefaultAlarmVToDoDate.qname(),
- ):
</del><ins>+ elif property.qname() in DefaultAlarmPropertyMixin.ALARM_PROPERTIES:
</ins><span class="cx"> if not self.isCalendarCollection() and not isinstance(self, CalendarHomeResource):
</span><span class="cx"> raise HTTPError(StatusResponse(
</span><span class="cx"> responsecode.FORBIDDEN,
</span><span class="cx"> "Property %s may only be set on calendar or home collection." % (property,)
</span><span class="cx"> ))
</span><span class="cx">
</span><del>- if not property.valid():
- raise HTTPError(ErrorResponse(
- responsecode.CONFLICT,
- (caldav_namespace, "valid-calendar-data"),
- description="Invalid property"
- ))
-
</del><span class="cx"> elif property.qname() == caldavxml.ScheduleCalendarTransp.qname():
</span><span class="cx"> if not self.isCalendarCollection():
</span><span class="cx"> raise HTTPError(StatusResponse(
</span><span class="lines">@@ -779,14 +688,6 @@
</span><span class="cx"> "Property %s may only be set on calendar collection." % (property,)
</span><span class="cx"> ))
</span><span class="cx">
</span><del>-
- @inlineCallbacks
- def _writeGlobalProperty(self, property, request):
-
- if property.qname() == caldavxml.ScheduleCalendarTransp.qname():
- yield self._newStoreObject.setUsedForFreeBusy(property == caldavxml.ScheduleCalendarTransp(caldavxml.Opaque()))
- returnValue(None)
-
</del><span class="cx"> result = (yield super(CalDAVResource, self).writeProperty(property, request))
</span><span class="cx"> returnValue(result)
</span><span class="cx">
</span><span class="lines">@@ -2452,11 +2353,7 @@
</span><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span><del>- def _hasGlobalProperty(self, property, request):
- """
- Need to special case schedule-calendar-transp for backwards compatability.
- """
-
</del><ins>+ def hasProperty(self, property, request):
</ins><span class="cx"> if type(property) is tuple:
</span><span class="cx"> qname = property
</span><span class="cx"> else:
</span><span class="lines">@@ -2467,7 +2364,7 @@
</span><span class="cx"> return succeed(self.getDefaultAlarmProperty(qname) is not None)
</span><span class="cx">
</span><span class="cx"> else:
</span><del>- return super(CalendarHomeResource, self)._hasGlobalProperty(property, request)
</del><ins>+ return super(CalendarHomeResource, self).hasProperty(property, request)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -2506,13 +2403,19 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def _writeGlobalProperty(self, property, request):
</del><ins>+ def writeProperty(self, property, request):
</ins><span class="cx">
</span><span class="cx"> if property.qname() in DefaultAlarmPropertyMixin.ALARM_PROPERTIES:
</span><ins>+ if not property.valid():
+ raise HTTPError(ErrorResponse(
+ responsecode.CONFLICT,
+ (caldav_namespace, "valid-calendar-data"),
+ description="Invalid property"
+ ))
</ins><span class="cx"> yield self.setDefaultAlarmProperty(property)
</span><span class="cx"> returnValue(None)
</span><span class="cx">
</span><del>- result = (yield super(CalendarHomeResource, self)._writeGlobalProperty(property, request))
</del><ins>+ result = (yield super(CalendarHomeResource, self).writeProperty(property, request))
</ins><span class="cx"> returnValue(result)
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavstorebridgepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/storebridge.py (13895 => 13896)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/storebridge.py        2014-08-19 17:49:19 UTC (rev 13895)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py        2014-08-19 21:25:04 UTC (rev 13896)
</span><span class="lines">@@ -280,9 +280,22 @@
</span><span class="cx"> if qname == customxml.MaxResources.qname() and config.MaxResourcesPerCollection:
</span><span class="cx"> returnValue(customxml.MaxResources.fromString(config.MaxResourcesPerCollection))
</span><span class="cx">
</span><del>- returnValue((yield super(_CommonHomeChildCollectionMixin, self).readProperty(prop, request)))
</del><ins>+ elif qname == customxml.BulkRequests.qname() and config.EnableBatchUpload:
+ returnValue(customxml.BulkRequests(
+ customxml.Simple(
+ customxml.MaxBulkResources.fromString(str(config.MaxResourcesBatchUpload)),
+ customxml.MaxBulkBytes.fromString(str(config.MaxBytesBatchUpload)),
+ ),
+ customxml.CRUD(
+ customxml.MaxBulkResources.fromString(str(config.MaxResourcesBatchUpload)),
+ customxml.MaxBulkBytes.fromString(str(config.MaxBytesBatchUpload)),
+ ),
+ ))
</ins><span class="cx">
</span><ins>+ result = (yield super(_CommonHomeChildCollectionMixin, self).readProperty(prop, request))
+ returnValue(result)
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> def url(self):
</span><span class="cx"> return joinURL(self._parentResource.url(), self._name, "/")
</span><span class="cx">
</span><span class="lines">@@ -589,25 +602,6 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def _readGlobalProperty(self, qname, prop, request):
-
- if config.EnableBatchUpload and qname == customxml.BulkRequests.qname():
- returnValue(customxml.BulkRequests(
- customxml.Simple(
- customxml.MaxBulkResources.fromString(str(config.MaxResourcesBatchUpload)),
- customxml.MaxBulkBytes.fromString(str(config.MaxBytesBatchUpload)),
- ),
- customxml.CRUD(
- customxml.MaxBulkResources.fromString(str(config.MaxResourcesBatchUpload)),
- customxml.MaxBulkBytes.fromString(str(config.MaxBytesBatchUpload)),
- ),
- ))
- else:
- result = (yield super(_CommonHomeChildCollectionMixin, self)._readGlobalProperty(qname, prop, request))
- returnValue(result)
-
-
- @inlineCallbacks
</del><span class="cx"> def checkCTagPrecondition(self, request):
</span><span class="cx"> if request.headers.hasHeader("If"):
</span><span class="cx"> iffy = request.headers.getRawHeaders("If")[0]
</span><span class="lines">@@ -1243,11 +1237,7 @@
</span><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span><del>- def _hasGlobalProperty(self, property, request):
- """
- Need to special case schedule-calendar-transp for backwards compatability.
- """
-
</del><ins>+ def hasProperty(self, property, request):
</ins><span class="cx"> if type(property) is tuple:
</span><span class="cx"> qname = property
</span><span class="cx"> else:
</span><span class="lines">@@ -1261,7 +1251,7 @@
</span><span class="cx"> return succeed(self._newStoreObject.getTimezone() is not None)
</span><span class="cx">
</span><span class="cx"> else:
</span><del>- return super(CalendarCollectionResource, self)._hasGlobalProperty(property, request)
</del><ins>+ return super(CalendarCollectionResource, self).hasProperty(property, request)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -1284,17 +1274,33 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def _writeGlobalProperty(self, property, request):
</del><ins>+ def writeProperty(self, property, request):
</ins><span class="cx">
</span><span class="cx"> if property.qname() in DefaultAlarmPropertyMixin.ALARM_PROPERTIES:
</span><ins>+ if not property.valid():
+ raise HTTPError(ErrorResponse(
+ responsecode.CONFLICT,
+ (caldav_namespace, "valid-calendar-data"),
+ description="Invalid property"
+ ))
</ins><span class="cx"> yield self.setDefaultAlarmProperty(property)
</span><span class="cx"> returnValue(None)
</span><span class="cx">
</span><span class="cx"> elif property.qname() == caldavxml.CalendarTimeZone.qname():
</span><ins>+ if not property.valid():
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (caldav_namespace, "valid-calendar-data"),
+ description="Invalid property"
+ ))
</ins><span class="cx"> yield self._newStoreObject.setTimezone(property.calendar())
</span><span class="cx"> returnValue(None)
</span><span class="cx">
</span><del>- result = (yield super(CalendarCollectionResource, self)._writeGlobalProperty(property, request))
</del><ins>+ elif property.qname() == caldavxml.ScheduleCalendarTransp.qname():
+ yield self._newStoreObject.setUsedForFreeBusy(property == caldavxml.ScheduleCalendarTransp(caldavxml.Opaque()))
+ returnValue(None)
+
+ result = (yield super(CalendarCollectionResource, self).writeProperty(property, request))
</ins><span class="cx"> returnValue(result)
</span><span class="cx">
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>