[CalendarServer-changes] [10101] CalendarServer/branches/users/gaya/sharedgroups/twistedcaldav/ sharing.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Nov 28 12:33:58 PST 2012


Revision: 10101
          http://trac.calendarserver.org//changeset/10101
Author:   gaya at apple.com
Date:     2012-11-28 12:33:58 -0800 (Wed, 28 Nov 2012)
Log Message:
-----------
in _allInvitations() remove unused param, cache result

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

Modified: CalendarServer/branches/users/gaya/sharedgroups/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups/twistedcaldav/sharing.py	2012-11-28 18:59:12 UTC (rev 10100)
+++ CalendarServer/branches/users/gaya/sharedgroups/twistedcaldav/sharing.py	2012-11-28 20:33:58 UTC (rev 10101)
@@ -529,7 +529,7 @@
 
 
     @inlineCallbacks
-    def _allInvitations(self, includeAccepted=True):
+    def _allInvitations(self):
         """
         Get list of all invitations to this object
         
@@ -539,25 +539,25 @@
         if not self.exists():
             returnValue([])
 
-        invitedHomeChildren = yield self._newStoreObject.asInvited()
-        if includeAccepted:
+        if not hasattr(self, "_invitations"):
+
             acceptedHomeChildren = yield self._newStoreObject.asShared()
-            # remove direct shares (it might be OK not to remove these, that would be different from legacy code)
+            # remove direct shares (it might be OK not to remove these, but that would be different from legacy code)
             indirectAccceptedHomeChildren = [homeChild for homeChild in acceptedHomeChildren
                                              if homeChild.shareMode() != _BIND_MODE_DIRECT]
-            invitedHomeChildren += indirectAccceptedHomeChildren
+            invitedHomeChildren = (yield self._newStoreObject.asInvited()) + indirectAccceptedHomeChildren
 
-        invitations = [Invitation(homeChild) for homeChild in invitedHomeChildren]
-        invitations.sort(key=lambda invitation:invitation.shareeUID())
+            self._invitations = sorted([Invitation(homeChild) for homeChild in invitedHomeChildren],
+                                 key=lambda invitation:invitation.shareeUID())
 
-        returnValue(invitations)
+        returnValue(self._invitations)
 
     @inlineCallbacks
-    def _invitationForShareeUID(self, shareeUID, includeAccepted=True):
+    def _invitationForShareeUID(self, shareeUID):
         """
         Get an invitation for this sharee principal UID
         """
-        invitations = yield self._allInvitations(includeAccepted=includeAccepted)
+        invitations = yield self._allInvitations()
         for invitation in invitations:
             if invitation.shareeUID() == shareeUID:
                 returnValue(invitation)
@@ -565,11 +565,11 @@
 
 
     @inlineCallbacks
-    def _invitationForUID(self, uid, includeAccepted=True):
+    def _invitationForUID(self, uid):
         """
         Get an invitation for an invitations uid 
         """
-        invitations = yield self._allInvitations(includeAccepted=includeAccepted)
+        invitations = yield self._allInvitations()
         for invitation in invitations:
             if invitation.uid() == uid:
                 returnValue(invitation)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121128/527a730d/attachment.html>


More information about the calendarserver-changes mailing list