[CalendarServer-changes] [11178] CalendarServer/branches/users/gaya/sharedgroups-3

source_changes at macosforge.org source_changes at macosforge.org
Tue May 14 12:14:33 PDT 2013


Revision: 11178
          http://trac.calendarserver.org//changeset/11178
Author:   gaya at apple.com
Date:     2013-05-14 12:14:32 -0700 (Tue, 14 May 2013)
Log Message:
-----------
isShared() fixes part 1

Modified Paths:
--------------
    CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/customxml.py
    CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/storebridge.py
    CalendarServer/branches/users/gaya/sharedgroups-3/txdav/carddav/datastore/sql.py
    CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql.py

Modified: CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/customxml.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/customxml.py	2013-05-14 04:17:34 UTC (rev 11177)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/customxml.py	2013-05-14 19:14:32 UTC (rev 11178)
@@ -1460,5 +1460,7 @@
 ResourceType.sharedcalendar = ResourceType(Collection(), caldavxml.Calendar(), Shared())
 ResourceType.sharedowneraddressbook = ResourceType(Collection(), carddavxml.AddressBook(), SharedOwner())
 ResourceType.sharedaddressbook = ResourceType(Collection(), carddavxml.AddressBook(), Shared())
+ResourceType.sharedownergroup = ResourceType(SharedOwner())
+ResourceType.sharedgroup = ResourceType(Shared())
 
 ResourceType.link = ResourceType(Link())

Modified: CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/storebridge.py	2013-05-14 04:17:34 UTC (rev 11177)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/twistedcaldav/storebridge.py	2013-05-14 19:14:32 UTC (rev 11178)
@@ -3060,14 +3060,22 @@
     }
 
 
+    def resourceType(self):
+        if self.isShared():
+            return customxml.ResourceType.sharedownergroup
+        elif self.isShareeResource():
+            return customxml.ResourceType.sharedgroup
+        else:
+            return super(AddressBookObjectResource, self).resourceType()
+
+
     @inlineCallbacks
     def storeRemove(self, request):
         """
         Remove this address book object
         """
         # Handle sharing
-        wasShared = (yield self.isShared())
-        if wasShared:
+        if self.isShared():
             yield self.downgradeFromShare(request)
 
         response = (

Modified: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/carddav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/carddav/datastore/sql.py	2013-05-14 04:17:34 UTC (rev 11177)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/carddav/datastore/sql.py	2013-05-14 19:14:32 UTC (rev 11178)
@@ -896,6 +896,33 @@
         return not self.owned() and self._bindStatus == _BIND_STATUS_ACCEPTED
 
 
+    @inlineCallbacks
+    def setShared(self, shared):
+        """
+        Set an owned collection to shared or unshared state. Technically this is not useful as "shared"
+        really means it has invitees, but the current sharing spec supports a notion of a shared collection
+        that has not yet had invitees added. For the time being we will support that option by using a new
+        MESSAGE value to indicate an owned collection that is "shared".
+
+        @param shared: whether or not the owned collection is "shared"
+        @type shared: C{bool}
+        """
+        assert self.owned()
+
+        self._bindMessage = "shared" if shared else None
+
+        ''' FIXME:  Make shared persistent:  Owned group does not have a bind table
+        bind = self._bindSchema
+        yield Update(
+            {bind.MESSAGE: self._bindMessage},
+            Where=(bind.RESOURCE_ID == Parameter("resourceID"))
+                  .And(bind.HOME_RESOURCE_ID == Parameter("homeID")),
+        ).on(self._txn, resourceID=self._resourceID, homeID=self.viewerHome()._resourceID)
+        '''
+        yield self.invalidateQueryCache()
+        yield self.notifyChanged()
+
+
     @classmethod
     @inlineCallbacks
     def listObjects(cls, home):
@@ -1223,8 +1250,8 @@
             )))
             if acceptedBindCount == 1:
                 sharedAddressBook._deletedSyncToken(sharedRemoval=True)
-                shareeHome._children.pop(self.sharedAddressBook.name(), None)
-                shareeHome._children.pop(self.sharedAddressBook._resourceID, None)
+                shareeHome._children.pop(sharedAddressBook.name(), None)
+                shareeHome._children.pop(sharedAddressBook._resourceID, None)
             elif not sharedAddressBook.fullyShared():
                 #FIXME: remove objects for this group only using self.removeObjectResource
                 self._objectNames = None
@@ -2038,6 +2065,32 @@
         """
         return self._bindName
 
+    @inlineCallbacks
+    def setShared(self, shared):
+        """
+        Set an owned collection to shared or unshared state. Technically this is not useful as "shared"
+        really means it has invitees, but the current sharing spec supports a notion of a shared collection
+        that has not yet had invitees added. For the time being we will support that option by using a new
+        MESSAGE value to indicate an owned collection that is "shared".
+
+        @param shared: whether or not the owned collection is "shared"
+        @type shared: C{bool}
+        """
+        assert self.owned()
+
+        self._bindMessage = "shared" if shared else None
+
+        ''' FIXME:  Make shared persistent:  Owned address book does not have a bind table
+        bind = self._bindSchema
+        yield Update(
+            {bind.MESSAGE: self._bindMessage},
+            Where=(bind.RESOURCE_ID == Parameter("resourceID"))
+                  .And(bind.HOME_RESOURCE_ID == Parameter("homeID")),
+        ).on(self._txn, resourceID=self._resourceID, homeID=self.viewerHome()._resourceID)
+        '''
+        yield self.invalidateQueryCache()
+        yield self.notifyChanged()
+
     @classmethod
     def metadataColumns(cls):
         """

Modified: CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql.py	2013-05-14 04:17:34 UTC (rev 11177)
+++ CalendarServer/branches/users/gaya/sharedgroups-3/txdav/common/datastore/sql.py	2013-05-14 19:14:32 UTC (rev 11178)
@@ -2901,7 +2901,7 @@
         Set an owned collection to shared or unshared state. Technically this is not useful as "shared"
         really means it has invitees, but the current sharing spec supports a notion of a shared collection
         that has not yet had invitees added. For the time being we will support that option by using a new
-        BINS_STATUS value to indicate an owned collection that is "shared".
+        MESSAGE value to indicate an owned collection that is "shared".
 
         @param shared: whether or not the owned collection is "shared"
         @type shared: C{bool}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130514/4b01b9f9/attachment.html>


More information about the calendarserver-changes mailing list