[CalendarServer-changes] [12621] twext/trunk/twext/who/opendirectory/_service.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 11:24:58 PDT 2014


Revision: 12621
          http://trac.calendarserver.org//changeset/12621
Author:   sagen at apple.com
Date:     2014-02-08 14:14:21 -0800 (Sat, 08 Feb 2014)
Log Message:
-----------
OD recordwithShortName is supposed to only return a single record

Modified Paths:
--------------
    twext/trunk/twext/who/opendirectory/_service.py

Modified: twext/trunk/twext/who/opendirectory/_service.py
===================================================================
--- twext/trunk/twext/who/opendirectory/_service.py	2014-02-08 18:48:36 UTC (rev 12620)
+++ twext/trunk/twext/who/opendirectory/_service.py	2014-02-08 22:14:21 UTC (rev 12621)
@@ -24,7 +24,7 @@
 from uuid import UUID
 from zope.interface import implementer
 
-from twisted.internet.defer import succeed, fail
+from twisted.internet.defer import succeed, fail, inlineCallbacks, returnValue
 from twisted.web.guard import DigestCredentialFactory
 
 from twext.python.log import Logger
@@ -44,7 +44,7 @@
     MatchExpression, MatchFlags,
 )
 from ..ldap._util import LDAP_QUOTING_TABLE
-from ..util import ConstantsContainer
+from ..util import ConstantsContainer, uniqueResult
 
 from ._odframework import ODSession, ODNode, ODQuery
 from ._constants import (
@@ -539,19 +539,23 @@
         return record
 
 
+    @inlineCallbacks
     def recordWithShortName(self, recordType, shortName):
         try:
             query = self._queryFromMatchExpression(
                 MatchExpression(self.fieldName.shortNames, shortName),
                 recordType=recordType
             )
-            return self._recordsFromQuery(query)
+            returnValue(
+                uniqueResult(
+                    (yield self._recordsFromQuery(query))
+                )
+            )
 
         except QueryNotSupportedError:
             # Let the superclass try
-            return BaseDirectoryService.recordWithShortName(
-                self, recordType, shortName
-            )
+            returnValue((yield BaseDirectoryService.recordWithShortName(
+                self, recordType, shortName)))
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/eb069bac/attachment.html>


More information about the calendarserver-changes mailing list