[CalendarServer-changes] [5404] CalendarServer/branches/users/cdaboo/shared-calendars-5187/ twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Thu Mar 25 19:04:49 PDT 2010
Revision: 5404
http://trac.macosforge.org/projects/calendarserver/changeset/5404
Author: cdaboo at apple.com
Date: 2010-03-25 19:04:46 -0700 (Thu, 25 Mar 2010)
Log Message:
-----------
Fixes after adding tests for per-user data and freebusy.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/directory/calendar.py
CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/resource.py
CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/scheduling/caldav.py
CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/sharing.py
Modified: CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/directory/calendar.py
===================================================================
--- CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/directory/calendar.py 2010-03-26 01:46:48 UTC (rev 5403)
+++ CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/directory/calendar.py 2010-03-26 02:04:46 UTC (rev 5404)
@@ -365,6 +365,9 @@
def ownerPrincipal(self, request):
return succeed(self.principalForRecord())
+ def resourceOwnerPrincipal(self, request):
+ return succeed(self.principalForRecord())
+
def defaultAccessControlList(self):
myPrincipal = self.principalForRecord()
Modified: CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/resource.py 2010-03-26 01:46:48 UTC (rev 5403)
+++ CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/resource.py 2010-03-26 02:04:46 UTC (rev 5404)
@@ -401,6 +401,7 @@
# Per-user Dav props currently only apply to a sharee's copy of a calendar
isvirt = (yield self.isVirtualShare(request))
if isvirt and (self.isShadowableProperty(property.qname()) or (not self.isGlobalProperty(property.qname()))):
+ yield self._preProcessWriteProperty(property, request)
ownerPrincipal = (yield self.resourceOwnerPrincipal(request))
p = self.deadProperties().set(property, uid=ownerPrincipal.principalUID())
returnValue(p)
@@ -409,7 +410,7 @@
returnValue(res)
@inlineCallbacks
- def _writeGlobalProperty(self, property, request):
+ def _preProcessWriteProperty(self, property, request):
if property.qname() == caldavxml.SupportedCalendarComponentSet.qname():
if not self.isPseudoCalendarCollection():
raise HTTPError(StatusResponse(
@@ -457,7 +458,12 @@
myurl = (yield self.canonicalURL(request))
inbox.processFreeBusyCalendar(myurl, property.children[0] == caldavxml.Opaque())
- elif property.qname() == davxml.ResourceType.qname():
+ @inlineCallbacks
+ def _writeGlobalProperty(self, property, request):
+
+ yield self._preProcessWriteProperty(property, request)
+
+ if property.qname() == davxml.ResourceType.qname():
if self.isCalendarCollection():
sawShare = [child for child in property.children if child.qname() == (calendarserver_namespace, "shared-owner")]
if not (config.Sharing.Enabled and config.Sharing.Calendars.Enabled):
@@ -587,19 +593,24 @@
else:
returnValue(None)
+ @inlineCallbacks
def resourceOwnerPrincipal(self, request):
"""
This is the owner of the resource based on the URI used to access it. For a shared
collection it will be the sharee, otherwise it will be the regular the ownerPrincipal.
"""
- def _defer(isVirt):
- return self._shareePrincipal if isVirt else self.ownerPrincipal(request)
+ isVirt = (yield self.isVirtualShare(request))
+ if isVirt:
+ returnValue(self._shareePrincipal)
+ else:
+ parent = (yield self.locateParent(request, request.urlForResource(self)))
+ if parent and isinstance(parent, CalDAVResource):
+ result = (yield parent.resourceOwnerPrincipal(request))
+ returnValue(result)
+ else:
+ returnValue(None)
- d = self.isVirtualShare(request)
- d.addCallback(_defer)
- return d
-
def isOwner(self, request, adminprincipals=False, readprincipals=False):
"""
Determine whether the DAV:owner of this resource matches the currently authorized principal
Modified: CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/scheduling/caldav.py
===================================================================
--- CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/scheduling/caldav.py 2010-03-26 01:46:48 UTC (rev 5403)
+++ CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/scheduling/caldav.py 2010-03-26 02:04:46 UTC (rev 5404)
@@ -249,6 +249,8 @@
# Now process free-busy set calendars
matchtotal = 0
for calendarResourceURL in fbset:
+ if not calendarResourceURL.endswith('/'):
+ calendarResourceURL += '/'
calendarResource = (yield self.scheduler.request.locateResource(calendarResourceURL))
if calendarResource is None or not calendarResource.exists() or not isCalendarCollectionResource(calendarResource):
# We will ignore missing calendars. If the recipient has failed to
Modified: CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/sharing.py 2010-03-26 01:46:48 UTC (rev 5403)
+++ CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/sharing.py 2010-03-26 02:04:46 UTC (rev 5404)
@@ -194,13 +194,15 @@
userprivs.append(davxml.Privilege(davxml.Read()))
userprivs.append(davxml.Privilege(davxml.ReadACL()))
userprivs.append(davxml.Privilege(davxml.ReadCurrentUserPrivilegeSet()))
+ if invite.access in ("read-only",):
+ userprivs.append(davxml.Privilege(davxml.WriteProperties()))
if invite.access in ("read-write", "read-write-schedule",):
userprivs.append(davxml.Privilege(davxml.Write()))
proxyprivs = list(userprivs)
proxyprivs.remove(davxml.Privilege(davxml.ReadACL()))
aces = (
- # Inheritable DAV:all access for the resource's associated principal.
+ # Inheritable specific access for the resource's associated principal.
davxml.ACE(
davxml.Principal(davxml.HRef(self._shareePrincipal.principalURL())),
davxml.Grant(*userprivs),
@@ -825,11 +827,25 @@
""" Remove a shared calendar named in resourceName and send a decline """
return self.declineShare(request, share.hosturl, share.inviteuid)
+ @inlineCallbacks
def removeShareByUID(self, request, inviteuid):
""" Remove a shared calendar but do not send a decline back """
- self.sharesDB().removeRecordForInviteUID(inviteuid)
- return succeed(True)
+ record = self.sharesDB().recordForInviteUID(inviteuid)
+ if record:
+ shareURL = joinURL(self.url(), record.localname)
+
+ # For backwards compatibility we need to sync this up with the calendar-free-busy-set on the inbox
+ principal = (yield self.resourceOwnerPrincipal(request))
+ inboxURL = principal.scheduleInboxURL()
+ if inboxURL:
+ inbox = (yield request.locateResource(inboxURL))
+ inbox.processFreeBusyCalendar(shareURL, False)
+
+ self.sharesDB().removeRecordForInviteUID(inviteuid)
+
+ returnValue(True)
+
@inlineCallbacks
def declineShare(self, request, hostUrl, inviteUID):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100325/ff5e3045/attachment.html>
More information about the calendarserver-changes
mailing list