[CalendarServer-changes] [6941] CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/ sql.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 16 06:27:34 PST 2011


Revision: 6941
          http://trac.macosforge.org/projects/calendarserver/changeset/6941
Author:   glyph at apple.com
Date:     2011-02-16 06:27:34 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
attachments query

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/dalify/txdav/caldav/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:27:22 UTC (rev 6940)
+++ CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py	2011-02-16 14:27:34 UTC (rev 6941)
@@ -63,6 +63,7 @@
 from twext.enterprise.dal.syntax import Insert
 from twext.enterprise.dal.syntax import Update
 from twext.enterprise.dal.syntax import Delete
+from twext.enterprise.dal.syntax import Parameter
 from txdav.common.icommondatastore import IndexedSearchException
 
 from vobject.icalendar import utc
@@ -631,12 +632,17 @@
     dropboxID = dropboxIDFromCalendarObject
 
 
+    _attachmentsQuery = Select(
+        [schema.ATTACHMENT.PATH],
+        From=schema.ATTACHMENT,
+        Where=schema.ATTACHMENT.DROPBOX_ID == Parameter('dropboxID')
+    )
+
+
     @inlineCallbacks
     def attachments(self):
-        rows = yield self._txn.execSQL(
-            """
-            select PATH from ATTACHMENT where DROPBOX_ID = %s
-            """, [self._dropboxID])
+        rows = yield self._attachmentsQuery.on(self._txn,
+                                               dropboxID=self._dropboxID)
         result = []
         for row in rows:
             result.append((yield self.attachmentWithName(row[0])))
@@ -714,11 +720,12 @@
         if home:
             # Adjust quota
             yield home.adjustQuotaUsedBytes(self.attachment.size() - old_size)
-            
+
             # Send change notification to home
             yield home.notifyChanged()
 
 
+
 def sqltime(value):
     return datetimeMktime(parseSQLTimestamp(value))
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/3894e8df/attachment.html>


More information about the calendarserver-changes mailing list