[CalendarServer-changes] [10729] CalendarServer/trunk/twext/who/xml.py
source_changes at macosforge.org
source_changes at macosforge.org
Thu Feb 14 10:48:22 PST 2013
Revision: 10729
http://trac.calendarserver.org//changeset/10729
Author: wsanchez at apple.com
Date: 2013-02-14 10:48:22 -0800 (Thu, 14 Feb 2013)
Log Message:
-----------
Rework indexedRecordsFromMatchExpression() to prepare to handle other match types.
Modified Paths:
--------------
CalendarServer/trunk/twext/who/xml.py
Modified: CalendarServer/trunk/twext/who/xml.py
===================================================================
--- CalendarServer/trunk/twext/who/xml.py 2013-02-14 18:47:47 UTC (rev 10728)
+++ CalendarServer/trunk/twext/who/xml.py 2013-02-14 18:48:22 UTC (rev 10729)
@@ -39,11 +39,11 @@
from twext.who.idirectory import DirectoryServiceError
from twext.who.idirectory import NoSuchRecordError, UnknownRecordTypeError
from twext.who.idirectory import RecordType, FieldName as BaseFieldName
-from twext.who.idirectory import MatchType
+from twext.who.idirectory import MatchType, QueryFlags
from twext.who.idirectory import DirectoryQueryMatchExpression
from twext.who.directory import DirectoryService as BaseDirectoryService
from twext.who.directory import DirectoryRecord as BaseDirectoryRecord
-from twext.who.util import MergedConstants
+from twext.who.util import MergedConstants, describe
@@ -360,15 +360,23 @@
"""
fieldIndex = self.index[expression.fieldName]
- if expression.matchType != MatchType.equals:
- raise NotImplementedError("Handle MatchType != equals")
+ if expression.flags is not None:
+ raise NotImplementedError("Unknown query flags: %s" % (expression.flags,))
- if expression.flags:
- raise NotImplementedError("Handle QueryFlags")
+ if expression.matchType == MatchType.startsWith:
+ raise NotImplementedError("Handle MatchType.startsWith")
+ elif expression.matchType == MatchType.contains:
+ raise NotImplementedError("Handle MatchType.contains")
+ elif expression.matchType == MatchType.equals:
+ indexKeys = (expression.fieldValue,)
+ else:
+ raise NotImplementedError("Unknown match type: %s" % (describe(expression.matchType),))
- matchingRecords = fieldIndex.get(expression.fieldValue, ())
+ matchingRecords = set()
+ for key in indexKeys:
+ matchingRecords |= fieldIndex.get(key, frozenset())
- return succeed(frozenset(matchingRecords))
+ return succeed(matchingRecords)
def unIndexedRecordsFromMatchExpression(self, expression):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130214/30839423/attachment-0001.html>
More information about the calendarserver-changes
mailing list