[CalendarServer-changes] [10807] CalendarServer/branches/users/gaya/sharedgroups/txdav

source_changes at macosforge.org source_changes at macosforge.org
Mon Feb 25 19:57:58 PST 2013


Revision: 10807
          http://trac.calendarserver.org//changeset/10807
Author:   gaya at apple.com
Date:     2013-02-25 19:57:58 -0800 (Mon, 25 Feb 2013)
Log Message:
-----------
clean up

Modified Paths:
--------------
    CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/datastore/sql.py
    CalendarServer/branches/users/gaya/sharedgroups/txdav/common/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-02-26 00:17:15 UTC (rev 10806)
+++ CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/datastore/sql.py	2013-02-26 03:57:58 UTC (rev 10807)
@@ -296,7 +296,6 @@
     @inlineCallbacks
     def remove(self):
 
-        print("removeChildWithName:%s, name=%s" % (self, self.name()))
         if self._resourceID == self._home._resourceID:
 
             # allow remove, as a way to reset the address book to an empty state
@@ -368,7 +367,7 @@
 
 
     @classmethod
-    def _abObjectColumnsWithAddressBookResourceID(cls, columns,): #@NoSelf
+    def _abObjectColumnsWithAddressBookResourceID(cls, columns):
         """
         DAL statement to retrieve addressbook object rows with given columns.
         """
@@ -590,6 +589,7 @@
 
                 for attr, value in zip(cls.metadataAttributes(), metadata):
                     setattr(child, attr, value)
+                #FIXME
                 child._syncTokenRevision = revisions[resourceID]
                 propstore = propertyStores.get(resourceID, None)
 
@@ -854,7 +854,7 @@
 
 
     @classmethod
-    def _memberIDsWithGroupIDsQuery(cls, groupIDs): #@NoSelf
+    def _memberIDsWithGroupIDsQuery(cls, groupIDs):
         """
         DAL query to load all object resource names for a home child.
         """
@@ -1180,7 +1180,7 @@
 
 
     @classmethod
-    def _deleteMembersWithMemberIDAndGroupIDsQuery(cls, memberID, groupIDs): #@NoSelf
+    def _deleteMembersWithMemberIDAndGroupIDsQuery(cls, memberID, groupIDs):
         aboMembers = schema.ABO_MEMBERS
         return Delete(
             aboMembers,
@@ -1257,12 +1257,12 @@
 
 
     @classmethod
-    def _allColumnsWithResourceIDsAndName(cls, resourceIDs): #@NoSelf
+    def _allColumnsWithResourceIDsAndName(cls, resourceIDs):
         return cls._allColumnsWithResourceIDsAnd(resourceIDs, cls._objectSchema.RESOURCE_NAME, "name")
 
 
     @classmethod
-    def _allColumnsWithResourceIDsAndUID(cls, resourceIDs): #@NoSelf
+    def _allColumnsWithResourceIDsAndUID(cls, resourceIDs):
         return cls._allColumnsWithResourceIDsAnd(resourceIDs, cls._objectSchema.UID, "uid")
 
 
@@ -1405,7 +1405,7 @@
 
 
     @classmethod
-    def _columnsWithResourceIDsQuery(cls, columns, resourceIDs): #@NoSelf
+    def _columnsWithResourceIDsQuery(cls, columns, resourceIDs):
         """
         DAL statement to retrieve addressbook object rows with given columns.
         """
@@ -1416,7 +1416,7 @@
 
     @classmethod
     @inlineCallbacks
-    def _allColumnsWithParent(cls, addressbook): #@NoSelf
+    def _allColumnsWithParent(cls, addressbook):
         if addressbook.owned() or addressbook.fullyShared():
             rows = yield super(AddressBookObject, cls)._allColumnsWithParent(addressbook)
             if addressbook.fullyShared():
@@ -1431,7 +1431,7 @@
 
 
     @classmethod
-    def _allColumnsWithResourceIDsAndNamesQuery(cls, resourceIDs, names): #@NoSelf
+    def _allColumnsWithResourceIDsAndNamesQuery(cls, resourceIDs, names):
         obj = cls._objectSchema
         return Select(cls._allColumns, From=obj,
                       Where=(obj.RESOURCE_ID.In(Parameter("resourceIDs", len(resourceIDs))).And(
@@ -1440,7 +1440,7 @@
 
     @classmethod
     @inlineCallbacks
-    def _allColumnsWithParentAndNames(cls, addressbook, names): #@NoSelf
+    def _allColumnsWithParentAndNames(cls, addressbook, names):
 
         if addressbook.owned() or addressbook.fullyShared():
             rows = yield super(AddressBookObject, cls)._allColumnsWithParentAndNames(addressbook, names)
@@ -1489,7 +1489,7 @@
 
 
     @classmethod
-    def _resourceIDAndUIDForUIDsAndAddressBookResourceIDQuery(cls, uids): #@NoSelf
+    def _resourceIDAndUIDForUIDsAndAddressBookResourceIDQuery(cls, uids):
         abo = schema.ADDRESSBOOK_OBJECT
         return Select([abo.RESOURCE_ID, abo.VCARD_UID],
                       From=abo,
@@ -1500,7 +1500,7 @@
 
 
     @classmethod
-    def _deleteMembersWithGroupIDAndMemberIDsQuery(cls, groupID, memberIDs): #@NoSelf
+    def _deleteMembersWithGroupIDAndMemberIDsQuery(cls, groupID, memberIDs):
         aboMembers = schema.ABO_MEMBERS
         return Delete(
             aboMembers,
@@ -1509,7 +1509,7 @@
 
 
     @classmethod
-    def _deleteForeignMembersWithGroupIDAndMembeAddrsQuery(cls, groupID, memberAddrs): #@NoSelf
+    def _deleteForeignMembersWithGroupIDAndMembeAddrsQuery(cls, groupID, memberAddrs):
         aboForeignMembers = schema.ABO_FOREIGN_MEMBERS
         return Delete(
             aboForeignMembers,
@@ -1835,8 +1835,7 @@
     @inlineCallbacks
     def ownerHomeID(cls, txn, resourceID):
 
-        # no owner, so shared item must be group
-        abo = schema.ADDRESSBOOK_OBJECT
+        abo = cls._objectSchema
         groupAddressBookRows = yield Select(
             [abo.ADDRESSBOOK_RESOURCE_ID],
             From=abo,

Modified: CalendarServer/branches/users/gaya/sharedgroups/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups/txdav/common/datastore/sql.py	2013-02-26 00:17:15 UTC (rev 10806)
+++ CalendarServer/branches/users/gaya/sharedgroups/txdav/common/datastore/sql.py	2013-02-26 03:57:58 UTC (rev 10807)
@@ -778,6 +778,7 @@
                       Where=(imip.ORGANIZER == Parameter("organizer")).And(
                              imip.ATTENDEE == Parameter("attendee")).And(
                              imip.ICALUID == Parameter("icaluid")))
+
     @classproperty
     def _updateIMIPTokenQuery(cls): #@NoSelf
         imip = schema.IMIP_TOKENS
@@ -2128,6 +2129,15 @@
             Where=(bind.HOME_RESOURCE_ID == Parameter("homeResourceID")).And(bind.BIND_STATUS != _BIND_STATUS_ACCEPTED)
         ).on(self._txn, **kwds)
 
+    @inlineCallbacks
+    def ownerHomeForChildID(self, resourceID):
+        """
+        Get the owner home for a shared child ID
+        Subclasses may override.  Currently Unused.
+        """
+        ownerHomeRows = yield self._childClass._ownerHomeWithResourceID.on(self._txn, resourceID=resourceID)
+        ownerHome = yield self._txn.homeWithResourceID(self._homeType, ownerHomeRows[0][0])
+        returnValue(ownerHome)
 
 
 class _SharedSyncLogic(object):
@@ -2462,7 +2472,7 @@
 
 
     @classmethod
-    def _bindColumns(cls): #@NoSelf
+    def _bindColumns(cls):
         bind = cls._bindSchema
         return (bind.BIND_MODE,
                 bind.HOME_RESOURCE_ID,
@@ -2473,7 +2483,7 @@
 
 
     @classmethod
-    def _bindFor(cls, condition): #@NoSelf
+    def _bindFor(cls, condition):
         bind = cls._bindSchema
         return Select(
                   cls._bindColumns(),
@@ -2582,7 +2592,7 @@
 
 
     @classmethod
-    def _updateBindColumnsQuery(cls, columnMap): #@NoSelf
+    def _updateBindColumnsQuery(cls, columnMap):
         bind = cls._bindSchema
         return Update(columnMap,
                       Where=(bind.RESOURCE_ID == Parameter("resourceID"))
@@ -2727,10 +2737,7 @@
                 yield self.unshareWith(sharedToHome)
         else:
             # This collection is shared to me
-            ownerHomeID = yield self.ownerHomeID(self._txn, self._resourceID)
-            ownerHome = yield self._txn.homeWithResourceID(self._home._homeType,
-                ownerHomeID)
-            ownerHomeChild = yield ownerHome.childWithID(self._resourceID)
+            ownerHomeChild = yield self.ownerHome().childWithID(self._resourceID)
             yield ownerHomeChild.unshareWith(self._home)
 
 
@@ -3925,7 +3932,7 @@
 
 
     @classmethod
-    def _allColumnsWithParentAndNamesQuery(cls, names): #@NoSelf
+    def _allColumnsWithParentAndNamesQuery(cls, names):
         obj = cls._objectSchema
         return Select(cls._allColumns, From=obj,
                       Where=(obj.PARENT_RESOURCE_ID == Parameter("parentID")).And(
@@ -4151,7 +4158,7 @@
 
 
     @classmethod
-    def _selectForUpdateQuery(cls, nowait): #@NoSelf
+    def _selectForUpdateQuery(cls, nowait):
         """
         DAL statement to lock a L{CommonObjectResource} by its resource ID.
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130225/9964074d/attachment-0001.html>


More information about the calendarserver-changes mailing list