[CalendarServer-changes] [13608] CalendarServer/trunk/txdav/dps

source_changes at macosforge.org source_changes at macosforge.org
Wed Jun 4 15:51:50 PDT 2014


Revision: 13608
          http://trac.calendarserver.org//changeset/13608
Author:   sagen at apple.com
Date:     2014-06-04 15:51:50 -0700 (Wed, 04 Jun 2014)
Log Message:
-----------
Support NOT in recordsMatchingFields across AMP

Modified Paths:
--------------
    CalendarServer/trunk/txdav/dps/server.py
    CalendarServer/trunk/txdav/dps/test/test_client.py

Modified: CalendarServer/trunk/txdav/dps/server.py
===================================================================
--- CalendarServer/trunk/txdav/dps/server.py	2014-06-04 22:14:20 UTC (rev 13607)
+++ CalendarServer/trunk/txdav/dps/server.py	2014-06-04 22:51:50 UTC (rev 13608)
@@ -286,8 +286,18 @@
                 valueType = self._directory.fieldName.valueType(field)
                 if valueType is uuid.UUID:
                     searchTerm = uuid.UUID(searchTerm)
-            matchFlags = MatchFlags.lookupByName(matchFlags.decode("utf-8"))
+
+            matchFlags = matchFlags.decode("utf-8")
+            if matchFlags.startswith("{") and matchFlags.endswith("}"):
+                flags = MatchFlags.none
+                for flag in matchFlags[1:-1].split(","):
+                    flags |= MatchFlags.lookupByName(flag)
+                matchFlags = flags
+            else:
+                matchFlags = MatchFlags.lookupByName(matchFlags)
+
             matchType = MatchType.lookupByName(matchType.decode("utf-8"))
+
             newFields.append((fieldName, searchTerm, matchFlags, matchType))
         operand = Operand.lookupByName(operand)
         if recordType:

Modified: CalendarServer/trunk/txdav/dps/test/test_client.py
===================================================================
--- CalendarServer/trunk/txdav/dps/test/test_client.py	2014-06-04 22:14:20 UTC (rev 13607)
+++ CalendarServer/trunk/txdav/dps/test/test_client.py	2014-06-04 22:51:50 UTC (rev 13608)
@@ -234,6 +234,28 @@
 
 
     @inlineCallbacks
+    def test_recordsMatchingFields_not(self):
+        fields = (
+            (
+                u"fullNames", "anche",
+                MatchFlags.NOT | MatchFlags.caseInsensitive,
+                MatchType.contains
+            ),
+        )
+        records = (yield self.directory.recordsMatchingFields(
+            fields, operand=Operand.OR, recordType=None
+        ))
+        matchingShortNames = set()
+        for r in records:
+            for shortName in r.shortNames:
+                matchingShortNames.add(shortName)
+        self.assertTrue("sagen" in matchingShortNames)
+        self.assertTrue("dre" not in matchingShortNames)
+        self.assertTrue("wsanchez" not in matchingShortNames)
+        self.assertTrue("sanchezoffice" not in matchingShortNames)
+
+
+    @inlineCallbacks
     def test_recordsFromMatchExpression(self):
         expression = MatchExpression(
             FieldName.uid,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140604/1337ca50/attachment.html>


More information about the calendarserver-changes mailing list