[CalendarServer-changes] [10293] CalendarServer/trunk/twistedcaldav/sharing.py
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jan 8 13:57:33 PST 2013
Revision: 10293
http://trac.calendarserver.org//changeset/10293
Author: cdaboo at apple.com
Date: 2013-01-08 13:57:32 -0800 (Tue, 08 Jan 2013)
Log Message:
-----------
Add docstr.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/sharing.py
Modified: CalendarServer/trunk/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/sharing.py 2013-01-08 01:55:10 UTC (rev 10292)
+++ CalendarServer/trunk/twistedcaldav/sharing.py 2013-01-08 21:57:32 UTC (rev 10293)
@@ -1,6 +1,6 @@
# -*- test-case-name: twistedcaldav.test.test_sharing -*-
##
-# Copyright (c) 2010-2012 Apple Inc. All rights reserved.
+# Copyright (c) 2010-2013 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.
@@ -117,6 +117,7 @@
rtype = element.ResourceType(*(rtype.children + (customxml.SharedOwner(),)))
self.writeDeadProperty(rtype)
+
@inlineCallbacks
def downgradeFromShare(self, request):
@@ -289,7 +290,17 @@
@inlineCallbacks
def shareeAccessControlList(self, request, *args, **kwargs):
+ """
+ Return WebDAV ACLs appropriate for the current user accessing the shared collection. For
+ an "invite" share we take the privilege granted to the sharee in the invite and map that
+ to WebDAV ACLs. For a "direct" share, if it is a wiki collection we map the wiki privileges
+ into WebDAV ACLs, otherwise we use whatever privileges exist on the underlying shared
+ collection.
+ @return: the appropriate WebDAV ACL for the sharee
+ @rtype: L{davxml.ACL}
+ """
+
assert self._isShareeCollection, "Only call this for a sharee collection"
wikiAccessMethod = kwargs.get("wikiAccessMethod", getWikiAccess)
@@ -509,6 +520,7 @@
invitation = Invitation(shareeHomeChild)
returnValue(invitation)
+
@inlineCallbacks
def _updateInvitation(self, invitation, access=None, state=None, summary=None):
mode = None if access is None else invitationAccessToBindModeMap[access]
@@ -524,7 +536,7 @@
def _allInvitations(self, includeAccepted=True):
"""
Get list of all invitations to this object
-
+
For legacy reasons, all invitations are all invited + shared (accepted, not direct).
Combine these two into a single sorted list so code is similar to that for legacy invite db
"""
@@ -537,10 +549,11 @@
invitedHomeChildren += indirectAccceptedHomeChildren
invitations = [Invitation(homeChild) for homeChild in invitedHomeChildren]
- invitations.sort(key=lambda invitation:invitation.shareeUID())
+ invitations.sort(key=lambda invitation: invitation.shareeUID())
returnValue(invitations)
+
@inlineCallbacks
def _invitationForShareeUID(self, shareeUID, includeAccepted=True):
"""
@@ -556,7 +569,7 @@
@inlineCallbacks
def _invitationForUID(self, uid, includeAccepted=True):
"""
- Get an invitation for an invitations uid
+ Get an invitation for an invitations uid
"""
invitations = yield self._allInvitations(includeAccepted=includeAccepted)
for invitation in invitations:
@@ -565,7 +578,6 @@
returnValue(None)
-
@inlineCallbacks
def inviteSingleUserToShare(self, userid, cn, ace, summary, request):
@@ -671,7 +683,7 @@
state = notificationState if notificationState else invitation.state()
summary = invitation.summary() if displayName is None else displayName
- typeAttr = {'shared-type':self.sharedResourceType()}
+ typeAttr = {'shared-type': self.sharedResourceType()}
xmltype = customxml.InviteNotification(**typeAttr)
xmldata = customxml.Notification(
customxml.DTStamp.fromString(PyCalendarDateTime.getNowUTC().getText()),
@@ -696,6 +708,7 @@
# Add to collections
yield notifications.writeNotificationObject(invitation.uid(), xmltype, xmldata)
+
@inlineCallbacks
def removeInviteNotification(self, invitation, request):
@@ -709,6 +722,7 @@
# Add to collections
yield notifications.removeNotificationObjectWithUID(invitation.uid())
+
@inlineCallbacks
def _xmlHandleInvite(self, request, docroot):
yield self.authorize(request, (element.Read(), element.Write()))
@@ -947,35 +961,41 @@
def __init__(self, shareeHomeChild):
self._shareeHomeChild = shareeHomeChild
+
def uid(self):
return self._shareeHomeChild.shareUID()
+
def shareeUID(self):
return self._shareeHomeChild.viewerHome().uid()
+
def access(self):
return invitationAccessFromBindModeMap.get(self._shareeHomeChild.shareMode())
+
def state(self):
return invitationStateFromBindStatusMap.get(self._shareeHomeChild.shareStatus())
+
def summary(self):
return self._shareeHomeChild.shareMessage()
+
class SharedHomeMixin(LinkFollowerMixIn):
"""
A mix-in for calendar/addressbook homes that defines the operations for
manipulating a sharee's set of shared calendars.
"""
-
@inlineCallbacks
def provisionShare(self, child, request=None):
share = yield self._shareForHomeChild(child._newStoreObject, request)
if share:
child.setShare(share)
+
@inlineCallbacks
def _shareForHomeChild(self, child, request=None):
# Try to find a matching share
@@ -989,7 +1009,8 @@
if not request:
# FIXEME: Fake up a request that can be used to get the sharer home resource
- class _FakeRequest(object):pass
+ class _FakeRequest(object):
+ pass
fakeRequest = _FakeRequest()
setattr(fakeRequest, TRANSACTION_KEY, self._newStoreHome._txn)
request = fakeRequest
@@ -1004,6 +1025,7 @@
returnValue(share)
+
@inlineCallbacks
def _shareForUID(self, shareUID, request):
@@ -1023,6 +1045,7 @@
returnValue(None)
+
@inlineCallbacks
def acceptInviteShare(self, request, hostUrl, inviteUID, displayname=None):
@@ -1062,6 +1085,7 @@
response = yield self._acceptShare(request, not oldShare, share, displayname)
returnValue(response)
+
@inlineCallbacks
def _acceptShare(self, request, isNewShare, share, displayname=None):
@@ -1140,6 +1164,7 @@
else:
returnValue(None)
+
@inlineCallbacks
def removeDirectShare(self, request, share):
"""
@@ -1159,7 +1184,6 @@
inbox = (yield request.locateResource(inboxURL))
inbox.processFreeBusyCalendar(shareURL, False)
-
if share.direct():
yield share._sharerHomeChild.unshareWith(share._shareeHomeChild.viewerHome())
else:
@@ -1290,6 +1314,8 @@
self.localname = localname
self.summary = summary
+
+
class Share(object):
def __init__(self, sharerHomeChild, shareeHomeChild, url):
@@ -1297,10 +1323,12 @@
self._sharerHomeChild = sharerHomeChild
self._sharedResourceURL = url
+
@classmethod
def directUID(cls, shareeHome, sharerHomeChild):
return "Direct-%s-%s" % (shareeHome._resourceID, sharerHomeChild._resourceID,)
+
def uid(self):
# Move to CommonHomeChild shareUID?
if self._shareeHomeChild.shareMode() == _BIND_MODE_DIRECT:
@@ -1308,17 +1336,22 @@
else:
return self._shareeHomeChild.shareUID()
+
def direct(self):
return self._shareeHomeChild.shareMode() == _BIND_MODE_DIRECT
+
def url(self):
return self._sharedResourceURL
+
def name(self):
return self._shareeHomeChild.name()
+
def summary(self):
return self._shareeHomeChild.shareMessage()
+
def shareeUID(self):
return self._shareeHomeChild.viewerHome().uid()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130108/75f651d1/attachment.html>
More information about the calendarserver-changes
mailing list