[CalendarServer-changes] [10067] CalendarServer/branches/users/glyph/one-home-list-api

source_changes at macosforge.org source_changes at macosforge.org
Fri Nov 16 14:49:09 PST 2012


Revision: 10067
          http://trac.calendarserver.org//changeset/10067
Author:   glyph at apple.com
Date:     2012-11-16 14:49:08 -0800 (Fri, 16 Nov 2012)
Log Message:
-----------
Refactor.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/one-home-list-api/txdav/common/datastore/sql.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/one-home-list-api/

Modified: CalendarServer/branches/users/glyph/one-home-list-api/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/one-home-list-api/txdav/common/datastore/sql.py	2012-11-16 22:49:07 UTC (rev 10066)
+++ CalendarServer/branches/users/glyph/one-home-list-api/txdav/common/datastore/sql.py	2012-11-16 22:49:08 UTC (rev 10067)
@@ -195,16 +195,17 @@
 
 
     @inlineCallbacks
-    def withEachCalendarHomeDo(self, action, batchSize=None):
+    def _withEachHomeDo(self, homeTable, homeFromTxn, action, batchSize):
         """
-        Implementation of L{ICalendarStore.withEachCalendarHomeDo}.
+        Implementation of L{ICalendarStore.withEachCalendarHomeDo} and
+        L{IAddressbookStore.withEachAddressbookHomeDo}.
         """
         txn = yield self.newTransaction()
-        allUIDs = yield Select([schema.CALENDAR_HOME.OWNER_UID],
-                               From=schema.CALENDAR_HOME).on(txn)
         try:
+            allUIDs = yield (Select([homeTable.OWNER_UID], From=homeTable)
+                             .on(txn))
             for [uid] in allUIDs:
-                yield action(txn, (yield txn.calendarHomeWithUID(uid)))
+                yield action(txn, (yield homeFromTxn(txn, uid)))
         except:
             a, b, c = sys.exc_info()
             yield txn.abort()
@@ -213,6 +214,17 @@
             yield txn.commit()
 
 
+    def withEachCalendarHomeDo(self, action, batchSize=None):
+        """
+        Implementation of L{ICalendarStore.withEachCalendarHomeDo}.
+        """
+        return self._withEachHomeDo(
+            schema.CALENDAR_HOME,
+            lambda txn, uid: txn.calendarHomeWithUID(uid),
+            action, batchSize
+        )
+
+
     def newTransaction(self, label="unlabeled", disableCache=False):
         """
         @see: L{IDataStore.newTransaction}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121116/e32977ce/attachment.html>


More information about the calendarserver-changes mailing list