[CalendarServer-changes] [7018] 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:21 PST 2011
Revision: 7018
http://trac.macosforge.org/projects/calendarserver/changeset/7018
Author: glyph at apple.com
Date: 2011-02-16 06:42:21 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
dalify NotificationObject.loadAllObjects
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:11 UTC (rev 7017)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py 2011-02-16 14:42:21 UTC (rev 7018)
@@ -2581,6 +2581,8 @@
"_home",
)
+ _objectSchema = schema.NOTIFICATION
+
def __init__(self, home, uid):
self._home = home
self._resourceID = None
@@ -2592,10 +2594,25 @@
self._xmlType = None
self._objectText = None
+
def __repr__(self):
return "<%s: %s>" % (self.__class__.__name__, self._resourceID)
+ @classproperty
+ def _allColumnsByHomeIDQuery(cls):
+ """
+ DAL query to load all columns by home ID.
+ """
+ obj = cls._objectSchema
+ return Select([obj.RESOURCE_ID, obj.NOTIFICATION_UID, obj.MD5,
+ Len(obj.XML_DATA), obj.XML_TYPE, obj.CREATED,
+ obj.MODIFIED],
+ From=obj,
+ Where=(obj.NOTIFICATION_HOME_RESOURCE_ID == Parameter(
+ "homeID")))
+
+
@classmethod
@inlineCallbacks
def loadAllObjects(cls, parent):
@@ -2609,20 +2626,9 @@
results = []
# Load from the main table first
- dataRows = (yield parent._txn.execSQL("""
- select
- RESOURCE_ID,
- NOTIFICATION_UID,
- MD5,
- character_length(XML_DATA),
- XML_TYPE,
- CREATED,
- MODIFIED
- from NOTIFICATION
- where NOTIFICATION_HOME_RESOURCE_ID = %s
- """,
- [parent._resourceID]
- ))
+ dataRows = (
+ yield cls._allColumnsByHomeIDQuery.on(parent._txn,
+ homeID=parent._resourceID))
if dataRows:
# Get property stores for all these child resources (if any found)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/cec12a2c/attachment-0001.html>
More information about the calendarserver-changes
mailing list