[CalendarServer-changes] [6988] CalendarServer/branches/users/glyph/dalify/txdav/base/propertystore/ sql.py

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


Revision: 6988
          http://trac.macosforge.org/projects/calendarserver/changeset/6988
Author:   glyph at apple.com
Date:     2011-02-16 06:36:45 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
dalify property delete

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/dalify/txdav/base/propertystore/sql.py

Modified: CalendarServer/branches/users/glyph/dalify/txdav/base/propertystore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/dalify/txdav/base/propertystore/sql.py	2011-02-16 14:36:33 UTC (rev 6987)
+++ CalendarServer/branches/users/glyph/dalify/txdav/base/propertystore/sql.py	2011-02-16 14:36:45 UTC (rev 6988)
@@ -23,19 +23,16 @@
     "PropertyStore",
 ]
 
+
 from twistedcaldav.memcacher import Memcacher
 
-from twext.enterprise.dal.syntax import Select
-from twext.enterprise.dal.syntax import Parameter
-from twext.enterprise.dal.syntax import Update
-from twext.enterprise.dal.syntax import Insert
-from twext.enterprise.dal.syntax import TableSyntax
+from twext.enterprise.dal.syntax import (
+    Select, Parameter, Update, Insert, TableSyntax, Delete)
 
 from txdav.common.datastore.sql_tables import schema
+from txdav.base.propertystore.base import (AbstractPropertyStore,
+                                           PropertyName, validKey)
 
-from txdav.base.propertystore.base import (
-    AbstractPropertyStore, PropertyName, validKey)
-
 from twext.web2.dav.davxml import WebDAVDocument
 
 from twisted.internet.defer import inlineCallbacks, returnValue
@@ -183,24 +180,28 @@
         self._cacher.delete(str(self._resourceID))
 
 
+    _deleteQuery = Delete(
+        prop, Where=(prop.RESOURCE_ID == Parameter("resourceID")).And(
+            prop.NAME == Parameter("name")).And(
+                prop.VIEWER_UID == Parameter("uid"))
+    )
+
+
     def _delitem_uid(self, key, uid):
         validKey(key)
 
         key_str = key.toString()
         del self._cached[(key_str, uid)]
-        self._txn.execSQL(
-            """
-            delete from RESOURCE_PROPERTY
-            where RESOURCE_ID = %s and NAME = %s and VIEWER_UID = %s
-            """,
-            [self._resourceID, key_str, uid],
-            raiseOnZeroRowCount=lambda:KeyError(key)
-        )
+        self._deleteQuery.on(self._txn, lambda:KeyError(key),
+                             resourceID=self._resourceID,
+                             name=key_str, uid=uid
+                            )
         self._cacher.delete(str(self._resourceID))
-            
 
+
     def _keys_uid(self, uid):
-
         for cachedKey, cachedUID in self._cached.keys():
             if cachedUID == uid:
                 yield PropertyName.fromString(cachedKey)
+
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/80bd70ea/attachment.html>


More information about the calendarserver-changes mailing list