[CalendarServer-changes] [278]
CalendarServer/trunk/twistedcaldav/index.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Oct 18 15:35:16 PDT 2006
Revision: 278
http://trac.macosforge.org/projects/calendarserver/changeset/278
Author: wsanchez at apple.com
Date: 2006-10-18 15:35:15 -0700 (Wed, 18 Oct 2006)
Log Message:
-----------
resourceNameForUID() should raise if >1 resource is found; use resourceNamesForUID() instead if this isn't an error for you.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/index.py
Modified: CalendarServer/trunk/twistedcaldav/index.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/index.py 2006-10-18 21:44:58 UTC (rev 277)
+++ CalendarServer/trunk/twistedcaldav/index.py 2006-10-18 22:35:15 UTC (rev 278)
@@ -133,8 +133,7 @@
"""
Looks up the names of the resources with the given UID.
@param uid: the UID of the resources to look up.
- @return: If the resource is found, alist of the resource names; C{None}
- otherwise.
+ @return: a list of resource names
"""
names = self._db_values_for_sql("select NAME from RESOURCE where UID = :1", uid)
@@ -160,12 +159,14 @@
@param uid: the UID of the resource to look up.
@return: If the resource is found, its name; C{None} otherwise.
"""
- names = self.resourceNamesForUID(uid)
- if len(names) > 0:
- return names[0]
- else:
- return None
+ result = None
+ for name in self.resourceNamesForUID(uid):
+ assert result is None, "More than one resource with UID %s in calendar collection %r" % (uid, self)
+ result = name
+
+ return result
+
def resourceUIDForName(self, name):
"""
Looks up the UID of the resource with the given name.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061018/66540b30/attachment.html
More information about the calendarserver-changes
mailing list