[CalendarServer-changes] [7021] CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/ sql.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 16 06:42:54 PST 2011
Revision: 7021
http://trac.macosforge.org/projects/calendarserver/changeset/7021
Author: glyph at apple.com
Date: 2011-02-16 06:42:54 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
dalify NotificationObject.initFromStore
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:42:43 UTC (rev 7020)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py 2011-02-16 14:42:54 UTC (rev 7021)
@@ -2658,26 +2658,35 @@
returnValue(results)
+ @classproperty
+ def _oneNotificationQuery(cls):
+ no = cls._objectSchema
+ return Select(
+ [
+ no.RESOURCE_ID,
+ no.MD5,
+ Len(no.XML_DATA),
+ no.XML_TYPE,
+ no.CREATED,
+ no.MODIFIED
+ ],
+ From=no,
+ Where=(no.NOTIFICATION_UID ==
+ Parameter("uid")).And(no.NOTIFICATION_HOME_RESOURCE_ID ==
+ Parameter("homeID")))
+
+
@inlineCallbacks
def initFromStore(self):
"""
- Initialise this object from the store. We read in and cache all the extra metadata
- from the DB to avoid having to do DB queries for those individually later.
+ Initialise this object from the store, based on its UID and home
+ resource ID. We read in and cache all the extra metadata from the DB to
+ avoid having to do DB queries for those individually later.
@return: L{self} if object exists in the DB, else C{None}
"""
- rows = (yield self._txn.execSQL("""
- select
- RESOURCE_ID,
- MD5,
- character_length(XML_DATA),
- XML_TYPE,
- CREATED,
- MODIFIED
- from NOTIFICATION
- where NOTIFICATION_UID = %s and NOTIFICATION_HOME_RESOURCE_ID = %s
- """,
- [self._uid, self._home._resourceID]))
+ rows = (yield self._oneNotificationQuery.on(
+ self._txn, uid=self._uid, homeID=self._home._resourceID))
if rows:
(self._resourceID,
self._md5,
@@ -2690,6 +2699,7 @@
else:
returnValue(None)
+
def _loadPropertyStore(self, props=None, created=False):
if props is None:
props = NonePropertyStore(self._home.uid())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/1b18bc65/attachment-0001.html>
More information about the calendarserver-changes
mailing list