<!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>[13649] twext/branches/users/sagen/recordtypes/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/13649">13649</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2014-06-17 14:55:05 -0700 (Tue, 17 Jun 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Starting to add recordTypes arg</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#twextbranchesuserssagenrecordtypestwextwhoaggregatepy">twext/branches/users/sagen/recordtypes/twext/who/aggregate.py</a></li>
<li><a href="#twextbranchesuserssagenrecordtypestwextwhodirectorypy">twext/branches/users/sagen/recordtypes/twext/who/directory.py</a></li>
<li><a href="#twextbranchesuserssagenrecordtypestwextwhoidirectorypy">twext/branches/users/sagen/recordtypes/twext/who/idirectory.py</a></li>
<li><a href="#twextbranchesuserssagenrecordtypestwextwhoindexpy">twext/branches/users/sagen/recordtypes/twext/who/index.py</a></li>
<li><a href="#twextbranchesuserssagenrecordtypestwextwholdap_servicepy">twext/branches/users/sagen/recordtypes/twext/who/ldap/_service.py</a></li>
<li><a href="#twextbranchesuserssagenrecordtypestwextwhotesttest_directorypy">twext/branches/users/sagen/recordtypes/twext/who/test/test_directory.py</a></li>
<li><a href="#twextbranchesuserssagenrecordtypestwextwhotesttest_indexpy">twext/branches/users/sagen/recordtypes/twext/who/test/test_index.py</a></li>
<li><a href="#twextbranchesuserssagenrecordtypestwextwhotesttest_xmlpy">twext/branches/users/sagen/recordtypes/twext/who/test/test_xml.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="twextbranchesuserssagenrecordtypestwextwhoaggregatepy"></a>
<div class="modfile"><h4>Modified: twext/branches/users/sagen/recordtypes/twext/who/aggregate.py (13648 => 13649)</h4>
<pre class="diff"><span>
<span class="info">--- twext/branches/users/sagen/recordtypes/twext/who/aggregate.py        2014-06-17 19:13:35 UTC (rev 13648)
+++ twext/branches/users/sagen/recordtypes/twext/who/aggregate.py        2014-06-17 21:55:05 UTC (rev 13649)
</span><span class="lines">@@ -108,9 +108,10 @@
</span><span class="cx">         return d
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def recordsFromExpression(self, expression, records=None):
</del><ins>+    def recordsFromExpression(self, expression, recordTypes=None, records=None):
</ins><span class="cx">         return self._gatherFromSubServices(
</span><del>-            &quot;recordsFromExpression&quot;, expression, records=None
</del><ins>+            &quot;recordsFromExpression&quot;, expression, recordTypes=recordTypes,
+            records=None
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="twextbranchesuserssagenrecordtypestwextwhodirectorypy"></a>
<div class="modfile"><h4>Modified: twext/branches/users/sagen/recordtypes/twext/who/directory.py (13648 => 13649)</h4>
<pre class="diff"><span>
<span class="info">--- twext/branches/users/sagen/recordtypes/twext/who/directory.py        2014-06-17 19:13:35 UTC (rev 13648)
+++ twext/branches/users/sagen/recordtypes/twext/who/directory.py        2014-06-17 21:55:05 UTC (rev 13649)
</span><span class="lines">@@ -122,7 +122,9 @@
</span><span class="cx">         return self.recordType.iterconstants()
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def recordsFromNonCompoundExpression(self, expression, records=None):
</del><ins>+    def recordsFromNonCompoundExpression(
+        self, expression, recordTypes=None, records=None
+    ):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Finds records matching a non-compound expression.
</span><span class="cx"> 
</span><span class="lines">@@ -139,6 +141,10 @@
</span><span class="cx">         @param expression: an expression to apply
</span><span class="cx">         @type expression: L{object}
</span><span class="cx"> 
</span><ins>+        @param recordTypes: the record types to match
+        @type recordTypes: an iterable of L{NamedConstant}, or None for no
+            filtering
+
</ins><span class="cx">         @param records: a set of records to limit the search to. C{None} if
</span><span class="cx">             the whole directory should be searched.
</span><span class="cx">             This is provided by L{recordsFromExpression} when it has already
</span><span class="lines">@@ -165,7 +171,9 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def recordsFromCompoundExpression(self, expression, records=None):
</del><ins>+    def recordsFromCompoundExpression(
+        self, expression, recordTypes=None, records=None
+    ):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Finds records matching a compound expression.
</span><span class="cx"> 
</span><span class="lines">@@ -178,6 +186,10 @@
</span><span class="cx">         @param expression: an expression to apply
</span><span class="cx">         @type expression: L{CompoundExpression}
</span><span class="cx"> 
</span><ins>+        @param recordTypes: the record types to match
+        @type recordTypes: an iterable of L{NamedConstant}, or None for no
+            filtering
+
</ins><span class="cx">         @param records: a set of records to limit the search to. C{None} if
</span><span class="cx">             the whole directory should be searched.
</span><span class="cx">             This is provided by L{recordsFromExpression} when it has already
</span><span class="lines">@@ -201,7 +213,9 @@
</span><span class="cx">             returnValue(())
</span><span class="cx"> 
</span><span class="cx">         results = set((
</span><del>-            yield self.recordsFromExpression(subExpression, records=records)
</del><ins>+            yield self.recordsFromExpression(
+                subExpression, recordTypes=recordTypes, records=records
+            )
</ins><span class="cx">         ))
</span><span class="cx"> 
</span><span class="cx">         for subExpression in subExpressions:
</span><span class="lines">@@ -216,7 +230,7 @@
</span><span class="cx"> 
</span><span class="cx">             recordsMatchingExpression = frozenset((
</span><span class="cx">                 yield self.recordsFromExpression(
</span><del>-                    subExpression, records=records
</del><ins>+                    subExpression, recordTypes=recordTypes, records=records
</ins><span class="cx">                 )
</span><span class="cx">             ))
</span><span class="cx"> 
</span><span class="lines">@@ -232,16 +246,20 @@
</span><span class="cx">         returnValue(results)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def recordsFromExpression(self, expression, records=None):
</del><ins>+    def recordsFromExpression(self, expression, recordTypes=None, records=None):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         @note: This interface is the same as
</span><span class="cx">             L{IDirectoryService.recordsFromExpression}, except for the
</span><span class="cx">             additional C{records} argument.
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         if isinstance(expression, CompoundExpression):
</span><del>-            return self.recordsFromCompoundExpression(expression)
</del><ins>+            return self.recordsFromCompoundExpression(
+                expression, recordTypes=recordTypes
+            )
</ins><span class="cx">         else:
</span><del>-            return self.recordsFromNonCompoundExpression(expression)
</del><ins>+            return self.recordsFromNonCompoundExpression(
+                expression, recordTypes=recordTypes
+            )
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def recordsWithFieldValue(self, fieldName, value):
</span></span></pre></div>
<a id="twextbranchesuserssagenrecordtypestwextwhoidirectorypy"></a>
<div class="modfile"><h4>Modified: twext/branches/users/sagen/recordtypes/twext/who/idirectory.py (13648 => 13649)</h4>
<pre class="diff"><span>
<span class="info">--- twext/branches/users/sagen/recordtypes/twext/who/idirectory.py        2014-06-17 19:13:35 UTC (rev 13648)
+++ twext/branches/users/sagen/recordtypes/twext/who/idirectory.py        2014-06-17 21:55:05 UTC (rev 13649)
</span><span class="lines">@@ -278,13 +278,17 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def recordsFromExpression(expression):
</del><ins>+    def recordsFromExpression(expression, recordTypes=None):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Find records matching an expression.
</span><span class="cx"> 
</span><span class="cx">         @param expression: an expression to apply
</span><span class="cx">         @type expression: L{object}
</span><span class="cx"> 
</span><ins>+        @param recordTypes: the record types to match
+        @type recordTypes: an iterable of L{NamedConstant}, or None for no
+            filtering
+
</ins><span class="cx">         @return: The matching records.
</span><span class="cx">         @rtype: deferred iterable of L{IDirectoryRecord}s
</span><span class="cx"> 
</span></span></pre></div>
<a id="twextbranchesuserssagenrecordtypestwextwhoindexpy"></a>
<div class="modfile"><h4>Modified: twext/branches/users/sagen/recordtypes/twext/who/index.py (13648 => 13649)</h4>
<pre class="diff"><span>
<span class="info">--- twext/branches/users/sagen/recordtypes/twext/who/index.py        2014-06-17 19:13:35 UTC (rev 13648)
+++ twext/branches/users/sagen/recordtypes/twext/who/index.py        2014-06-17 21:55:05 UTC (rev 13649)
</span><span class="lines">@@ -226,7 +226,9 @@
</span><span class="cx">         self._index = index
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def indexedRecordsFromMatchExpression(self, expression, records=None):
</del><ins>+    def indexedRecordsFromMatchExpression(
+        self, expression, recordTypes=None, records=None
+    ):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Finds records in the internal indexes matching a single expression.
</span><span class="cx"> 
</span><span class="lines">@@ -286,10 +288,17 @@
</span><span class="cx">         # if records is not None:
</span><span class="cx">         #     matchingRecords &amp;= records
</span><span class="cx"> 
</span><ins>+        if recordTypes is not None:
+            for record in list(matchingRecords):
+                if record.recordType not in recordTypes:
+                    matchingRecords.remove(record)
+
</ins><span class="cx">         return succeed(matchingRecords)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def unIndexedRecordsFromMatchExpression(self, expression, records=None):
</del><ins>+    def unIndexedRecordsFromMatchExpression(
+        self, expression, recordTypes=None, records=None
+    ):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Finds records not in the internal indexes matching a single expression.
</span><span class="cx"> 
</span><span class="lines">@@ -312,6 +321,11 @@
</span><span class="cx">             )
</span><span class="cx"> 
</span><span class="cx">         for record in records:
</span><ins>+
+            if recordTypes is not None:
+                if record.recordType not in recordTypes:
+                    continue
+
</ins><span class="cx">             fieldValues = record.fields.get(expression.fieldName, None)
</span><span class="cx"> 
</span><span class="cx">             if fieldValues is None:
</span><span class="lines">@@ -324,7 +338,9 @@
</span><span class="cx">         return succeed(result)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def recordsFromNonCompoundExpression(self, expression, records=None):
</del><ins>+    def recordsFromNonCompoundExpression(
+        self, expression, recordTypes=None, records=None
+    ):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         This implementation can handle L{MatchExpression} expressions; other
</span><span class="cx">         expressions are passed up to the superclass.
</span><span class="lines">@@ -332,15 +348,15 @@
</span><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><del>-                    expression, records=records
</del><ins>+                    expression, recordTypes=recordTypes, records=records
</ins><span class="cx">                 )
</span><span class="cx">             else:
</span><span class="cx">                 return self.unIndexedRecordsFromMatchExpression(
</span><del>-                    expression, records=records
</del><ins>+                    expression, recordTypes=recordTypes, records=records
</ins><span class="cx">                 )
</span><span class="cx">         else:
</span><span class="cx">             return BaseDirectoryService.recordsFromNonCompoundExpression(
</span><del>-                self, expression, records=records
</del><ins>+                self, expression, recordTypes=recordTypes, records=records
</ins><span class="cx">             )
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="twextbranchesuserssagenrecordtypestwextwholdap_servicepy"></a>
<div class="modfile"><h4>Modified: twext/branches/users/sagen/recordtypes/twext/who/ldap/_service.py (13648 => 13649)</h4>
<pre class="diff"><span>
<span class="info">--- twext/branches/users/sagen/recordtypes/twext/who/ldap/_service.py        2014-06-17 19:13:35 UTC (rev 13648)
+++ twext/branches/users/sagen/recordtypes/twext/who/ldap/_service.py        2014-06-17 21:55:05 UTC (rev 13649)
</span><span class="lines">@@ -408,7 +408,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><del>-    def _recordsFromQueryString(self, queryString):
</del><ins>+    def _recordsFromQueryString(self, queryString, recordTypes=None):
</ins><span class="cx">         connection = yield self._connect()
</span><span class="cx"> 
</span><span class="cx">         self.log.info(&quot;Performing LDAP query: {query}&quot;, query=queryString)
</span><span class="lines">@@ -428,7 +428,7 @@
</span><span class="cx">             )
</span><span class="cx">             raise LDAPQueryError(&quot;Unable to perform query&quot;, e)
</span><span class="cx"> 
</span><del>-        records = yield self._recordsFromReply(reply)
</del><ins>+        records = yield self._recordsFromReply(reply, recordTypes=recordTypes)
</ins><span class="cx">         returnValue(records)
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -455,7 +455,7 @@
</span><span class="cx">             returnValue(None)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def _recordsFromReply(self, reply):
</del><ins>+    def _recordsFromReply(self, reply, recordTypes=None):
</ins><span class="cx">         records = []
</span><span class="cx"> 
</span><span class="cx">         for dn, recordData in reply:
</span><span class="lines">@@ -474,6 +474,9 @@
</span><span class="cx">                 )
</span><span class="cx">                 continue
</span><span class="cx"> 
</span><ins>+            if recordTypes is not None and recordType not in recordTypes:
+                continue
+
</ins><span class="cx">             # Populate a fields dictionary
</span><span class="cx"> 
</span><span class="cx">             fields = {}
</span><span class="lines">@@ -527,20 +530,26 @@
</span><span class="cx">         return records
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def recordsFromNonCompoundExpression(self, expression, records=None):
</del><ins>+    def recordsFromNonCompoundExpression(
+        self, expression, recordTypes=None, records=None
+    ):
</ins><span class="cx">         if isinstance(expression, MatchExpression):
</span><span class="cx">             queryString = ldapQueryStringFromMatchExpression(
</span><span class="cx">                 expression,
</span><span class="cx">                 self._fieldNameToAttributesMap, self._recordTypeSchemas
</span><span class="cx">             )
</span><del>-            return self._recordsFromQueryString(queryString)
</del><ins>+            return self._recordsFromQueryString(
+                queryString, recordTypes=recordTypes
+            )
</ins><span class="cx"> 
</span><span class="cx">         return BaseDirectoryService.recordsFromNonCompoundExpression(
</span><span class="cx">             self, expression, records=records
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def recordsFromCompoundExpression(self, expression, records=None):
</del><ins>+    def recordsFromCompoundExpression(
+        self, expression, recordTypes=None, records=None
+    ):
</ins><span class="cx">         if not expression.expressions:
</span><span class="cx">             return succeed(())
</span><span class="cx"> 
</span><span class="lines">@@ -548,7 +557,9 @@
</span><span class="cx">             expression,
</span><span class="cx">             self._fieldNameToAttributesMap, self._recordTypeSchemas
</span><span class="cx">         )
</span><del>-        return self._recordsFromQueryString(queryString)
</del><ins>+        return self._recordsFromQueryString(
+            queryString, recordTypes=recordTypes
+        )
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     # def updateRecords(self, records, create=False):
</span></span></pre></div>
<a id="twextbranchesuserssagenrecordtypestwextwhotesttest_directorypy"></a>
<div class="modfile"><h4>Modified: twext/branches/users/sagen/recordtypes/twext/who/test/test_directory.py (13648 => 13649)</h4>
<pre class="diff"><span>
<span class="info">--- twext/branches/users/sagen/recordtypes/twext/who/test/test_directory.py        2014-06-17 19:13:35 UTC (rev 13648)
+++ twext/branches/users/sagen/recordtypes/twext/who/test/test_directory.py        2014-06-17 21:55:05 UTC (rev 13649)
</span><span class="lines">@@ -62,15 +62,17 @@
</span><span class="cx">         self.seenExpressions = []
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def recordsFromExpression(self, expression, records=None):
</del><ins>+    def recordsFromExpression(self, expression, recordTypes=None, records=None):
</ins><span class="cx">         self.seenExpressions.append(expression)
</span><span class="cx">         return (
</span><span class="cx">             super(StubDirectoryService, self)
</span><del>-            .recordsFromExpression(expression)
</del><ins>+            .recordsFromExpression(expression, recordTypes=recordTypes)
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def recordsFromNonCompoundExpression(self, expression, records=None):
</del><ins>+    def recordsFromNonCompoundExpression(
+        self, expression, recordTypes=None, records=None
+    ):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         This implementation handles three expressions:
</span><span class="cx"> 
</span><span class="lines">@@ -94,7 +96,9 @@
</span><span class="cx"> 
</span><span class="cx">         return (
</span><span class="cx">             super(StubDirectoryService, self)
</span><del>-            .recordsFromNonCompoundExpression(expression, records=records)
</del><ins>+            .recordsFromNonCompoundExpression(
+                expression, recordTypes=recordTypes, records=records
+            )
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -1149,7 +1153,23 @@
</span><span class="cx">             ],
</span><span class="cx">         )
</span><span class="cx"> 
</span><ins>+        self.addGroup(
+            shortNames=[u&quot;calendar-dev&quot;],
+            fullNames=[u&quot;Calendar Developers&quot;],
+            emailAddresses=[
+                u&quot;calendar-dev@example.com&quot;,
+            ],
+        )
</ins><span class="cx"> 
</span><ins>+        self.addGroup(
+            shortNames=[u&quot;developers&quot;],
+            fullNames=[u&quot;Developers&quot;],
+            emailAddresses=[
+                u&quot;developers@example.com&quot;,
+            ],
+        )
+
+
</ins><span class="cx">     def addUser(self, shortNames, fullNames, emailAddresses=[]):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Add a user record with the given field information.
</span><span class="lines">@@ -1177,6 +1197,32 @@
</span><span class="cx">         }))
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def addGroup(self, shortNames, fullNames, emailAddresses=[]):
+        &quot;&quot;&quot;
+        Add a group record with the given field information.
+
+        @param shortNames: Record short names.
+        @type shortNames: L{list} of L{unicode}s
+
+        @param fullNames: Record full names.
+        @type fullNames: L{list} of L{unicode}s
+
+        @param emailAddresses: Record email addresses.
+        @type emailAddresses: L{list} of L{unicode}s
+        &quot;&quot;&quot;
+        service = self.service
+        fieldName = service.fieldName
+        recordType = service.recordType
+
+        self.records.append(self.recordClass(self.service, {
+            fieldName.recordType: recordType.group,
+            fieldName.uid: u&quot;__{0}__&quot;.format(shortNames[0]),
+            fieldName.shortNames: shortNames,
+            fieldName.fullNames: fullNames,
+            fieldName.emailAddresses: emailAddresses,
+        }))
+
+
</ins><span class="cx">     def __iter__(self):
</span><span class="cx">         return iter(self.records)
</span><span class="cx"> 
</span></span></pre></div>
<a id="twextbranchesuserssagenrecordtypestwextwhotesttest_indexpy"></a>
<div class="modfile"><h4>Modified: twext/branches/users/sagen/recordtypes/twext/who/test/test_index.py (13648 => 13649)</h4>
<pre class="diff"><span>
<span class="info">--- twext/branches/users/sagen/recordtypes/twext/who/test/test_index.py        2014-06-17 19:13:35 UTC (rev 13648)
+++ twext/branches/users/sagen/recordtypes/twext/who/test/test_index.py        2014-06-17 21:55:05 UTC (rev 13649)
</span><span class="lines">@@ -149,6 +149,7 @@
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def _test_indexedRecordsFromMatchExpression(
</span><span class="cx">         self, inOut, matchType, fieldName=BaseFieldName.shortNames,
</span><ins>+        recordTypes=None
</ins><span class="cx">     ):
</span><span class="cx">         service = self.noLoadServicePopulated()
</span><span class="cx"> 
</span><span class="lines">@@ -157,7 +158,8 @@
</span><span class="cx">                 MatchExpression(
</span><span class="cx">                     fieldName, subString,
</span><span class="cx">                     matchType
</span><del>-                )
</del><ins>+                ),
+                recordTypes=recordTypes,
</ins><span class="cx">             )
</span><span class="cx">             self.assertEquals(
</span><span class="cx">                 set((record.uid for record in records)),
</span><span class="lines">@@ -238,9 +240,25 @@
</span><span class="cx">         self.assertFailure(result, NotImplementedError)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    def test_indexedRecordsFromMatchExpression_recordTypes(self):
+        &quot;&quot;&quot;
+        L{DirectoryService.indexedRecordsFromMatchExpression} with recordTypes
+        &quot;&quot;&quot;
+        return self._test_indexedRecordsFromMatchExpression(
+            (
+                (u&quot;c&quot;, (u&quot;__calendar-dev__&quot;,)),  # only groups
+                (u&quot;d&quot;, (u&quot;__developers__&quot;,)),
+                (u&quot;j&quot;, ()),
+            ),
+            MatchType.startsWith,
+            recordTypes=(BaseRecordType.group,)
+        )
+
+
</ins><span class="cx">     @inlineCallbacks
</span><span class="cx">     def _test_unIndexedRecordsFromMatchExpression(
</span><span class="cx">         self, inOut, matchType, fieldName=BaseFieldName.fullNames,
</span><ins>+        recordTypes=None
</ins><span class="cx">     ):
</span><span class="cx">         service = self.noLoadServicePopulated()
</span><span class="cx"> 
</span><span class="lines">@@ -249,7 +267,8 @@
</span><span class="cx">                 MatchExpression(
</span><span class="cx">                     fieldName, subString,
</span><span class="cx">                     matchType
</span><del>-                )
</del><ins>+                ),
+                recordTypes=recordTypes
</ins><span class="cx">             )
</span><span class="cx">             self.assertEquals(
</span><span class="cx">                 set((record.uid for record in records)),
</span></span></pre></div>
<a id="twextbranchesuserssagenrecordtypestwextwhotesttest_xmlpy"></a>
<div class="modfile"><h4>Modified: twext/branches/users/sagen/recordtypes/twext/who/test/test_xml.py (13648 => 13649)</h4>
<pre class="diff"><span>
<span class="info">--- twext/branches/users/sagen/recordtypes/twext/who/test/test_xml.py        2014-06-17 19:13:35 UTC (rev 13648)
+++ twext/branches/users/sagen/recordtypes/twext/who/test/test_xml.py        2014-06-17 21:55:05 UTC (rev 13649)
</span><span class="lines">@@ -557,7 +557,28 @@
</span><span class="cx">         self.assertRecords(records, (u&quot;__wsanchez__&quot;,))
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    @inlineCallbacks
+    def test_queryWithRecordTypes(self):
+        &quot;&quot;&quot;
+        Verify that results are limited to the requested recordTypes
+        &quot;&quot;&quot;
+        service = self.service()
+        records = yield service.recordsFromExpression(
+            service.query(
+                u&quot;fullNames&quot;, u&quot;e&quot;,
+                matchType=MatchType.contains,
+            ),
+            recordTypes=(service.recordType.group,)
+        )
+        # Note: only contains groups; the users that would normally match
+        # have been filtered out
+        self.assertRecords(
+            records,
+            (u&quot;__calendar-dev__&quot;, u&quot;__developers__&quot;, u&quot;__twisted__&quot;)
+        )
</ins><span class="cx"> 
</span><ins>+
+
</ins><span class="cx"> class DirectoryServiceMutableTestMixIn(object):
</span><span class="cx">     @inlineCallbacks
</span><span class="cx">     def test_updateRecord(self):
</span></span></pre>
</div>
</div>

</body>
</html>