[CalendarServer-changes] [9729] CalendarServer/branches/users/gaya/inviteclean/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Fri Aug 17 14:54:14 PDT 2012


Revision: 9729
          http://trac.macosforge.org/projects/calendarserver/changeset/9729
Author:   gaya at apple.com
Date:     2012-08-17 14:54:13 -0700 (Fri, 17 Aug 2012)
Log Message:
-----------
Minor cleanup

Modified Paths:
--------------
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py	2012-08-17 18:49:14 UTC (rev 9728)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py	2012-08-17 21:54:13 UTC (rev 9729)
@@ -488,6 +488,7 @@
         Need to special case schedule-calendar-transp for backwards compatability.
         """
         
+        #TODO: Remove old code below
         '''
         if type(property) is tuple:
             qname = property
@@ -564,8 +565,9 @@
                         returnValue(propVal)
 
                 returnValue(customxml.PubSubXMPPPushKeyProperty())
-
-        '''
+        
+        #TODO: Remove old code below
+        ''' 
         isShareeCollection = self.isShareeCollection()
         if isShareeCollection:
             if self.isShadowableProperty(qname):
@@ -715,6 +717,8 @@
             "%r is not a WebDAVElement instance" % (property,)
         )
         
+        #TODO: Remove old code below
+        '''
         # Per-user Dav props currently only apply to a sharee's copy of a calendar
         isShareeCollection = self.isShareeCollection()
 
@@ -722,6 +726,7 @@
             yield self._preProcessWriteProperty(property, request, isShare=True)
             p = self.deadProperties().set(property)
             returnValue(p)
+        '''
  
         res = (yield self._writeGlobalProperty(property, request))
         returnValue(res)
@@ -962,6 +967,7 @@
         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.
         """
+        #TODO: Remove old code below:
         '''
         isShareeCollection = self.isShareeCollection()
         if isShareeCollection:
@@ -2225,20 +2231,11 @@
             self.putChild(name, child)
             returnValue(child)
 
-        # Try normal child type
+        # get regular or shared child
         child = (yield self.makeRegularChild(name))
         
-        '''
-        # Try shares next if child does not exist
-        if not child.exists() and self.canShare():
-            sharedchild = yield self.provisionShare(name)
-            if sharedchild:
-                returnValue(sharedchild)
-        '''
-                    
-        share = yield self.shareWithChild(child._newStoreObject)
-        if share:
-            child.setShareeCollection(share)
+        # add _share attribute if child is shared
+        yield self.provisionShare(child)
 
         returnValue(child)
 

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py	2012-08-17 18:49:14 UTC (rev 9728)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py	2012-08-17 21:54:13 UTC (rev 9729)
@@ -235,13 +235,13 @@
         returnValue((yield self.isSpecialCollection(customxml.SharedOwner)))
 
 
-    def setShareeCollection(self, share):
-        self._isShareeCollection = True
+    def setShare(self, share):
+        self._isShareeCollection = True #  _isShareeCollection attr is used by self tests
         self._share = share
 
 
     def isShareeCollection(self):
-        """ Return True if this is a sharee shared calendar collection """
+        """ Return True if this is a sharee view of a shared calendar collection """
         return hasattr(self, "_isShareeCollection")
 
 
@@ -1065,9 +1065,16 @@
     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 shareWithChild(self, child, request=None):
+    def _shareForHomeChild(self, child, request=None):
         # Try to find a matching share
         if not child or child.owned():
             returnValue(None)
@@ -1100,14 +1107,14 @@
         # since child.shareUID() == child.name() for indirect shares
         child = yield self._newStoreHome.childWithName(shareUID)
         if child:
-            share = yield self.shareWithChild(child, request)
+            share = yield self._shareForHomeChild(child, request)
             if share and share.uid() == shareUID:
                 returnValue(share)
         
         # find direct shares
         children = yield self._newStoreHome.children()
         for child in children:
-            share = yield self.shareWithChild(child, request)
+            share = yield self._shareForHomeChild(child, request)
             if share and share.uid() == shareUID:
                 returnValue(share)
                 
@@ -1172,7 +1179,7 @@
             shareeHomeResource = yield sharee.addressBookHome(request)
         shareeURL = joinURL(shareeHomeResource.url(), share.name())
         shareeCollection = yield request.locateResource(shareeURL)
-        shareeCollection.setShareeCollection(share)
+        shareeCollection.setShare(share)
 
         # Set per-user displayname or color to whatever was given
         if displayname:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120817/4bbeb6bc/attachment.html>


More information about the calendarserver-changes mailing list