[CalendarServer-changes] [7004] CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/ sql.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 16 06:39:47 PST 2011


Revision: 7004
          http://trac.macosforge.org/projects/calendarserver/changeset/7004
Author:   glyph at apple.com
Date:     2011-02-16 06:39:47 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
dalify the rest of notificationsWithUID

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py

Modified: CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py	2011-02-16 14:39:36 UTC (rev 7003)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py	2011-02-16 14:39:47 UTC (rev 7004)
@@ -49,7 +49,7 @@
 from txdav.carddav.iaddressbookstore import IAddressBookTransaction
 
 from txdav.common.datastore.sql_tables import schema
-from txdav.common.datastore.sql_tables import NOTIFICATION_HOME_TABLE, _BIND_MODE_OWN, \
+from txdav.common.datastore.sql_tables import _BIND_MODE_OWN, \
     _BIND_STATUS_ACCEPTED, NOTIFICATION_OBJECT_REVISIONS_TABLE
 from txdav.common.icommondatastore import HomeChildNameNotAllowedError, \
     HomeChildNameAlreadyExistsError, NoSuchHomeChildError, \
@@ -2345,23 +2345,24 @@
         [_homeSchema.RESOURCE_ID], From=_homeSchema,
         Where=_homeSchema.OWNER_UID == Parameter("uid"))
 
+    _provisionNewNotificationsQuery = Insert(
+        {_homeSchema.OWNER_UID: Parameter("uid")},
+        Return=_homeSchema.RESOURCE_ID
+    )
+
+
     @classmethod
     @inlineCallbacks
     def notificationsWithUID(cls, txn, uid):
-        """
-        Implement notificationsWithUID.
-        """
-
         rows = yield cls._resourceIDFromUIDQuery.on(txn, uid=uid)
 
         if rows:
             resourceID = rows[0][0]
             created = False
         else:
-            resourceID = str((yield txn.execSQL(
-                "insert into %(name)s (%(column_OWNER_UID)s) values (%%s) returning %(column_RESOURCE_ID)s" % NOTIFICATION_HOME_TABLE,
-                [uid]
-            ))[0][0])
+            resourceID = str((
+                yield cls._provisionNewNotificationsQuery.on(txn, uid=uid)
+            )[0][0])
             created = True
         collection = cls(txn, uid, resourceID)
         yield collection._loadPropertyStore()
@@ -2369,6 +2370,7 @@
             yield collection._initSyncToken()
         returnValue(collection)
 
+
     @inlineCallbacks
     def _loadPropertyStore(self):
         self._propertyStore = yield PropertyStore.load(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/2164fdeb/attachment.html>


More information about the calendarserver-changes mailing list