[CalendarServer-changes] [6946] CalendarServer/branches/users/glyph/dalify/txdav

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 16 06:28:33 PST 2011


Revision: 6946
          http://trac.macosforge.org/projects/calendarserver/changeset/6946
Author:   glyph at apple.com
Date:     2011-02-16 06:28:32 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
dalify home.initFromStore

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

Modified: CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py	2011-02-16 14:28:19 UTC (rev 6945)
+++ CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py	2011-02-16 14:28:32 UTC (rev 6946)
@@ -77,6 +77,10 @@
 
     implements(ICalendarHome)
 
+    # structured tables.  (new, preferred)
+    _homeSchema = schema.CALENDAR_HOME
+
+    # string mappings (old, removing)
     _homeTable = CALENDAR_HOME_TABLE
     _homeMetaDataTable = CALENDAR_HOME_METADATA_TABLE
     _childTable = CALENDAR_TABLE
@@ -181,7 +185,10 @@
     """
     implements(ICalendar)
 
+    # structured tables.  (new, preferred)
     _bindSchema = schema.CALENDAR_BIND
+
+    # string mappings (old, removing)
     _bindTable = CALENDAR_BIND_TABLE
     _homeChildTable = CALENDAR_TABLE
     _homeChildBindTable = CALENDAR_AND_CALENDAR_BIND

Modified: CalendarServer/branches/users/glyph/dalify/txdav/carddav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/carddav/datastore/sql.py	2011-02-16 14:28:19 UTC (rev 6945)
+++ CalendarServer/branches/users/glyph/dalify/txdav/carddav/datastore/sql.py	2011-02-16 14:28:32 UTC (rev 6946)
@@ -64,6 +64,10 @@
 
     implements(IAddressBookHome)
 
+    # structured tables.  (new, preferred)
+    _homeSchema = schema.ADDRESSBOOK_HOME
+
+    # string mappings (old, removing)
     _homeTable = ADDRESSBOOK_HOME_TABLE
     _homeMetaDataTable = ADDRESSBOOK_HOME_METADATA_TABLE
     _childTable = ADDRESSBOOK_TABLE
@@ -100,7 +104,10 @@
     """
     implements(IAddressBook)
 
+    # structured tables.  (new, preferred)
     _bindSchema = schema.ADDRESSBOOK_BIND
+
+    # string mappings (old, removing)
     _bindTable = ADDRESSBOOK_BIND_TABLE
     _homeChildTable = ADDRESSBOOK_TABLE
     _homeChildBindTable = ADDRESSBOOK_AND_ADDRESSBOOK_BIND

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:28:19 UTC (rev 6945)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py	2011-02-16 14:28:32 UTC (rev 6946)
@@ -25,7 +25,6 @@
     "CommonHome",
 ]
 
-import datetime
 
 from zope.interface import implements, directlyProvides
 
@@ -399,20 +398,25 @@
         for key, value in self._bindTable.iteritems():
             self._revisionBindJoinTable["BIND:%s" % (key,)] = value
 
+
+    @classproperty
+    def _resourceIDFromOwnerQuery(cls):
+        home = cls._homeSchema
+        return Select([home.RESOURCE_ID],
+                      From=home, Where=home.OWNER_UID == Parameter("ownerUID"))
+
+
     @inlineCallbacks
     def initFromStore(self, no_cache=False):
         """
-        Initialize this object from the store. We read in and cache all the extra meta-data
-        from the DB to avoid having to do DB queries for those individually later.
+        Initialize this object from the store. We read in and cache all the
+        extra meta-data from the DB to avoid having to do DB queries for those
+        individually later.
         """
-
         result = yield self._cacher.get(self._ownerUID)
         if result is None:
-            result = yield self._txn.execSQL(
-                "select %(column_RESOURCE_ID)s from %(name)s"
-                " where %(column_OWNER_UID)s = %%s" % self._homeTable,
-                [self._ownerUID]
-            )
+            result = yield self._resourceIDFromOwnerQuery.on(
+                self._txn, ownerUID=self._ownerUID)
             if result and not no_cache:
                 yield self._cacher.set(self._ownerUID, result)
 
@@ -423,6 +427,7 @@
         else:
             returnValue(None)
 
+
     @classmethod
     @inlineCallbacks
     def homeWithUID(cls, txn, uid, create=False):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/6a6d6dc5/attachment.html>


More information about the calendarserver-changes mailing list