<!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>[15156] CalendarServer/trunk</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/15156">15156</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2015-09-29 01:27:20 -0700 (Tue, 29 Sep 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Support for server-info document - off by default.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkcalendarservertaputilpy">CalendarServer/trunk/calendarserver/tap/util.py</a></li>
<li><a href="#CalendarServertrunkrequirementsdevtxt">CalendarServer/trunk/requirements-dev.txt</a></li>
<li><a href="#CalendarServertrunktwistedcaldavextensionspy">CalendarServer/trunk/twistedcaldav/extensions.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavresourcepy">CalendarServer/trunk/twistedcaldav/resource.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavstdconfigpy">CalendarServer/trunk/twistedcaldav/stdconfig.py</a></li>
<li><a href="#CalendarServertrunktxweb2davmethodpropfindpy">CalendarServer/trunk/txweb2/dav/method/propfind.py</a></li>
<li><a href="#CalendarServertrunktxweb2davresourcepy">CalendarServer/trunk/txweb2/dav/resource.py</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#CalendarServertrunktwistedcaldavserverinfopy">CalendarServer/trunk/twistedcaldav/serverinfo.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavserverinfoxmlpy">CalendarServer/trunk/twistedcaldav/serverinfoxml.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkcalendarservertaputilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tap/util.py (15155 => 15156)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tap/util.py        2015-09-29 08:12:33 UTC (rev 15155)
+++ CalendarServer/trunk/calendarserver/tap/util.py        2015-09-29 08:27:20 UTC (rev 15156)
</span><span class="lines">@@ -72,6 +72,7 @@
</span><span class="cx"> from twistedcaldav.directory.principal import DirectoryPrincipalProvisioningResource
</span><span class="cx"> from twistedcaldav.directorybackedaddressbook import DirectoryBackedAddressBookResource
</span><span class="cx"> from twistedcaldav.resource import AuthenticationWrapper
</span><ins>+from twistedcaldav.serverinfo import ServerInfoResource
</ins><span class="cx"> from twistedcaldav.simpleresource import SimpleResource, SimpleRedirectResource, \
</span><span class="cx"> SimpleUnavailableResource
</span><span class="cx"> from twistedcaldav.stdconfig import config
</span><span class="lines">@@ -421,6 +422,7 @@
</span><span class="cx"> addressBookResourceClass = DirectoryAddressBookHomeProvisioningResource
</span><span class="cx"> directoryBackedAddressBookResourceClass = DirectoryBackedAddressBookResource
</span><span class="cx"> apnSubscriptionResourceClass = APNSubscriptionResource
</span><ins>+ serverInfoResourceClass = ServerInfoResource
</ins><span class="cx"> principalResourceClass = DirectoryPrincipalProvisioningResource
</span><span class="cx"> controlResourceClass = ControlAPIResource
</span><span class="cx">
</span><span class="lines">@@ -743,6 +745,17 @@
</span><span class="cx"> apnResource = apnSubscriptionResourceClass(root, newStore)
</span><span class="cx"> root.putChild(apnConfig["SubscriptionURL"], apnResource)
</span><span class="cx">
</span><ins>+ # Server info document
+ if config.EnableServerInfo:
+ log.info(
+ "Setting up server-info resource: {cls}",
+ cls=serverInfoResourceClass)
+
+ serverInfo = serverInfoResourceClass(
+ root,
+ )
+ root.putChild("server-info", serverInfo)
+
</ins><span class="cx"> #
</span><span class="cx"> # Configure ancillary data
</span><span class="cx"> #
</span></span></pre></div>
<a id="CalendarServertrunkrequirementsdevtxt"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/requirements-dev.txt (15155 => 15156)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/requirements-dev.txt        2015-09-29 08:12:33 UTC (rev 15155)
+++ CalendarServer/trunk/requirements-dev.txt        2015-09-29 08:27:20 UTC (rev 15156)
</span><span class="lines">@@ -8,4 +8,4 @@
</span><span class="cx"> q
</span><span class="cx"> tl.eggdeps
</span><span class="cx"> --editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVClientLibrary/trunk@14856#egg=CalDAVClientLibrary
</span><del>---editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@15151#egg=CalDAVTester
</del><ins>+--editable svn+http://svn.calendarserver.org/repository/calendarserver/CalDAVTester/trunk@15155#egg=CalDAVTester
</ins></span></pre></div>
<a id="CalendarServertrunktwistedcaldavextensionspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/extensions.py (15155 => 15156)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/extensions.py        2015-09-29 08:12:33 UTC (rev 15155)
+++ CalendarServer/trunk/twistedcaldav/extensions.py        2015-09-29 08:27:20 UTC (rev 15156)
</span><span class="lines">@@ -76,6 +76,22 @@
</span><span class="cx"> log = Logger()
</span><span class="cx">
</span><span class="cx">
</span><ins>+class WebDAVServerInfoMixIn(object):
+
+ def renderHTTP(self, request):
+ def _addServerInfoToken(request, response):
+ # server-info-token processing
+ if config.EnableServerInfo and (
+ request.headers.hasHeader("server-info-token") or
+ request.method == "OPTIONS"
+ ):
+ response.headers.setRawHeaders("server-info-token", (config.ServerInfoToken,))
+ return response
+ request.addResponseFilter(_addServerInfoToken, onlyOnce=True)
+ return super(WebDAVServerInfoMixIn, self).renderHTTP(request)
+
+
+
</ins><span class="cx"> class DirectoryPrincipalPropertySearchMixIn(object):
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -583,9 +599,13 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-class DAVResource (DirectoryPrincipalPropertySearchMixIn,
- SuperDAVResource,
- DirectoryRenderingMixIn, StaticRenderMixin):
</del><ins>+class DAVResource (
+ WebDAVServerInfoMixIn,
+ DirectoryPrincipalPropertySearchMixIn,
+ SuperDAVResource,
+ DirectoryRenderingMixIn,
+ StaticRenderMixin
+):
</ins><span class="cx"> """
</span><span class="cx"> Extended L{txweb2.dav.resource.DAVResource} implementation.
</span><span class="cx">
</span><span class="lines">@@ -712,9 +732,12 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-class DAVPrincipalResource (DirectoryPrincipalPropertySearchMixIn,
- SuperDAVPrincipalResource,
- DirectoryRenderingMixIn):
</del><ins>+class DAVPrincipalResource (
+ WebDAVServerInfoMixIn,
+ DirectoryPrincipalPropertySearchMixIn,
+ SuperDAVPrincipalResource,
+ DirectoryRenderingMixIn
+):
</ins><span class="cx"> """
</span><span class="cx"> Extended L{txweb2.dav.static.DAVFile} implementation.
</span><span class="cx"> """
</span><span class="lines">@@ -811,7 +834,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-class DAVFile (SuperDAVFile, DirectoryRenderingMixIn):
</del><ins>+class DAVFile (WebDAVServerInfoMixIn, SuperDAVFile, DirectoryRenderingMixIn):
</ins><span class="cx"> """
</span><span class="cx"> Extended L{txweb2.dav.static.DAVFile} implementation.
</span><span class="cx"> """
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavresourcepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/resource.py (15155 => 15156)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/resource.py        2015-09-29 08:12:33 UTC (rev 15155)
+++ CalendarServer/trunk/twistedcaldav/resource.py        2015-09-29 08:27:20 UTC (rev 15156)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx">
</span><span class="cx"> from twistedcaldav import caldavxml, customxml
</span><span class="cx"> from twistedcaldav import carddavxml
</span><ins>+from twistedcaldav import serverinfoxml
</ins><span class="cx"> from twistedcaldav import ical
</span><span class="cx"> from twistedcaldav.cache import PropfindCacheMixin
</span><span class="cx"> from twistedcaldav.caldavxml import caldav_namespace
</span><span class="lines">@@ -59,7 +60,7 @@
</span><span class="cx"> from txdav.common.icommondatastore import InternalDataStoreError, \
</span><span class="cx"> SyncTokenValidException
</span><span class="cx"> from txdav.xml import element
</span><del>-from txdav.xml.element import dav_namespace
</del><ins>+from txdav.xml.element import dav_namespace, HRef
</ins><span class="cx">
</span><span class="cx"> from txweb2 import responsecode, http, http_headers
</span><span class="cx"> from txweb2.auth.wrapper import UnauthorizedResponse
</span><span class="lines">@@ -554,6 +555,10 @@
</span><span class="cx"> customxml.AllowedSharingModes.qname(),
</span><span class="cx"> )
</span><span class="cx">
</span><ins>+ if config.EnableServerInfo:
+ baseProperties += (serverinfoxml.ServerInfoHref.qname(),)
+
+
</ins><span class="cx"> return super(CalDAVResource, self).liveProperties() + baseProperties
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -704,6 +709,11 @@
</span><span class="cx"> else:
</span><span class="cx"> returnValue(None)
</span><span class="cx">
</span><ins>+
+ elif qname == serverinfoxml.ServerInfoHref.qname():
+ if config.EnableServerInfo:
+ returnValue(serverinfoxml.ServerInfoHref(HRef.fromString("/server-info")))
+
</ins><span class="cx"> result = (yield super(CalDAVResource, self).readProperty(property, request))
</span><span class="cx"> returnValue(result)
</span><span class="cx">
</span><span class="lines">@@ -2446,13 +2456,6 @@
</span><span class="cx"> returnValue((storeHome, created))
</span><span class="cx">
</span><span class="cx">
</span><del>- def davComplianceClasses(self):
- compliance = tuple(super(CalendarHomeResource, self).davComplianceClasses())
- if config.EnableTimezonesByReference:
- compliance += caldavxml.caldav_timezone_service_set_compliance
- return compliance
-
-
</del><span class="cx"> def liveProperties(self):
</span><span class="cx">
</span><span class="cx"> existing = super(CalendarHomeResource, self).liveProperties()
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavserverinfopy"></a>
<div class="addfile"><h4>Added: CalendarServer/trunk/twistedcaldav/serverinfo.py (0 => 15156)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/serverinfo.py         (rev 0)
+++ CalendarServer/trunk/twistedcaldav/serverinfo.py        2015-09-29 08:27:20 UTC (rev 15156)
</span><span class="lines">@@ -0,0 +1,257 @@
</span><ins>+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from twisted.internet.defer import inlineCallbacks, succeed, returnValue
+from twistedcaldav import caldavxml, carddavxml, mkcolxml
+from twistedcaldav import customxml
+from twistedcaldav.caldavxml import caldav_namespace
+from twistedcaldav.carddavxml import carddav_namespace
+from twistedcaldav.customxml import calendarserver_namespace
+from txdav.xml import element as davxml
+from txdav.xml.element import dav_namespace, WebDAVUnknownElement
+from txweb2.dav.noneprops import NonePropertyStore
+from txweb2.http_headers import MimeType, ETag
+from twistedcaldav.resource import ReadOnlyNoCopyResourceMixIn
+from twistedcaldav.extensions import DAVResource, \
+ DAVResourceWithoutChildrenMixin
+from txweb2.http import XMLResponse
+from twistedcaldav.config import config
+from txweb2 import responsecode
+import hashlib
+from twistedcaldav.serverinfoxml import Class1_Feature, AccessControl_Feature, \
+ Quota_Feature, SyncCollection_Feature, AddMember_Feature, Name_Service, \
+ Features, ServerInfo, Token, Applications, Application
+
+"""
+draft-douglass-server-info: "DAV Server Information Object"
+"""
+
+def buildServerInfo(config):
+ """
+ Build the DAV compliance header, server-info document, and server-info-token value
+ based on the supplied L{config}.
+
+ @param config: config to use
+ @type config: L{twistedcaldav.config}
+
+ @return: tuple of three items: compliance value, server-info XML document root
+ element, server-info-token value
+ @rtype: L{tuple}
+ """
+ global_features = [
+ Class1_Feature(),
+ AccessControl_Feature(),
+ Quota_Feature(),
+ SyncCollection_Feature(),
+ AddMember_Feature(),
+ ]
+ compliance = ()
+ applications = []
+ if config.EnableCalDAV:
+ if config.Scheduling.CalDAV.OldDraftCompatibility:
+ compliance = caldavxml.caldav_full_compliance
+ else:
+ compliance = caldavxml.caldav_implicit_compliance
+ features = [
+ WebDAVUnknownElement.withName(caldav_namespace, "calendar-access"),
+ WebDAVUnknownElement.withName(caldav_namespace, "calendar-auto-schedule"),
+ WebDAVUnknownElement.withName(calendarserver_namespace, "calendar-availability"),
+ WebDAVUnknownElement.withName(calendarserver_namespace, "inbox-availability"),
+ ]
+
+ if config.EnableProxyPrincipals:
+ compliance += customxml.calendarserver_proxy_compliance
+ features.append(WebDAVUnknownElement.withName(calendarserver_namespace, customxml.calendarserver_proxy_compliance[0]))
+
+ if config.EnablePrivateEvents:
+ compliance += customxml.calendarserver_private_events_compliance
+ features.append(WebDAVUnknownElement.withName(calendarserver_namespace, customxml.calendarserver_private_events_compliance[0]))
+
+ if config.Scheduling.CalDAV.EnablePrivateComments:
+ compliance += customxml.calendarserver_private_comments_compliance
+ features.append(WebDAVUnknownElement.withName(calendarserver_namespace, customxml.calendarserver_private_comments_compliance[0]))
+
+ if config.Sharing.Enabled:
+ compliance += customxml.calendarserver_sharing_compliance
+ # TODO: This is only needed whilst we do not support scheduling in shared calendars
+ compliance += customxml.calendarserver_sharing_no_scheduling_compliance
+ if config.Sharing.Calendars.Enabled and config.Sharing.Calendars.Groups.Enabled:
+ compliance += customxml.calendarserver_group_sharee_compliance
+
+ sharing = WebDAVUnknownElement.withName(calendarserver_namespace, customxml.calendarserver_sharing_compliance[0])
+ # TODO: This is only needed whilst we do not support scheduling in shared calendars
+ sharing.children += (WebDAVUnknownElement.withName(calendarserver_namespace, customxml.calendarserver_sharing_no_scheduling_compliance[0]),)
+ if config.Sharing.Calendars.Enabled and config.Sharing.Calendars.Groups.Enabled:
+ sharing.children += (WebDAVUnknownElement.withName(calendarserver_namespace, customxml.calendarserver_group_sharee_compliance[0]),)
+ features.append(sharing)
+
+ if config.EnableCalendarQueryExtended:
+ compliance += caldavxml.caldav_query_extended_compliance
+ features.append(WebDAVUnknownElement.withName(caldav_namespace, caldavxml.caldav_query_extended_compliance[0]))
+
+ if config.EnableDefaultAlarms:
+ compliance += caldavxml.caldav_default_alarms_compliance
+ features.append(WebDAVUnknownElement.withName(caldav_namespace, caldavxml.caldav_default_alarms_compliance[0]))
+
+ if config.EnableManagedAttachments:
+ compliance += caldavxml.caldav_managed_attachments_compliance
+ features.append(WebDAVUnknownElement.withName(caldav_namespace, caldavxml.caldav_managed_attachments_compliance[0]))
+
+ if config.Scheduling.Options.TimestampAttendeePartStatChanges:
+ compliance += customxml.calendarserver_partstat_changes_compliance
+ features.append(WebDAVUnknownElement.withName(calendarserver_namespace, customxml.calendarserver_partstat_changes_compliance[0]))
+
+ if config.GroupAttendees.Enabled:
+ compliance += customxml.calendarserver_group_attendee_compliance
+ features.append(WebDAVUnknownElement.withName(calendarserver_namespace, customxml.calendarserver_group_attendee_compliance[0]))
+
+ if config.EnableTimezonesByReference:
+ compliance += caldavxml.caldav_timezones_by_reference_compliance
+ features.append(WebDAVUnknownElement.withName(caldav_namespace, caldavxml.caldav_timezones_by_reference_compliance[0]))
+
+ compliance += customxml.calendarserver_recurrence_split
+ features.append(WebDAVUnknownElement.withName(calendarserver_namespace, customxml.calendarserver_recurrence_split[0]))
+
+ applications.append(
+ Application(
+ Name_Service.fromString("caldav"),
+ Features(*features),
+ )
+ )
+
+ if config.EnableCardDAV:
+ compliance += carddavxml.carddav_compliance
+ features = [
+ WebDAVUnknownElement.withName(carddav_namespace, "addressbook"),
+ ]
+
+ applications.append(
+ Application(
+ Name_Service.fromString("carddav"),
+ Features(*features),
+ )
+ )
+
+ if config.EnableCardDAV:
+ compliance += carddavxml.carddav_compliance
+
+ if config.EnableCalDAV or config.EnableCardDAV:
+ compliance += mkcolxml.mkcol_compliance
+ global_features.append(WebDAVUnknownElement.withName(dav_namespace, mkcolxml.mkcol_compliance[0]))
+
+ # Principal property search is always enabled
+ compliance += customxml.calendarserver_principal_property_search_compliance
+ global_features.append(WebDAVUnknownElement.withName(calendarserver_namespace, customxml.calendarserver_principal_property_search_compliance[0]))
+
+ compliance += customxml.calendarserver_principal_search_compliance
+ global_features.append(WebDAVUnknownElement.withName(calendarserver_namespace, customxml.calendarserver_principal_search_compliance[0]))
+
+ # Home Depth:1 sync report will include WebDAV property changes on home child resources
+ compliance += customxml.calendarserver_home_sync_compliance
+
+ def _createServerInfo(token):
+ return ServerInfo(
+ Token.fromString(token),
+ Features(*global_features),
+ Applications(*applications)
+ )
+
+ token = hashlib.md5(_createServerInfo("").toxml()).hexdigest()
+
+ return compliance, _createServerInfo(token), token
+
+
+
+class ServerInfoResource (ReadOnlyNoCopyResourceMixIn, DAVResourceWithoutChildrenMixin, DAVResource):
+ """
+ Server-info resource.
+
+ Extends L{DAVResource} to allow server-info document retrieval.
+ """
+
+ def __init__(self, parent):
+ """
+ @param parent: the parent resource of this one.
+ """
+ assert parent is not None
+
+ DAVResource.__init__(self, principalCollections=parent.principalCollections())
+
+ self.parent = parent
+
+
+ def deadProperties(self):
+ if not hasattr(self, "_dead_properties"):
+ self._dead_properties = NonePropertyStore(self)
+ return self._dead_properties
+
+
+ def etag(self):
+ return succeed(ETag(config.ServerInfoToken))
+
+
+ def checkPreconditions(self, request):
+ return None
+
+
+ def checkPrivileges(self, request, privileges, recurse=False, principal=None, inherited_aces=None):
+ return succeed(None)
+
+
+ def defaultAccessControlList(self):
+ return succeed(
+ davxml.ACL(
+ # DAV:Read for all principals (includes anonymous)
+ davxml.ACE(
+ davxml.Principal(davxml.All()),
+ davxml.Grant(
+ davxml.Privilege(davxml.Read()),
+ ),
+ davxml.Protected(),
+ ),
+ )
+ )
+
+
+ def contentType(self):
+ return MimeType.fromString("text/xml; charset=utf-8")
+
+
+ def resourceType(self):
+ return None
+
+
+ def isCollection(self):
+ return False
+
+
+ def isCalendarCollection(self):
+ return False
+
+
+ def isPseudoCalendarCollection(self):
+ return False
+
+
+ @inlineCallbacks
+ def http_GET(self, request):
+ """
+ The server-info GET method.
+ """
+
+ yield self.authorize(request, (davxml.Read(),))
+
+ returnValue(XMLResponse(responsecode.OK, config.ServerInfo))
</ins></span></pre></div>
<a id="CalendarServertrunktwistedcaldavserverinfoxmlpy"></a>
<div class="addfile"><h4>Added: CalendarServer/trunk/twistedcaldav/serverinfoxml.py (0 => 15156)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/serverinfoxml.py         (rev 0)
+++ CalendarServer/trunk/twistedcaldav/serverinfoxml.py        2015-09-29 08:27:20 UTC (rev 15156)
</span><span class="lines">@@ -0,0 +1,152 @@
</span><ins>+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from txdav.xml.element import WebDAVElement, dav_namespace, registerElement, \
+ WebDAVTextElement, WebDAVEmptyElement, Bind, \
+ SyncCollection, AddMember
+
+@registerElement
+class ServerInfoHref (WebDAVElement):
+ namespace = dav_namespace
+ name = "server-info-href"
+ hidden = True
+ protected = True
+ allowed_children = {
+ (dav_namespace, "href"): (0, 1),
+ }
+
+
+
+@registerElement
+class ServerInfo (WebDAVElement):
+ namespace = dav_namespace
+ name = "server-info"
+ allowed_children = {
+ (dav_namespace, "token"): (1, 1),
+ (dav_namespace, "features"): (0, 1),
+ (dav_namespace, "services"): (0, 1),
+ }
+
+
+
+@registerElement
+class Token (WebDAVTextElement):
+ namespace = dav_namespace
+ name = "token"
+
+
+
+@registerElement
+class Features (WebDAVElement):
+ namespace = dav_namespace
+ name = "features"
+ allowed_children = {}
+
+
+
+@registerElement
+class Applications (WebDAVElement):
+ namespace = dav_namespace
+ name = "applications"
+ allowed_children = {
+ (dav_namespace, "application"): (0, None),
+ }
+
+
+
+@registerElement
+class Application (WebDAVElement):
+ namespace = dav_namespace
+ name = "application"
+ allowed_children = {
+ (dav_namespace, "name"): (1, 1),
+ (dav_namespace, "features"): (1, 1),
+ }
+
+
+
+@registerElement
+class Name_Service (WebDAVTextElement):
+ namespace = dav_namespace
+ name = "name"
+
+
+
+@registerElement
+class Class1_Feature (WebDAVEmptyElement):
+ namespace = dav_namespace
+ name = "class-1"
+
+
+
+@registerElement
+class Class2_Feature (WebDAVEmptyElement):
+ namespace = dav_namespace
+ name = "class-2"
+
+
+
+@registerElement
+class Class3_Feature (WebDAVEmptyElement):
+ namespace = dav_namespace
+ name = "class-3"
+
+
+
+@registerElement
+class AccessControl_Feature (WebDAVEmptyElement):
+ namespace = dav_namespace
+ name = "access-control"
+
+
+
+@registerElement
+class VersionControl_Feature (WebDAVEmptyElement):
+ namespace = dav_namespace
+ name = "version-control"
+
+
+
+@registerElement
+class ExtendedMkcol_Feature (WebDAVEmptyElement):
+ namespace = dav_namespace
+ name = "extended-mkcol"
+
+
+
+@registerElement
+class Quota_Feature (WebDAVEmptyElement):
+ namespace = dav_namespace
+ name = "quota"
+
+
+
+Bind_Feature = Bind
+
+
+
+@registerElement
+class Search_Feature (WebDAVEmptyElement):
+ namespace = dav_namespace
+ name = "search"
+
+
+
+SyncCollection_Feature = SyncCollection
+
+
+
+AddMember_Feature = AddMember
</ins></span></pre></div>
<a id="CalendarServertrunktwistedcaldavstdconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py (15155 => 15156)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/stdconfig.py        2015-09-29 08:12:33 UTC (rev 15155)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py        2015-09-29 08:27:20 UTC (rev 15156)
</span><span class="lines">@@ -33,7 +33,6 @@
</span><span class="cx"> from twisted.python.filepath import FilePath
</span><span class="cx"> from twisted.python.runtime import platform
</span><span class="cx">
</span><del>-from twistedcaldav import caldavxml, customxml, carddavxml, mkcolxml
</del><span class="cx"> from twistedcaldav import ical
</span><span class="cx"> from twistedcaldav.config import ConfigProvider, ConfigurationError, ConfigDict
</span><span class="cx"> from twistedcaldav.config import config, mergeData, fullServerPath
</span><span class="lines">@@ -516,6 +515,8 @@
</span><span class="cx">
</span><span class="cx"> "EnableManagedAttachments" : False, # Support Managed Attachments
</span><span class="cx">
</span><ins>+ "EnableServerInfo" : False, # server-info document
+
</ins><span class="cx"> #
</span><span class="cx"> # Generic CalDAV/CardDAV extensions
</span><span class="cx"> #
</span><span class="lines">@@ -1750,56 +1751,12 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> def _updateCompliance(configDict, reloading=False):
</span><ins>+ from twistedcaldav.serverinfo import buildServerInfo
+ (configDict.CalDAVComplianceClasses,
+ configDict.ServerInfo,
+ configDict.ServerInfoToken) = buildServerInfo(configDict)
</ins><span class="cx">
</span><del>- if configDict.EnableCalDAV:
- if configDict.Scheduling.CalDAV.OldDraftCompatibility:
- compliance = caldavxml.caldav_full_compliance
- else:
- compliance = caldavxml.caldav_implicit_compliance
- if configDict.EnableProxyPrincipals:
- compliance += customxml.calendarserver_proxy_compliance
- if configDict.EnablePrivateEvents:
- compliance += customxml.calendarserver_private_events_compliance
- if configDict.Scheduling.CalDAV.EnablePrivateComments:
- compliance += customxml.calendarserver_private_comments_compliance
- if config.Sharing.Enabled:
- compliance += customxml.calendarserver_sharing_compliance
- # TODO: This is only needed whilst we do not support scheduling in shared calendars
- compliance += customxml.calendarserver_sharing_no_scheduling_compliance
- if config.Sharing.Calendars.Enabled and config.Sharing.Calendars.Groups.Enabled:
- compliance += customxml.calendarserver_group_sharee_compliance
- if configDict.EnableCalendarQueryExtended:
- compliance += caldavxml.caldav_query_extended_compliance
- if configDict.EnableDefaultAlarms:
- compliance += caldavxml.caldav_default_alarms_compliance
- if configDict.EnableManagedAttachments:
- compliance += caldavxml.caldav_managed_attachments_compliance
- if configDict.Scheduling.Options.TimestampAttendeePartStatChanges:
- compliance += customxml.calendarserver_partstat_changes_compliance
- if config.GroupAttendees.Enabled:
- compliance += customxml.calendarserver_group_attendee_compliance
- if configDict.EnableTimezonesByReference:
- compliance += caldavxml.caldav_timezones_by_reference_compliance
- compliance += customxml.calendarserver_recurrence_split
- else:
- compliance = ()
</del><span class="cx">
</span><del>- if configDict.EnableCardDAV:
- compliance += carddavxml.carddav_compliance
-
- if configDict.EnableCalDAV or configDict.EnableCardDAV:
- compliance += mkcolxml.mkcol_compliance
-
- # Principal property search is always enabled
- compliance += customxml.calendarserver_principal_property_search_compliance
- compliance += customxml.calendarserver_principal_search_compliance
-
- # Home Depth:1 sync report will include WebDAV property changes on home child resources
- compliance += customxml.calendarserver_home_sync_compliance
-
- configDict.CalDAVComplianceClasses = compliance
-
-
</del><span class="cx"> PRE_UPDATE_HOOKS = (
</span><span class="cx"> _preUpdateDirectoryService,
</span><span class="cx"> _preUpdateResourceService,
</span></span></pre></div>
<a id="CalendarServertrunktxweb2davmethodpropfindpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txweb2/dav/method/propfind.py (15155 => 15156)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txweb2/dav/method/propfind.py        2015-09-29 08:12:33 UTC (rev 15155)
+++ CalendarServer/trunk/txweb2/dav/method/propfind.py        2015-09-29 08:27:20 UTC (rev 15156)
</span><span class="lines">@@ -171,9 +171,12 @@
</span><span class="cx"> properties_to_enumerate = search_properties
</span><span class="cx">
</span><span class="cx"> for property in properties_to_enumerate:
</span><del>- has = waitForDeferred(resource.hasProperty(property, request))
- yield has
- has = has.getResult()
</del><ins>+ if hasattr(resource, "hasProperty"):
+ has = waitForDeferred(resource.hasProperty(property, request))
+ yield has
+ has = has.getResult()
+ else:
+ has = False
</ins><span class="cx"> if has:
</span><span class="cx"> try:
</span><span class="cx"> resource_property = waitForDeferred(resource.readProperty(property, request))
</span></span></pre></div>
<a id="CalendarServertrunktxweb2davresourcepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txweb2/dav/resource.py (15155 => 15156)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txweb2/dav/resource.py        2015-09-29 08:12:33 UTC (rev 15155)
+++ CalendarServer/trunk/txweb2/dav/resource.py        2015-09-29 08:27:20 UTC (rev 15156)
</span><span class="lines">@@ -660,7 +660,7 @@
</span><span class="cx"> reactor.callLater(0, getChild)
</span><span class="cx">
</span><span class="cx"> def checkPrivileges(child):
</span><del>- if child is None:
</del><ins>+ if child is None or not hasattr(child, "checkPrivileges"):
</ins><span class="cx"> return None
</span><span class="cx">
</span><span class="cx"> if privileges is None:
</span></span></pre>
</div>
</div>
</body>
</html>