[CalendarServer-changes] [12251] twext/trunk/twext/who/opendirectory

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 11:20:05 PDT 2014


Revision: 12251
          http://trac.calendarserver.org//changeset/12251
Author:   wsanchez at apple.com
Date:     2014-01-06 18:40:28 -0800 (Mon, 06 Jan 2014)
Log Message:
-----------
Support NOT flag in _queryStringFromMatchExpression.
_queryFromMatchExpression() raises NotImplementedError in that case now.

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

Modified: twext/trunk/twext/who/opendirectory/_constants.py
===================================================================
--- twext/trunk/twext/who/opendirectory/_constants.py	2014-01-07 02:15:58 UTC (rev 12250)
+++ twext/trunk/twext/who/opendirectory/_constants.py	2014-01-07 02:40:28 UTC (rev 12251)
@@ -389,39 +389,39 @@
 
 class ODMatchType(Values):
     all = ValueConstant(0x0001)
-    all.queryString = u"({attribute}=*)"
+    all.queryString = u"({notOp}{attribute}=*)"
 
     equals = ValueConstant(0x2001)
     equals.matchType = MatchType.equals
-    equals.queryString = u"({attribute}={value})"
+    equals.queryString = u"({notOp}{attribute}={value})"
 
     startsWith = ValueConstant(0x2002)
     startsWith.matchType = MatchType.startsWith
-    startsWith.queryString = u"({attribute}={value}*)"
+    startsWith.queryString = u"({notOp}{attribute}={value}*)"
 
     endsWith = ValueConstant(0x2003)
     endsWith.matchType = MatchType.endsWith
-    endsWith.queryString = u"({attribute}=*{value})"
+    endsWith.queryString = u"({notOp}{attribute}=*{value})"
 
     contains = ValueConstant(0x2004)
     contains.matchType = MatchType.contains
-    contains.queryString = u"({attribute}=*{value}*)"
+    contains.queryString = u"({notOp}{attribute}=*{value}*)"
 
     lessThan = ValueConstant(0x2005)
     lessThan.matchType = MatchType.lessThan
-    lessThan.queryString = u"({attribute}<{value})"
+    lessThan.queryString = u"({notOp}{attribute}<{value})"
 
     greaterThan = ValueConstant(0x2006)
     greaterThan.matchType = MatchType.greaterThan
-    greaterThan.queryString = u"({attribute}>{value})"
+    greaterThan.queryString = u"({notOp}{attribute}>{value})"
 
     lessThanOrEqualTo = ValueConstant(0x2007)
     lessThanOrEqualTo.matchType = MatchType.lessThanOrEqualTo
-    lessThanOrEqualTo.queryString = u"({attribute}<={value})"
+    lessThanOrEqualTo.queryString = u"({notOp}{attribute}<={value})"
 
     greaterThanOrEqualTo = ValueConstant(0x2008)
     greaterThanOrEqualTo.matchType = MatchType.greaterThanOrEqualTo
-    greaterThanOrEqualTo.queryString = u"({attribute}>={value})"
+    greaterThanOrEqualTo.queryString = u"({notOp}{attribute}>={value})"
 
     compound = ValueConstant(0x210B)
 

Modified: twext/trunk/twext/who/opendirectory/_service.py
===================================================================
--- twext/trunk/twext/who/opendirectory/_service.py	2014-01-07 02:15:58 UTC (rev 12250)
+++ twext/trunk/twext/who/opendirectory/_service.py	2014-01-07 02:40:28 UTC (rev 12251)
@@ -245,8 +245,12 @@
             )
 
         flags = tuple(iterFlags(expression.flags))
+
         if MatchFlags.NOT in flags:
-            raise NotImplementedError("Need to handle NOT")
+            notOp = u"!"
+        else:
+            notOp = u""
+
         if MatchFlags.caseInsensitive in flags:
             raise NotImplementedError("Need to handle caseInsensitive")
 
@@ -266,7 +270,7 @@
 
         # FIXME: Shouldn't the value be quoted somehow?
         return matchType.queryString.format(
-            attribute=odAttr.value, value=value
+            notOp=notOp, attribute=odAttr.value, value=value
         )
 
 
@@ -385,7 +389,12 @@
             )
         matchType = matchType.value
 
-        if MatchFlags.caseInsensitive in iterFlags(expression.flags):
+        flags = tuple(iterFlags(expression.flags))
+
+        if MatchFlags.NOT in flags:
+            raise NotImplementedError()
+
+        if MatchFlags.caseInsensitive in flags:
             caseInsensitive = 0x100
         else:
             caseInsensitive = 0x0

Modified: twext/trunk/twext/who/opendirectory/test/test_service.py
===================================================================
--- twext/trunk/twext/who/opendirectory/test/test_service.py	2014-01-07 02:15:58 UTC (rev 12250)
+++ twext/trunk/twext/who/opendirectory/test/test_service.py	2014-01-07 02:40:28 UTC (rev 12251)
@@ -83,9 +83,7 @@
             )
         )
 
-    test_queryStringFromMatchExpression_match_not.todo = "unimplemented"
 
-
     def test_queryStringFromMatchExpression_match_caseInsensitive(self):
         """
         Match expression with the C{caseInsensitive} flag adds the C{??????}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/81c40610/attachment.html>


More information about the calendarserver-changes mailing list