[CalendarServer-changes] [7000] CalendarServer/branches/users/glyph/dalify/txdav
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 16 06:39:00 PST 2011
Revision: 7000
http://trac.macosforge.org/projects/calendarserver/changeset/7000
Author: glyph at apple.com
Date: 2011-02-16 06:39:00 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
dalify all-columns query
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:38:48 UTC (rev 6999)
+++ CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py 2011-02-16 14:39:00 UTC (rev 7000)
@@ -65,6 +65,7 @@
from twext.enterprise.dal.syntax import Delete
from twext.enterprise.dal.syntax import Parameter
from twext.enterprise.dal.syntax import utcNowSQL
+from twext.enterprise.dal.syntax import Len
from txdav.common.icommondatastore import IndexedSearchException
from vobject.icalendar import utc
@@ -331,6 +332,7 @@
implements(ICalendarObject)
_objectTable = CALENDAR_OBJECT_TABLE
+ _objectSchema = schema.CALENDAR_OBJECT
def __init__(self, calendar, name, uid, resourceID=None, metadata=None):
@@ -347,10 +349,6 @@
@classmethod
def _selectAllColumns(cls):
- """
- Full set of columns in the object table that need to be loaded to
- initialize the object resource state.
- """
return """
select
%(column_RESOURCE_ID)s,
@@ -369,10 +367,29 @@
%(column_MODIFIED)s
""" % cls._objectTable
+
+ _allColumns = [
+ _objectSchema.RESOURCE_ID,
+ _objectSchema.RESOURCE_NAME,
+ _objectSchema.UID,
+ _objectSchema.MD5,
+ Len(_objectSchema.TEXT),
+ _objectSchema.ATTACHMENTS_MODE,
+ _objectSchema.DROPBOX_ID,
+ _objectSchema.ACCESS,
+ _objectSchema.SCHEDULE_OBJECT,
+ _objectSchema.SCHEDULE_TAG,
+ _objectSchema.SCHEDULE_ETAGS,
+ _objectSchema.PRIVATE_COMMENTS,
+ _objectSchema.CREATED,
+ _objectSchema.MODIFIED
+ ]
+
+
def _initFromRow(self, row):
"""
- Given a select result using the columns from L{_selectAllColumns}, initialize
- the object resource state.
+ Given a select result using the columns from L{_allColumns}, initialize
+ the calendar object resource state.
"""
(self._resourceID,
self._name,
@@ -389,6 +406,7 @@
self._created,
self._modified,) = tuple(row)
+
@property
def _calendar(self):
return self._parentCollection
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:38:48 UTC (rev 6999)
+++ CalendarServer/branches/users/glyph/dalify/txdav/carddav/datastore/sql.py 2011-02-16 14:39:00 UTC (rev 7000)
@@ -194,6 +194,7 @@
implements(IAddressBookObject)
_objectTable = ADDRESSBOOK_OBJECT_TABLE
+ _objectSchema = schema.ADDRESSBOOK_OBJECT
def __init__(self, addressbook, name, uid, resourceID=None, metadata=None):
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:38:48 UTC (rev 6999)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py 2011-02-16 14:39:00 UTC (rev 7000)
@@ -66,6 +66,7 @@
from twext.enterprise.dal.syntax import Max
from twext.enterprise.dal.syntax import default
from twext.enterprise.dal.syntax import Delete
+from twext.enterprise.dal.syntax import Len
from twext.enterprise.dal.syntax import Update
from txdav.base.propertystore.base import PropertyName
@@ -2006,6 +2007,14 @@
self._objectText = None
+
+ @classproperty
+ def _allColumnsWithParent(cls):
+ obj = cls._objectSchema
+ return Select(cls._allColumns, From=obj,
+ Where=obj.PARENT_RESOURCE_ID == Parameter("parentID"))
+
+
@classmethod
@inlineCallbacks
def loadAllObjects(cls, parent):
@@ -2019,12 +2028,8 @@
results = []
# Load from the main table first
- dataRows = yield parent._txn.execSQL(cls._selectAllColumns() + """
- from %(name)s
- where %(column_PARENT_RESOURCE_ID)s = %%s
- """ % cls._objectTable,
- [parent._resourceID,]
- )
+ dataRows = yield cls._allColumnsWithParent.on(
+ parent._txn, parentID=parent._resourceID)
if dataRows:
# Get property stores for all these child resources (if any found)
@@ -2123,7 +2128,8 @@
def _selectAllColumns(cls):
"""
Full set of columns in the object table that need to be loaded to
- initialize the object resource state.
+ initialize the object resource state. (XXX: remove me, old string-based
+ version, see _allColumns)
"""
return """
select
@@ -2136,9 +2142,28 @@
%(column_MODIFIED)s
""" % cls._objectTable
+
+ @classproperty
+ def _allColumns(cls):
+ """
+ Full set of columns in the object table that need to be loaded to
+ initialize the object resource state.
+ """
+ obj = cls._objectSchema
+ return [
+ obj.RESOURCE_ID,
+ obj.RESOURCE_NAME,
+ obj.UID,
+ obj.MD5,
+ Len(obj.TEXT),
+ obj.CREATED,
+ obj.MODIFIED
+ ]
+
+
def _initFromRow(self, row):
"""
- Given a select result using the columns from L{_selectAllColumns}, initialize
+ Given a select result using the columns from L{_allColumns}, initialize
the object resource state.
"""
(self._resourceID,
@@ -2149,6 +2174,7 @@
self._created,
self._modified,) = tuple(row)
+
@inlineCallbacks
def _loadPropertyStore(self, props=None, created=False):
if props is None:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/0cfb10ff/attachment-0001.html>
More information about the calendarserver-changes
mailing list