[CalendarServer-changes] [6984] CalendarServer/branches/users/glyph/dalify/txdav/base/propertystore/ sql.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 16 06:35:59 PST 2011
Revision: 6984
http://trac.macosforge.org/projects/calendarserver/changeset/6984
Author: glyph at apple.com
Date: 2011-02-16 06:35:59 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
dalify update properties
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:35:49 UTC (rev 6983)
+++ CalendarServer/branches/users/glyph/dalify/txdav/base/propertystore/sql.py 2011-02-16 14:35:59 UTC (rev 6984)
@@ -27,11 +27,12 @@
from twext.enterprise.dal.syntax import Select
from twext.enterprise.dal.syntax import Parameter
+from twext.enterprise.dal.syntax import Update
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
@@ -131,6 +132,12 @@
return WebDAVDocument.fromString(value).root_element
+ _updateQuery = Update({prop.VALUE: Parameter("value")},
+ Where=(
+ prop.RESOURCE_ID == Parameter("resourceID")).And(
+ prop.NAME == Parameter("name")).And(
+ prop.VIEWER_UID == Parameter("uid")))
+
def _setitem_uid(self, key, value, uid):
validKey(key)
@@ -138,17 +145,11 @@
value_str = value.toxml()
if (key_str, uid) in self._cached:
+ self._updateQuery.on(self._txn, resourceID=self._resourceID,
+ value=value_str, name=key_str, uid=uid)
+ else:
self._txn.execSQL(
"""
- update RESOURCE_PROPERTY
- set VALUE = %s
- where RESOURCE_ID = %s and NAME = %s and VIEWER_UID = %s
- """,
- [value_str, self._resourceID, key_str, uid]
- )
- else:
- self._txn.execSQL(
- """
insert into RESOURCE_PROPERTY
(RESOURCE_ID, NAME, VALUE, VIEWER_UID)
values (%s, %s, %s, %s)
@@ -158,6 +159,7 @@
self._cached[(key_str, uid)] = value_str
self._cacher.delete(str(self._resourceID))
+
def _delitem_uid(self, key, uid):
validKey(key)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/06c56d1d/attachment-0001.html>
More information about the calendarserver-changes
mailing list