[CalendarServer-changes] [10851] CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/ datastore/sql.py

source_changes at macosforge.org source_changes at macosforge.org
Tue Mar 5 13:12:03 PST 2013


Revision: 10851
          http://trac.calendarserver.org//changeset/10851
Author:   gaya at apple.com
Date:     2013-03-05 13:12:03 -0800 (Tue, 05 Mar 2013)
Log Message:
-----------
add alt way of getting per-vcard access.  Add missing yields.

Modified Paths:
--------------
    CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/datastore/sql.py

Modified: CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/datastore/sql.py	2013-03-05 21:04:32 UTC (rev 10850)
+++ CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/datastore/sql.py	2013-03-05 21:12:03 UTC (rev 10851)
@@ -137,6 +137,7 @@
         else:
             returnValue(None)
 
+
     @inlineCallbacks
     def _loadPropertyStore(self):
         props = yield PropertyStore.load(
@@ -940,7 +941,7 @@
                 adjustedReadWriteGroupIDs = readWriteGroupIDs
             returnValue((tuple(adjustedReadOnlyGroupIDs), tuple(adjustedReadWriteGroupIDs)))
 
-    '''
+    ''' unused
     @inlineCallbacks
     def readOnlyGroupIDs(self):
         returnValue((yield self.accessControlGroupIDs())[0])
@@ -951,7 +952,56 @@
         returnValue((yield self.accessControlGroupIDs())[1])
 
 
+    ''' unused: may be good for future caching
     @inlineCallbacks
+    def accessControlObjectIDs(self):
+        readOnlyIDs = set()
+        readWriteIDs = set()
+        if self.owned() or self.fullyShared():
+            rows = yield self._allColumnsWithParent(self)
+            ids = set([row[1] for row in rows])
+            if self.fullyShared():
+                ids |= set([self._resourceID, ])
+            if self.owned() or self._bindMode == _BIND_MODE_WRITE:
+                returnValue(tuple(readOnlyIDs), tuple(readWriteIDs))
+            readOnlyIDs = set(ids)
+
+        groupBindRows = yield AddressBookObject._acceptedBindWithHomeIDAndAddressBookID.on(
+                self._txn, homeID=self._home._resourceID, addressbookID=self._resourceID
+        )
+        readWriteGroupIDs = []
+        readOnlyGroupIDs = []
+        for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in groupBindRows: #@UnusedVariable
+            if bindMode == _BIND_MODE_WRITE:
+                readWriteGroupIDs.append(resourceID)
+            else:
+                readOnlyGroupIDs.append(resourceID)
+
+        if readOnlyGroupIDs:
+            readOnlyIDs |= set((yield self.expandGroupIDs(self._txn, readOnlyGroupIDs)))
+        if readWriteGroupIDs:
+            readWriteIDs |= set((yield self.expandGroupIDs(self._txn, readWriteGroupIDs)))
+        readOnlyIDs -= readWriteIDs
+        returnValue(tuple(readOnlyIDs), tuple(readWriteIDs))
+
+
+    @inlineCallbacks
+    def readOnlyObjectIDs(self):
+        returnValue((yield self.accessControlObjectIDs())[1])
+
+
+    @inlineCallbacks
+    def readWriteObjectIDs(self):
+        returnValue((yield self.accessControlObjectIDs())[1])
+
+
+    @inlineCallbacks
+    def allObjectIDs(self):
+        readOnlyIDs, readWriteIDs = yield self.accessControlObjectIDs()
+        returnValue((readOnlyIDs + readWriteIDs))
+    '''
+
+    @inlineCallbacks
     def updateShare(self, shareeView, mode=None, status=None, message=None, name=None):
         """
         Update share mode, status, and message for a home child shared with
@@ -1450,7 +1500,7 @@
             if addressbook.fullyShared():
                 rows.append((yield addressbook._groupForEntireAB_Row()))
         else:
-            acceptedGroupIDs = addressbook.acceptedGroupIDs()
+            acceptedGroupIDs = yield addressbook.acceptedGroupIDs()
             allowedObjectIDs = yield addressbook.expandGroupIDs(addressbook._txn, acceptedGroupIDs)
             rows = yield cls._columnsWithResourceIDsQuery(cls._allColumns, allowedObjectIDs).on(
                 addressbook._txn, resourceIDs=allowedObjectIDs
@@ -1475,7 +1525,7 @@
             if addressbook.fullyShared() and (yield addressbook._groupForEntireAB_Name()) in names:
                 rows.append((yield addressbook._groupForEntireAB_Row()))
         else:
-            acceptedGroupIDs = addressbook.acceptedGroupIDs()
+            acceptedGroupIDs = yield addressbook.acceptedGroupIDs()
             allowedObjectIDs = yield addressbook.expandGroupIDs(addressbook._txn, acceptedGroupIDs)
             rows = yield cls._allColumnsWithResourceIDsAndNamesQuery(allowedObjectIDs, names).on(
                 addressbook._txn, resourceIDs=allowedObjectIDs, names=names
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130305/0fadf7ed/attachment-0001.html>


More information about the calendarserver-changes mailing list