[CalendarServer-changes] [6967] CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/ sql.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 16 06:32:45 PST 2011


Revision: 6967
          http://trac.macosforge.org/projects/calendarserver/changeset/6967
Author:   glyph at apple.com
Date:     2011-02-16 06:32:44 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
eliminate one unnecessary round trip

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:32:33 UTC (rev 6966)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py	2011-02-16 14:32:44 UTC (rev 6967)
@@ -1196,25 +1196,23 @@
     @classmethod
     @inlineCallbacks
     def create(cls, home, name):
-        
         child = (yield cls.objectWithName(home, name, owned=True))
-        if child:
+        if child is not None:
             raise HomeChildNameAlreadyExistsError(name)
 
         if name.startswith("."):
             raise HomeChildNameNotAllowedError(name)
-        
+
         # Create and initialize (in a similar manner to initFromStore) this object
-        rows = yield home._txn.execSQL("select nextval('RESOURCE_ID_SEQ')")
-        resourceID = rows[0][0]
-        _created, _modified = (yield home._txn.execSQL("""
+        resourceID, _created, _modified = (yield home._txn.execSQL(
+            """
             insert into %(name)s (%(column_RESOURCE_ID)s)
-            values (%%s)
-            returning %(column_CREATED)s, %(column_MODIFIED)s
-            """ % cls._homeChildTable,
-            [resourceID]
+            values (default)
+            returning
+            %(column_RESOURCE_ID)s, %(column_CREATED)s, %(column_MODIFIED)s
+            """ % cls._homeChildTable, []
         ))[0]
-        
+
         # Bind table needs entry
         yield home._txn.execSQL("""
             insert into %(name)s (
@@ -1243,6 +1241,7 @@
         home.notifyChanged()
         returnValue(child)
 
+
     @inlineCallbacks
     def initFromStore(self):
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/28594e35/attachment.html>


More information about the calendarserver-changes mailing list