[CalendarServer-changes] [6971] CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/ sql.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Feb 16 06:33:30 PST 2011
Revision: 6971
http://trac.macosforge.org/projects/calendarserver/changeset/6971
Author: glyph at apple.com
Date: 2011-02-16 06:33:29 -0800 (Wed, 16 Feb 2011)
Log Message:
-----------
dalify CommonHomeChild.rename
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:33:18 UTC (rev 6970)
+++ CalendarServer/branches/users/glyph/dalify/txdav/common/datastore/sql.py 2011-02-16 14:33:29 UTC (rev 6971)
@@ -1310,15 +1310,29 @@
return self._name
+ @classproperty
+ def _renameQuery(cls):
+ """
+ DAL statement to rename a L{CommonHomeChild}
+ """
+ bind = cls._bindSchema
+ return Update({bind.RESOURCE_NAME: Parameter("name")},
+ Where=(bind.RESOURCE_ID == Parameter("resourceID")).And(
+ bind.HOME_RESOURCE_ID == Parameter("homeID")))
+
+
@inlineCallbacks
def rename(self, name):
+ """
+ Change the name of this L{CommonHomeChild} and update its sync token to
+ reflect that change.
+
+ @return: a L{Deferred} which fires when the modification is complete.
+ """
oldName = self._name
- yield self._txn.execSQL(
- "update %(name)s set %(column_RESOURCE_NAME)s = %%s "
- "where %(column_RESOURCE_ID)s = %%s AND "
- "%(column_HOME_RESOURCE_ID)s = %%s" % self._bindTable,
- [name, self._resourceID, self._home._resourceID]
- )
+ yield self._renameQuery.on(self._txn, name=name,
+ resourceID=self._resourceID,
+ homeID=self._home._resourceID)
self._name = name
# update memos
del self._home._children[oldName]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110216/f4f1cd00/attachment.html>
More information about the calendarserver-changes
mailing list