[CalendarServer-changes] [1219]
CalendarServer/branches/users/cdaboo/sqlprops-1202/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Tue Feb 20 11:11:38 PST 2007
Revision: 1219
http://trac.macosforge.org/projects/calendarserver/changeset/1219
Author: cdaboo at apple.com
Date: 2007-02-20 11:11:38 -0800 (Tue, 20 Feb 2007)
Log Message:
-----------
Add option to delete several properties on a resource in one go.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/sqlprops-1202/twistedcaldav/sqlprops.py
CalendarServer/branches/users/cdaboo/sqlprops-1202/twistedcaldav/test/test_sqlprops.py
Modified: CalendarServer/branches/users/cdaboo/sqlprops-1202/twistedcaldav/sqlprops.py
===================================================================
--- CalendarServer/branches/users/cdaboo/sqlprops-1202/twistedcaldav/sqlprops.py 2007-02-20 18:23:30 UTC (rev 1218)
+++ CalendarServer/branches/users/cdaboo/sqlprops-1202/twistedcaldav/sqlprops.py 2007-02-20 19:11:38 UTC (rev 1219)
@@ -165,6 +165,18 @@
if self.index:
self.index.removeProperty(self.rname, qname)
+ def deleteSeveral(self, properties):
+ """
+ Delete proeprty from index.
+
+ DELETE from PROPERTIES where NAME=<<rname>> and PROPNAME=<<pname>> ...
+
+ @param qname:
+ """
+
+ if self.index:
+ self.index.removeSeveralProperties(self.rname, [p.qname() for p in properties])
+
def deleteAll(self):
"""
Delete property from index.
@@ -357,13 +369,26 @@
Remove a property.
@param rname: a C{str} containing the resource name.
- @param pname: a C{str} containing the name of the property to get.
+ @param pname: a C{str} containing the name of the property to remove.
@return: a C{str} containing the property value.
"""
self._delete_from_db(rname, self._encode(pname))
self._db_commit()
+ def removeSeveralProperties(self, rname, pnames):
+ """
+ Remove specified properties.
+
+ @param rname: a C{str} containing the resource name.
+ @param pnames: a C{list} containing the names of the properties to remove.
+ @return: a C{str} containing the property value.
+ """
+
+ for pname in pnames:
+ self._delete_from_db(rname, self._encode(pname))
+ self._db_commit()
+
def removeResource(self, rname):
"""
Remove all properties for resource.
Modified: CalendarServer/branches/users/cdaboo/sqlprops-1202/twistedcaldav/test/test_sqlprops.py
===================================================================
--- CalendarServer/branches/users/cdaboo/sqlprops-1202/twistedcaldav/test/test_sqlprops.py 2007-02-20 18:23:30 UTC (rev 1218)
+++ CalendarServer/branches/users/cdaboo/sqlprops-1202/twistedcaldav/test/test_sqlprops.py 2007-02-20 19:11:38 UTC (rev 1219)
@@ -171,6 +171,19 @@
self.assertTrue(proplist == expected_proplist,
msg="Property lists do not match: %s != %s." % (proplist, expected_proplist))
+ def test_deleteseveralproperties(self):
+ index = self._setUpIndex()
+ for prop in SQLProps.props:
+ self._setProperty(index, prop)
+
+ delete_props = SQLProps.props[:2]
+ remaining_props = SQLProps.props[2:]
+ index.deleteSeveral(delete_props)
+ proplist = set(index.list())
+ expected_proplist = set([prop.qname() for prop in remaining_props])
+ self.assertTrue(proplist == expected_proplist,
+ msg="Property lists do not match: %s != %s." % (proplist, expected_proplist))
+
def test_deleteallproperties(self):
index = self._setUpIndex()
for prop in SQLProps.props:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070220/d2bb90f9/attachment.html
More information about the calendarserver-changes
mailing list