[CalendarServer-changes] [6550] CalendarServer/branches/users/glyph/sharedpool/txdav/caldav/ datastore/sql.py

source_changes at macosforge.org source_changes at macosforge.org
Mon Nov 1 14:32:30 PDT 2010


Revision: 6550
          http://trac.macosforge.org/projects/calendarserver/changeset/6550
Author:   glyph at apple.com
Date:     2010-11-01 14:32:28 -0700 (Mon, 01 Nov 2010)
Log Message:
-----------
Parse date/time values in loseConnection as well

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/sharedpool/txdav/caldav/datastore/sql.py

Modified: CalendarServer/branches/users/glyph/sharedpool/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/sharedpool/txdav/caldav/datastore/sql.py	2010-11-01 21:32:13 UTC (rev 6549)
+++ CalendarServer/branches/users/glyph/sharedpool/txdav/caldav/datastore/sql.py	2010-11-01 21:32:28 UTC (rev 6550)
@@ -596,25 +596,31 @@
         self.attachment._contentType = self.contentType
         self.attachment._md5 = self.hash.hexdigest()
         self.attachment._size = len(self.buf)
-        self.attachment._created, self.attachment._modified = (yield self._txn.execSQL(
-            """
-            update ATTACHMENT set CONTENT_TYPE = %s, SIZE = %s, MD5 = %s,
-             MODIFIED = timezone('UTC', CURRENT_TIMESTAMP)
-            where PATH = %s
-            returning CREATED, MODIFIED
-            """,
-            [
-                generateContentType(self.contentType),
-                self.attachment._size,
-                self.attachment._md5,
-                self.attachment.name()
-            ]
-        ))[0]
+        self.attachment._created, self.attachment._modified = map(
+            sqltime,
+            (yield self._txn.execSQL(
+                """
+                update ATTACHMENT set CONTENT_TYPE = %s, SIZE = %s, MD5 = %s,
+                 MODIFIED = timezone('UTC', CURRENT_TIMESTAMP)
+                where PATH = %s
+                returning CREATED, MODIFIED
+                """,
+                [
+                    generateContentType(self.contentType),
+                    self.attachment._size,
+                    self.attachment._md5,
+                    self.attachment.name()
+                ]
+            ))[0]
+        )
 
         # Adjust quota
         yield self.attachment._calendarObject._calendar._home.adjustQuotaUsedBytes(self.attachment.size() - old_size)
 
 
+def sqltime(value):
+    return datetimeMktime(datetime.datetime.strptime(value, "%Y-%m-%d %H:%M:%S.%f"))
+
 class Attachment(object):
 
     implements(IAttachment)
@@ -648,8 +654,8 @@
         self._contentType = MimeType.fromString(rows[0][0])
         self._size = rows[0][1]
         self._md5 = rows[0][2]
-        self._created = datetimeMktime(datetime.datetime.strptime(rows[0][3], "%Y-%m-%d %H:%M:%S.%f"))
-        self._modified = datetimeMktime(datetime.datetime.strptime(rows[0][4], "%Y-%m-%d %H:%M:%S.%f"))
+        self._created = sqltime(rows[0][3])
+        self._modified = sqltime(rows[0][4])
         returnValue(self)
 
 
@@ -692,3 +698,5 @@
 
     def modified(self):
         return self._modified
+
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101101/da1a55f5/attachment-0001.html>


More information about the calendarserver-changes mailing list