[CalendarServer-changes] [6943] 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:57 PST 2011


Revision: 6943
          http://trac.macosforge.org/projects/calendarserver/changeset/6943
Author:   glyph at apple.com
Date:     2011-02-16 06:27:57 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
dailfy insert into attachment

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:46 UTC (rev 6942)
+++ CalendarServer/branches/users/glyph/dalify/txdav/caldav/datastore/sql.py	2011-02-16 14:27:57 UTC (rev 6943)
@@ -743,10 +743,11 @@
     @classmethod
     def _attachmentPathRoot(cls, txn, dropboxID):
         attachmentRoot = txn._store.attachmentsPath
-        
+
         # Use directory hashing scheme based on MD5 of dropboxID
         hasheduid = hashlib.md5(dropboxID).hexdigest()
-        return attachmentRoot.child(hasheduid[0:2]).child(hasheduid[2:4]).child(hasheduid)
+        return attachmentRoot.child(hasheduid[0:2]).child(
+            hasheduid[2:4]).child(hasheduid)
 
 
     @classmethod
@@ -761,24 +762,18 @@
 
         # Now create the DB entry
         attachment = cls(txn, dropboxID, name, ownerHomeID)
-        yield txn.execSQL(
-            """
-            insert into ATTACHMENT
-              (CALENDAR_HOME_RESOURCE_ID, DROPBOX_ID, CONTENT_TYPE, SIZE, MD5, PATH)
-             values
-              (%s, %s, %s, %s, %s, %s)
-            """,
-            [
-                ownerHomeID,
-                dropboxID,
-                "",
-                0,
-                "",
-                name,
-            ]
-        )
+        att = schema.ATTACHMENT
+        yield Insert({
+            att.CALENDAR_HOME_RESOURCE_ID : ownerHomeID,
+            att.DROPBOX_ID                : dropboxID,
+            att.CONTENT_TYPE              : "",
+            att.SIZE                      : 0,
+            att.MD5                       : "",
+            att.PATH                      : name
+        }).on(txn)
         returnValue(attachment)
 
+
     @classmethod
     @inlineCallbacks
     def attachmentWithName(cls, txn, dropboxID, name):
@@ -786,6 +781,7 @@
         attachment = (yield attachment.initFromStore())
         returnValue(attachment)
 
+
     @inlineCallbacks
     def initFromStore(self):
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/b7eb305c/attachment.html>


More information about the calendarserver-changes mailing list