<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[11909] CalendarServer/trunk/twext/who</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/11909">11909</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2013-11-07 18:14:21 -0800 (Thu, 07 Nov 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Replace recordsFromQuery() with recordsFromExpression() that can handle a CompoundExpression.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktwextwhoaggregatepy">CalendarServer/trunk/twext/who/aggregate.py</a></li>
<li><a href="#CalendarServertrunktwextwhodirectorypy">CalendarServer/trunk/twext/who/directory.py</a></li>
<li><a href="#CalendarServertrunktwextwhoidirectorypy">CalendarServer/trunk/twext/who/idirectory.py</a></li>
<li><a href="#CalendarServertrunktwextwhoindexpy">CalendarServer/trunk/twext/who/index.py</a></li>
<li><a href="#CalendarServertrunktwextwhotesttest_directorypy">CalendarServer/trunk/twext/who/test/test_directory.py</a></li>
<li><a href="#CalendarServertrunktwextwhotesttest_xmlpy">CalendarServer/trunk/twext/who/test/test_xml.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunktwextwhoaggregatepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/aggregate.py (11908 => 11909)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/aggregate.py        2013-11-08 00:36:07 UTC (rev 11908)
+++ CalendarServer/trunk/twext/who/aggregate.py        2013-11-08 02:14:21 UTC (rev 11909)
</span><span class="lines">@@ -78,10 +78,10 @@
</span><span class="cx"> return self._recordType
</span><span class="cx">
</span><span class="cx">
</span><del>- def recordsFromExpression(self, expression, records=None):
</del><ins>+ def recordsFromExpression(self, expression):
</ins><span class="cx"> ds = []
</span><span class="cx"> for service in self.services:
</span><del>- d = service.recordsFromExpression(expression, records)
</del><ins>+ d = service.recordsFromExpression(expression)
</ins><span class="cx"> ds.append(d)
</span><span class="cx">
</span><span class="cx"> def unwrapFirstError(f):
</span></span></pre></div>
<a id="CalendarServertrunktwextwhodirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/directory.py (11908 => 11909)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/directory.py        2013-11-08 00:36:07 UTC (rev 11908)
+++ CalendarServer/trunk/twext/who/directory.py        2013-11-08 02:14:21 UTC (rev 11909)
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx"> from twext.who.idirectory import FieldName, RecordType
</span><span class="cx"> from twext.who.idirectory import Operand
</span><span class="cx"> from twext.who.idirectory import IDirectoryService, IDirectoryRecord
</span><del>-from twext.who.expression import MatchExpression
</del><ins>+from twext.who.expression import CompoundExpression, MatchExpression
</ins><span class="cx"> from twext.who.util import uniqueResult, describe
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -43,25 +43,30 @@
</span><span class="cx"> """
</span><span class="cx"> Generic implementation of L{IDirectoryService}.
</span><span class="cx">
</span><del>- This is a complete implementation of L{IDirectoryService}, with support for
- the query operands in L{Operand}.
</del><ins>+ Most of the C{recordsWith*} methods call L{recordsWithFieldValue}, which in
+ turn calls L{recordsFromExpression} with a corresponding
+ L{MatchExpression}.
</ins><span class="cx">
</span><del>- The C{recordsWith*} methods are all implemented in terms of
- L{recordsWithFieldValue}, which is in turn implemented in terms of
- L{recordsFromExpression}.
- L{recordsFromQuery} is also implemented in terms of
- {recordsFromExpression}.
</del><ins>+ L{recordsFromExpression} relies on L{recordsFromNonCompoundExpression} for
+ all expression types other than L{CompoundExpression}, which it handles
+ directly.
</ins><span class="cx">
</span><del>- L{recordsFromExpression} (and therefore most uses of the other methods)
- will always fail with a L{QueryNotSupportedError}.
</del><ins>+ L{recordsFromNonCompoundExpression} (and therefore most uses of the other
+ methods) will always fail with a L{QueryNotSupportedError}.
</ins><span class="cx">
</span><del>- A subclass should therefore override L{recordsFromExpression} with an
- implementation that handles any queries that it can support and its
- superclass' implementation with any query it cannot support.
</del><ins>+ A subclass should therefore override L{recordsFromNonCompoundExpression}
+ with an implementation that handles any queries that it can support (which
+ should include L{MatchExpression}) and calls its superclass' implementation
+ with any query it cannot support.
</ins><span class="cx">
</span><del>- A subclass may override L{recordsFromQuery} if it is to support additional
- operands.
</del><ins>+ A subclass may override L{recordsFromExpression} if it is to support
+ L{CompoundExpression}s with operands other than L{Operand.AND} and
+ L{Operand.OR}.
</ins><span class="cx">
</span><ins>+ A subclass may override L{recordsFromExpression} if it is built on top
+ of a directory service that supports compound expressions, as that may be
+ more effient than relying on L{DirectoryService}'s implementation.
+
</ins><span class="cx"> L{updateRecords} and L{removeRecords} will fail with L{NotAllowedError}
</span><span class="cx"> when asked to modify data.
</span><span class="cx"> A subclass should override these methods if is to allow editing of
</span><span class="lines">@@ -108,20 +113,19 @@
</span><span class="cx"> return self.recordType.iterconstants()
</span><span class="cx">
</span><span class="cx">
</span><del>- def recordsFromExpression(self, expression, records=None):
</del><ins>+ def recordsFromNonCompoundExpression(self, expression, records=None):
</ins><span class="cx"> """
</span><del>- Finds records matching a single expression.
</del><ins>+ Finds records matching a expression.
</ins><span class="cx">
</span><del>- @note: The implementation in L{DirectoryService} always raises
- L{QueryNotSupportedError}.
</del><ins>+ @note: This method is called by L{recordsFromExpression} to handle
+ all expressions other than L{CompoundExpression}.
+ This implementation always fails with L{QueryNotSupportedError}.
+ Subclasses should override this in order to handle additional
+ expression types, and call on the superclass' implementation
+ for other expression types.
</ins><span class="cx">
</span><del>- @note: This L{DirectoryService} adds a C{records} keyword argument to
- the interface defined by L{IDirectoryService}.
- This allows the implementation of
- L{DirectoryService.recordsFromQuery} to narrow the scope of records
- being searched as it applies expressions.
- This is therefore relevant to subclasses, which need to support the
- added parameter, but not to users of L{IDirectoryService}.
</del><ins>+ @note: This interface is the same as L{recordsFromExpression}, except
+ for the additional C{records} argument.
</ins><span class="cx">
</span><span class="cx"> @param expression: an expression to apply
</span><span class="cx"> @type expression: L{object}
</span><span class="lines">@@ -142,44 +146,55 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>- def recordsFromQuery(self, expressions, operand=Operand.AND):
- expressionIterator = iter(expressions)
</del><ins>+ def recordsFromExpression(self, expression):
+ if isinstance(expression, CompoundExpression):
+ operand = expression.operand
+ subExpressions = iter(expression.expressions)
</ins><span class="cx">
</span><del>- try:
- expression = expressionIterator.next()
- except StopIteration:
- returnValue(())
</del><ins>+ try:
+ subExpression = subExpressions.next()
+ except StopIteration:
+ returnValue(())
</ins><span class="cx">
</span><del>- results = set((yield self.recordsFromExpression(expression)))
</del><ins>+ results = set((
+ yield self.recordsFromNonCompoundExpression(subExpression)
+ ))
</ins><span class="cx">
</span><del>- for expression in expressions:
- if operand == Operand.AND:
- if not results:
- # No need to bother continuing here
- returnValue(())
</del><ins>+ for subExpression in subExpressions:
+ if operand == Operand.AND:
+ if not results:
+ # No need to bother continuing here
+ returnValue(())
</ins><span class="cx">
</span><del>- records = results
- else:
- records = None
</del><ins>+ records = results
+ else:
+ records = None
</ins><span class="cx">
</span><del>- recordsMatchingExpression = frozenset((
- yield self.recordsFromExpression(expression, records=records)
- ))
</del><ins>+ recordsMatchingExpression = frozenset((
+ yield self.recordsFromNonCompoundExpression(
+ subExpression,
+ records=records
+ )
+ ))
</ins><span class="cx">
</span><del>- if operand == Operand.AND:
- results &= recordsMatchingExpression
- elif operand == Operand.OR:
- results |= recordsMatchingExpression
- else:
- raise QueryNotSupportedError(
- "Unknown operand: {0}".format(operand)
- )
</del><ins>+ if operand == Operand.AND:
+ results &= recordsMatchingExpression
+ elif operand == Operand.OR:
+ results |= recordsMatchingExpression
+ else:
+ raise QueryNotSupportedError(
+ "Unknown operand: {0}".format(operand)
+ )
+ else:
+ results = yield self.recordsFromNonCompoundExpression(expression)
</ins><span class="cx">
</span><span class="cx"> returnValue(results)
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> def recordsWithFieldValue(self, fieldName, value):
</span><del>- return self.recordsFromExpression(MatchExpression(fieldName, value))
</del><ins>+ return self.recordsFromExpression(
+ MatchExpression(fieldName, value)
+ )
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="lines">@@ -202,10 +217,17 @@
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def recordWithShortName(self, recordType, shortName):
</span><del>- returnValue(uniqueResult((yield self.recordsFromQuery((
- MatchExpression(FieldName.recordType, recordType),
- MatchExpression(FieldName.shortNames, shortName),
- )))))
</del><ins>+ returnValue(uniqueResult((
+ yield self.recordsFromExpression(
+ CompoundExpression(
+ (
+ MatchExpression(FieldName.recordType, recordType),
+ MatchExpression(FieldName.shortNames, shortName),
+ ),
+ operand=Operand.AND
+ )
+ )
+ )))
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> def recordsWithEmailAddress(self, emailAddress):
</span></span></pre></div>
<a id="CalendarServertrunktwextwhoidirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/idirectory.py (11908 => 11909)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/idirectory.py        2013-11-08 00:36:07 UTC (rev 11908)
+++ CalendarServer/trunk/twext/who/idirectory.py        2013-11-08 02:14:21 UTC (rev 11909)
</span><span class="lines">@@ -249,7 +249,7 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx">
</span><del>- def recordsFromExpression(self, expression):
</del><ins>+ def recordsFromExpression(expression):
</ins><span class="cx"> """
</span><span class="cx"> Find records matching an expression.
</span><span class="cx">
</span><span class="lines">@@ -264,25 +264,6 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx">
</span><del>- def recordsFromQuery(expressions, operand=Operand.AND):
- """
- Find records by composing a query consisting of an iterable of
- expressions and an operand.
-
- @param expressions: expressions to query against
- @type expressions: iterable of L{object}s
-
- @param operand: an operand
- @type operand: a L{NamedConstant}
-
- @return: The matching records.
- @rtype: deferred iterable of L{IDirectoryRecord}s
-
- @raises: L{QueryNotSupportedError} if the query is not
- supported by this directory service.
- """
-
-
</del><span class="cx"> def recordsWithFieldValue(fieldName, value):
</span><span class="cx"> """
</span><span class="cx"> Find records that have the given field name with the given
</span></span></pre></div>
<a id="CalendarServertrunktwextwhoindexpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/index.py (11908 => 11909)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/index.py        2013-11-08 00:36:07 UTC (rev 11908)
+++ CalendarServer/trunk/twext/who/index.py        2013-11-08 02:14:21 UTC (rev 11909)
</span><span class="lines">@@ -215,7 +215,7 @@
</span><span class="cx"> return succeed(result)
</span><span class="cx">
</span><span class="cx">
</span><del>- def recordsFromExpression(self, expression, records=None):
</del><ins>+ def recordsFromNonCompoundExpression(self, expression, records=None):
</ins><span class="cx"> if isinstance(expression, MatchExpression):
</span><span class="cx"> if expression.fieldName in self.indexedFields:
</span><span class="cx"> return self.indexedRecordsFromMatchExpression(
</span><span class="lines">@@ -226,7 +226,7 @@
</span><span class="cx"> expression, records=records
</span><span class="cx"> )
</span><span class="cx"> else:
</span><del>- return BaseDirectoryService.recordsFromExpression(
</del><ins>+ return BaseDirectoryService.recordsFromNonCompoundExpression(
</ins><span class="cx"> self, expression, records=records
</span><span class="cx"> )
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServertrunktwextwhotesttest_directorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/test/test_directory.py (11908 => 11909)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/test/test_directory.py        2013-11-08 00:36:07 UTC (rev 11908)
+++ CalendarServer/trunk/twext/who/test/test_directory.py        2013-11-08 02:14:21 UTC (rev 11909)
</span><span class="lines">@@ -27,10 +27,10 @@
</span><span class="cx"> from twext.who.idirectory import QueryNotSupportedError, NotAllowedError
</span><span class="cx"> from twext.who.idirectory import RecordType, FieldName
</span><span class="cx"> from twext.who.idirectory import IDirectoryService, IDirectoryRecord
</span><ins>+from twext.who.expression import CompoundExpression
</ins><span class="cx"> from twext.who.directory import DirectoryService, DirectoryRecord
</span><span class="cx">
</span><span class="cx">
</span><del>-
</del><span class="cx"> class ServiceMixIn(object):
</span><span class="cx"> realmName = u"xyzzy"
</span><span class="cx">
</span><span class="lines">@@ -69,20 +69,20 @@
</span><span class="cx"> )
</span><span class="cx">
</span><span class="cx">
</span><del>- @inlineCallbacks
- def test_recordsFromQueryNone(self):
- service = self.service()
- records = (yield service.recordsFromQuery(()))
- for record in records:
- self.failTest("No records expected")
</del><ins>+ # @inlineCallbacks
+ # def test_recordsFromExpressionNone(self):
+ # service = self.service()
+ # records = (yield service.recordsFromExpression(CompoundExpression()))
+ # for record in records:
+ # self.failTest("No records expected")
</ins><span class="cx">
</span><span class="cx">
</span><del>- def test_recordsFromQueryBogus(self):
- service = self.service()
- self.assertFailure(
- service.recordsFromQuery((object(),)),
- QueryNotSupportedError
- )
</del><ins>+ # def test_recordsFromExpressionBogus(self):
+ # service = self.service()
+ # self.assertFailure(
+ # service.recordsFromQuery(CompoundExpression(object(),)),
+ # QueryNotSupportedError
+ # )
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> def test_recordWithUID(self):
</span></span></pre></div>
<a id="CalendarServertrunktwextwhotesttest_xmlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/test/test_xml.py (11908 => 11909)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/test/test_xml.py        2013-11-08 00:36:07 UTC (rev 11908)
+++ CalendarServer/trunk/twext/who/test/test_xml.py        2013-11-08 02:14:21 UTC (rev 11909)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx">
</span><span class="cx"> from twext.who.idirectory import NoSuchRecordError
</span><span class="cx"> from twext.who.idirectory import Operand
</span><ins>+from twext.who.expression import CompoundExpression
</ins><span class="cx"> from twext.who.expression import MatchExpression, MatchType, MatchFlags
</span><span class="cx"> from twext.who.xml import ParseError
</span><span class="cx"> from twext.who.xml import DirectoryService, DirectoryRecord
</span><span class="lines">@@ -300,12 +301,14 @@
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryAnd(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery(
- (
- service.query(u"emailAddresses", u"shared@example.com"),
- service.query(u"shortNames", u"sagen"),
- ),
- operand=Operand.AND
</del><ins>+ records = yield service.recordsFromExpression(
+ CompoundExpression(
+ (
+ service.query(u"emailAddresses", u"shared@example.com"),
+ service.query(u"shortNames", u"sagen"),
+ ),
+ operand=Operand.AND
+ )
</ins><span class="cx"> )
</span><span class="cx"> self.assertRecords(records, (u"__sagen__",))
</span><span class="cx">
</span><span class="lines">@@ -316,12 +319,14 @@
</span><span class="cx"> Test optimized case, where first expression yields no results.
</span><span class="cx"> """
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery(
- (
- service.query(u"emailAddresses", u"nobody@example.com"),
- service.query(u"shortNames", u"sagen"),
- ),
- operand=Operand.AND
</del><ins>+ records = yield service.recordsFromExpression(
+ CompoundExpression(
+ (
+ service.query(u"emailAddresses", u"nobody@example.com"),
+ service.query(u"shortNames", u"sagen"),
+ ),
+ operand=Operand.AND
+ )
</ins><span class="cx"> )
</span><span class="cx"> self.assertRecords(records, ())
</span><span class="cx">
</span><span class="lines">@@ -329,25 +334,37 @@
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryOr(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery(
- (
- service.query(u"emailAddresses", u"shared@example.com"),
- service.query(u"shortNames", u"wsanchez"),
- ),
- operand=Operand.OR
</del><ins>+ records = yield service.recordsFromExpression(
+ CompoundExpression(
+ (
+ service.query(u"emailAddresses", u"shared@example.com"),
+ service.query(u"shortNames", u"wsanchez"),
+ ),
+ operand=Operand.OR
+ )
</ins><span class="cx"> )
</span><del>- self.assertRecords(records, (u"__sagen__", u"__dre__", u"__wsanchez__"))
</del><ins>+ self.assertRecords(
+ records,
+ (u"__sagen__", u"__dre__", u"__wsanchez__")
+ )
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryNot(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery(
- (
- service.query(u"emailAddresses", u"shared@example.com"),
- service.query(u"shortNames", u"sagen", flags=MatchFlags.NOT),
- ),
- operand=Operand.AND
</del><ins>+ records = yield service.recordsFromExpression(
+ CompoundExpression(
+ (
+ service.query(
+ u"emailAddresses", u"shared@example.com"
+ ),
+ service.query(
+ u"shortNames", u"sagen",
+ flags=MatchFlags.NOT
+ ),
+ ),
+ operand=Operand.AND
+ )
</ins><span class="cx"> )
</span><span class="cx"> self.assertRecords(records, (u"__dre__",))
</span><span class="cx">
</span><span class="lines">@@ -355,15 +372,17 @@
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryNotNoIndex(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery(
- (
- service.query(u"emailAddresses", u"shared@example.com"),
- service.query(
- u"fullNames", u"Andre LaBranche",
- flags=MatchFlags.NOT
</del><ins>+ records = yield service.recordsFromExpression(
+ CompoundExpression(
+ (
+ service.query(u"emailAddresses", u"shared@example.com"),
+ service.query(
+ u"fullNames", u"Andre LaBranche",
+ flags=MatchFlags.NOT
+ ),
</ins><span class="cx"> ),
</span><del>- ),
- operand=Operand.AND
</del><ins>+ operand=Operand.AND
+ )
</ins><span class="cx"> )
</span><span class="cx"> self.assertRecords(records, (u"__sagen__",))
</span><span class="cx">
</span><span class="lines">@@ -371,58 +390,61 @@
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryCaseInsensitive(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
</del><ins>+ records = yield service.recordsFromExpression(
</ins><span class="cx"> service.query(
</span><span class="cx"> u"shortNames", u"SagEn",
</span><span class="cx"> flags=MatchFlags.caseInsensitive
</span><del>- ),
- ))
</del><ins>+ )
+ )
</ins><span class="cx"> self.assertRecords(records, (u"__sagen__",))
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryCaseInsensitiveNoIndex(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
</del><ins>+ records = yield service.recordsFromExpression(
</ins><span class="cx"> service.query(
</span><span class="cx"> u"fullNames", u"moRGen SAGen",
</span><span class="cx"> flags=MatchFlags.caseInsensitive
</span><del>- ),
- ))
</del><ins>+ )
+ )
</ins><span class="cx"> self.assertRecords(records, (u"__sagen__",))
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryStartsWith(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
- service.query(u"shortNames", u"wil", matchType=MatchType.startsWith),
- ))
</del><ins>+ records = yield service.recordsFromExpression(
+ service.query(
+ u"shortNames", u"wil",
+ matchType=MatchType.startsWith
+ )
+ )
</ins><span class="cx"> self.assertRecords(records, (u"__wsanchez__",))
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryStartsWithNoIndex(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
</del><ins>+ records = yield service.recordsFromExpression(
</ins><span class="cx"> service.query(
</span><span class="cx"> u"fullNames", u"Wilfredo",
</span><span class="cx"> matchType=MatchType.startsWith
</span><del>- ),
- ))
</del><ins>+ )
+ )
</ins><span class="cx"> self.assertRecords(records, (u"__wsanchez__",))
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryStartsWithNot(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
</del><ins>+ records = yield service.recordsFromExpression(
</ins><span class="cx"> service.query(
</span><span class="cx"> u"shortNames", u"w",
</span><span class="cx"> matchType=MatchType.startsWith,
</span><span class="cx"> flags=MatchFlags.NOT,
</span><del>- ),
- ))
</del><ins>+ )
+ )
</ins><span class="cx"> self.assertRecords(
</span><span class="cx"> records,
</span><span class="cx"> (
</span><span class="lines">@@ -450,13 +472,13 @@
</span><span class="cx"> should NOT require that all match?
</span><span class="cx"> """
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
</del><ins>+ records = yield service.recordsFromExpression(
</ins><span class="cx"> service.query(
</span><span class="cx"> u"shortNames", u"wil",
</span><span class="cx"> matchType=MatchType.startsWith,
</span><span class="cx"> flags=MatchFlags.NOT,
</span><del>- ),
- ))
</del><ins>+ )
+ )
</ins><span class="cx"> self.assertRecords(
</span><span class="cx"> records,
</span><span class="cx"> (
</span><span class="lines">@@ -479,13 +501,13 @@
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryStartsWithNotNoIndex(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
</del><ins>+ records = yield service.recordsFromExpression(
</ins><span class="cx"> service.query(
</span><span class="cx"> u"fullNames", u"Wilfredo",
</span><span class="cx"> matchType=MatchType.startsWith,
</span><span class="cx"> flags=MatchFlags.NOT,
</span><del>- ),
- ))
</del><ins>+ )
+ )
</ins><span class="cx"> self.assertRecords(
</span><span class="cx"> records,
</span><span class="cx"> (
</span><span class="lines">@@ -507,60 +529,63 @@
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryStartsWithCaseInsensitive(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
</del><ins>+ records = yield service.recordsFromExpression(
</ins><span class="cx"> service.query(
</span><span class="cx"> u"shortNames", u"WIL",
</span><span class="cx"> matchType=MatchType.startsWith,
</span><span class="cx"> flags=MatchFlags.caseInsensitive,
</span><del>- ),
- ))
</del><ins>+ )
+ )
</ins><span class="cx"> self.assertRecords(records, (u"__wsanchez__",))
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryStartsWithCaseInsensitiveNoIndex(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
</del><ins>+ records = yield service.recordsFromExpression(
</ins><span class="cx"> service.query(
</span><span class="cx"> u"fullNames", u"wilfrEdo",
</span><span class="cx"> matchType=MatchType.startsWith,
</span><span class="cx"> flags=MatchFlags.caseInsensitive,
</span><del>- ),
- ))
</del><ins>+ )
+ )
</ins><span class="cx"> self.assertRecords(records, (u"__wsanchez__",))
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryContains(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
</del><ins>+ records = yield service.recordsFromExpression(
</ins><span class="cx"> service.query(
</span><span class="cx"> u"shortNames", u"sanchez",
</span><del>- matchType=MatchType.contains
- ),
- ))
</del><ins>+ matchType=MatchType.contains,
+ )
+ )
</ins><span class="cx"> self.assertRecords(records, (u"__wsanchez__",))
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryContainsNoIndex(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
- service.query(u"fullNames", u"fred", matchType=MatchType.contains),
- ))
</del><ins>+ records = yield service.recordsFromExpression(
+ service.query(
+ u"fullNames", u"fred",
+ matchType=MatchType.contains,
+ )
+ )
</ins><span class="cx"> self.assertRecords(records, (u"__wsanchez__",))
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryContainsNot(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
</del><ins>+ records = yield service.recordsFromExpression(
</ins><span class="cx"> service.query(
</span><span class="cx"> u"shortNames", u"sanchez",
</span><span class="cx"> matchType=MatchType.contains,
</span><span class="cx"> flags=MatchFlags.NOT,
</span><del>- ),
- ))
</del><ins>+ )
+ )
</ins><span class="cx"> self.assertRecords(
</span><span class="cx"> records,
</span><span class="cx"> (
</span><span class="lines">@@ -582,13 +607,13 @@
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryContainsNotNoIndex(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
</del><ins>+ records = yield service.recordsFromExpression(
</ins><span class="cx"> service.query(
</span><span class="cx"> u"fullNames", u"fred",
</span><span class="cx"> matchType=MatchType.contains,
</span><span class="cx"> flags=MatchFlags.NOT,
</span><del>- ),
- ))
</del><ins>+ )
+ )
</ins><span class="cx"> self.assertRecords(
</span><span class="cx"> records,
</span><span class="cx"> (
</span><span class="lines">@@ -610,26 +635,26 @@
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryContainsCaseInsensitive(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
</del><ins>+ records = yield service.recordsFromExpression(
</ins><span class="cx"> service.query(
</span><span class="cx"> u"shortNames", u"Sanchez",
</span><span class="cx"> matchType=MatchType.contains,
</span><span class="cx"> flags=MatchFlags.caseInsensitive,
</span><del>- ),
- ))
</del><ins>+ )
+ )
</ins><span class="cx"> self.assertRecords(records, (u"__wsanchez__",))
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_queryContainsCaseInsensitiveNoIndex(self):
</span><span class="cx"> service = self.service()
</span><del>- records = yield service.recordsFromQuery((
</del><ins>+ records = yield service.recordsFromExpression(
</ins><span class="cx"> service.query(
</span><span class="cx"> u"fullNames", u"frEdo",
</span><span class="cx"> matchType=MatchType.contains,
</span><span class="cx"> flags=MatchFlags.caseInsensitive,
</span><del>- ),
- ))
</del><ins>+ )
+ )
</ins><span class="cx"> self.assertRecords(records, (u"__wsanchez__",))
</span><span class="cx">
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>