<!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>[11896] 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/11896">11896</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2013-11-06 14:52:10 -0800 (Wed, 06 Nov 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use unicode for field values, except for GUID, which is a UUID.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunktwextwhodirectorypy">CalendarServer/trunk/twext/who/directory.py</a></li>
<li><a href="#CalendarServertrunktwextwhoexpressionpy">CalendarServer/trunk/twext/who/expression.py</a></li>
<li><a href="#CalendarServertrunktwextwhoidirectorypy">CalendarServer/trunk/twext/who/idirectory.py</a></li>
<li><a href="#CalendarServertrunktwextwhotesttest_xmlpy">CalendarServer/trunk/twext/who/test/test_xml.py</a></li>
<li><a href="#CalendarServertrunktwextwhoxmlpy">CalendarServer/trunk/twext/who/xml.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunktwextwhodirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/directory.py (11895 => 11896)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/directory.py        2013-11-06 22:20:51 UTC (rev 11895)
+++ CalendarServer/trunk/twext/who/directory.py        2013-11-06 22:52:10 UTC (rev 11896)
</span><span class="lines">@@ -24,8 +24,6 @@
</span><span class="cx">     &quot;DirectoryRecord&quot;,
</span><span class="cx"> ]
</span><span class="cx"> 
</span><del>-from uuid import UUID
-
</del><span class="cx"> from zope.interface import implementer
</span><span class="cx"> 
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue
</span><span class="lines">@@ -87,7 +85,6 @@
</span><span class="cx">     fieldName  = FieldName
</span><span class="cx"> 
</span><span class="cx">     normalizedFields = {
</span><del>-        FieldName.guid: lambda g: UUID(g).hex,
</del><span class="cx">         FieldName.emailAddresses: lambda e: bytes(e).lower(),
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktwextwhoexpressionpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/expression.py (11895 => 11896)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/expression.py        2013-11-06 22:20:51 UTC (rev 11895)
+++ CalendarServer/trunk/twext/who/expression.py        2013-11-06 22:52:10 UTC (rev 11896)
</span><span class="lines">@@ -66,10 +66,13 @@
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Query for a matching value in a given field.
</span><span class="cx"> 
</span><del>-    @ivar fieldName: a L{NamedConstant} specifying the field
-    @ivar fieldValue: a text value to match
-    @ivar matchType: a L{NamedConstant} specifying the match algorythm
-    @ivar flags: L{NamedConstant} specifying additional options
</del><ins>+    @ivar fieldName: A L{NamedConstant} specifying the field.
+
+    @ivar fieldValue: A value to match.
+
+    @ivar matchType: A L{NamedConstant} specifying the match algorithm.
+
+    @ivar flags: A L{NamedConstant} specifying additional options.
</ins><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx">     def __init__(
</span><span class="lines">@@ -82,6 +85,7 @@
</span><span class="cx">         self.matchType  = matchType
</span><span class="cx">         self.flags      = flags
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx">     def __repr__(self):
</span><span class="cx">         def describe(constant):
</span><span class="cx">             return getattr(constant, &quot;description&quot;, str(constant))
</span></span></pre></div>
<a id="CalendarServertrunktwextwhoidirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/idirectory.py (11895 => 11896)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/idirectory.py        2013-11-06 22:20:51 UTC (rev 11895)
+++ CalendarServer/trunk/twext/who/idirectory.py        2013-11-06 22:52:10 UTC (rev 11896)
</span><span class="lines">@@ -36,6 +36,8 @@
</span><span class="cx">     &quot;IDirectoryRecord&quot;,
</span><span class="cx"> ]
</span><span class="cx"> 
</span><ins>+from uuid import UUID
+
</ins><span class="cx"> from zope.interface import Attribute, Interface
</span><span class="cx"> 
</span><span class="cx"> from twisted.python.constants import Names, NamedConstant
</span><span class="lines">@@ -158,6 +160,8 @@
</span><span class="cx">     emailAddresses.description = &quot;email addresses&quot;
</span><span class="cx">     password.description       = &quot;password&quot;
</span><span class="cx"> 
</span><ins>+    guid.valueType = UUID
+
</ins><span class="cx">     shortNames.multiValue     = True
</span><span class="cx">     fullNames.multiValue      = True
</span><span class="cx">     emailAddresses.multiValue = True
</span><span class="lines">@@ -168,13 +172,30 @@
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Check for whether a field is multi-value (as opposed to single-value).
</span><span class="cx"> 
</span><ins>+        @param name: The name of the field.
+        @type name: L{NamedConstant}
+
</ins><span class="cx">         @return: C{True} if the field is multi-value, C{False} otherwise.
</span><span class="cx">         @rtype: L{BOOL}
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         return getattr(name, &quot;multiValue&quot;, False)
</span><span class="cx"> 
</span><span class="cx"> 
</span><ins>+    @staticmethod
+    def valueType(name):
+        &quot;&quot;&quot;
+        Check for the expected type of values for a field.
</ins><span class="cx"> 
</span><ins>+        @param name: The name of the field.
+        @type name: L{NamedConstant}
+
+        @return: The expected type.
+        @rtype: L{type}
+        &quot;&quot;&quot;
+        return getattr(name, &quot;valueType&quot;, unicode)
+
+
+
</ins><span class="cx"> class Operand(Names):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Contants for common operands.
</span><span class="lines">@@ -295,7 +316,7 @@
</span><span class="cx">         Find the record that has the given GUID.
</span><span class="cx"> 
</span><span class="cx">         @param guid: a GUID
</span><del>-        @type guid: L{bytes}
</del><ins>+        @type guid: L{UUID}
</ins><span class="cx"> 
</span><span class="cx">         @return: The matching record or C{None} if there is no match.
</span><span class="cx">         @rtype: deferred L{IDirectoryRecord}s or C{None}
</span></span></pre></div>
<a id="CalendarServertrunktwextwhotesttest_xmlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/test/test_xml.py (11895 => 11896)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/test/test_xml.py        2013-11-06 22:20:51 UTC (rev 11895)
+++ CalendarServer/trunk/twext/who/test/test_xml.py        2013-11-06 22:52:10 UTC (rev 11896)
</span><span class="lines">@@ -19,6 +19,7 @@
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx"> from time import sleep
</span><ins>+from uuid import UUID
</ins><span class="cx"> 
</span><span class="cx"> from twisted.trial import unittest
</span><span class="cx"> from twisted.python.filepath import FilePath
</span><span class="lines">@@ -63,11 +64,11 @@
</span><span class="cx">     def test_recordWithUID(self):
</span><span class="cx">         service = self.service()
</span><span class="cx"> 
</span><del>-        record = (yield service.recordWithUID(&quot;__null__&quot;))
</del><ins>+        record = (yield service.recordWithUID(u&quot;__null__&quot;))
</ins><span class="cx">         self.assertEquals(record, None)
</span><span class="cx"> 
</span><del>-        record = (yield service.recordWithUID(&quot;__wsanchez__&quot;))
-        self.assertEquals(record.uid, &quot;__wsanchez__&quot;)
</del><ins>+        record = (yield service.recordWithUID(u&quot;__wsanchez__&quot;))
+        self.assertEquals(record.uid, u&quot;__wsanchez__&quot;)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -75,7 +76,7 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         record = (
</span><span class="cx">             yield service.recordWithGUID(
</span><del>-                &quot;6C495FCD-7E78-4D5C-AA66-BC890AD04C9D&quot;
</del><ins>+                UUID(&quot;6C495FCD-7E78-4D5C-AA66-BC890AD04C9D&quot;)
</ins><span class="cx">             )
</span><span class="cx">         )
</span><span class="cx">         self.assertEquals(record, None)
</span><span class="lines">@@ -93,15 +94,15 @@
</span><span class="cx">         self.assertRecords(
</span><span class="cx">             records,
</span><span class="cx">             (
</span><del>-                &quot;__wsanchez__&quot;,
-                &quot;__glyph__&quot;,
-                &quot;__sagen__&quot;,
-                &quot;__cdaboo__&quot;,
-                &quot;__dre__&quot;,
-                &quot;__exarkun__&quot;,
-                &quot;__dreid__&quot;,
-                &quot;__alyssa__&quot;,
-                &quot;__joe__&quot;,
</del><ins>+                u&quot;__wsanchez__&quot;,
+                u&quot;__glyph__&quot;,
+                u&quot;__sagen__&quot;,
+                u&quot;__cdaboo__&quot;,
+                u&quot;__dre__&quot;,
+                u&quot;__exarkun__&quot;,
+                u&quot;__dreid__&quot;,
+                u&quot;__alyssa__&quot;,
+                u&quot;__joe__&quot;,
</ins><span class="cx">             ),
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -111,9 +112,9 @@
</span><span class="cx">         self.assertRecords(
</span><span class="cx">             records,
</span><span class="cx">             (
</span><del>-                &quot;__calendar-dev__&quot;,
-                &quot;__twisted__&quot;,
-                &quot;__developers__&quot;,
</del><ins>+                u&quot;__calendar-dev__&quot;,
+                u&quot;__twisted__&quot;,
+                u&quot;__developers__&quot;,
</ins><span class="cx">             ),
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -125,7 +126,7 @@
</span><span class="cx">         record = (
</span><span class="cx">             yield service.recordWithShortName(
</span><span class="cx">                 service.recordType.user,
</span><del>-                &quot;null&quot;,
</del><ins>+                u&quot;null&quot;,
</ins><span class="cx">             )
</span><span class="cx">         )
</span><span class="cx">         self.assertEquals(record, None)
</span><span class="lines">@@ -133,18 +134,18 @@
</span><span class="cx">         record = (
</span><span class="cx">             yield service.recordWithShortName(
</span><span class="cx">                 service.recordType.user,
</span><del>-                &quot;wsanchez&quot;,
</del><ins>+                u&quot;wsanchez&quot;,
</ins><span class="cx">             )
</span><span class="cx">         )
</span><del>-        self.assertEquals(record.uid, &quot;__wsanchez__&quot;)
</del><ins>+        self.assertEquals(record.uid, u&quot;__wsanchez__&quot;)
</ins><span class="cx"> 
</span><span class="cx">         record = (
</span><span class="cx">             yield service.recordWithShortName(
</span><span class="cx">                 service.recordType.user,
</span><del>-                &quot;wilfredo_sanchez&quot;,
</del><ins>+                u&quot;wilfredo_sanchez&quot;,
</ins><span class="cx">             )
</span><span class="cx">         )
</span><del>-        self.assertEquals(record.uid, &quot;__wsanchez__&quot;)
</del><ins>+        self.assertEquals(record.uid, u&quot;__wsanchez__&quot;)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -153,24 +154,24 @@
</span><span class="cx"> 
</span><span class="cx">         records = (
</span><span class="cx">             yield service.recordsWithEmailAddress(
</span><del>-                &quot;wsanchez@bitbucket.calendarserver.org&quot;
</del><ins>+                u&quot;wsanchez@bitbucket.calendarserver.org&quot;
</ins><span class="cx">             )
</span><span class="cx">         )
</span><del>-        self.assertRecords(records, (&quot;__wsanchez__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__wsanchez__&quot;,))
</ins><span class="cx"> 
</span><span class="cx">         records = (
</span><span class="cx">             yield service.recordsWithEmailAddress(
</span><del>-                &quot;wsanchez@devnull.twistedmatrix.com&quot;
</del><ins>+                u&quot;wsanchez@devnull.twistedmatrix.com&quot;
</ins><span class="cx">             )
</span><span class="cx">         )
</span><del>-        self.assertRecords(records, (&quot;__wsanchez__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__wsanchez__&quot;,))
</ins><span class="cx"> 
</span><span class="cx">         records = (
</span><span class="cx">             yield service.recordsWithEmailAddress(
</span><del>-                &quot;shared@example.com&quot;
</del><ins>+                u&quot;shared@example.com&quot;
</ins><span class="cx">             )
</span><span class="cx">         )
</span><del>-        self.assertRecords(records, (&quot;__sagen__&quot;, &quot;__dre__&quot;))
</del><ins>+        self.assertRecords(records, (u&quot;__sagen__&quot;, u&quot;__dre__&quot;))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -178,7 +179,7 @@
</span><span class="cx">     def test_realmNameImmutable(self):
</span><span class="cx">         def setRealmName():
</span><span class="cx">             service = self.service()
</span><del>-            service.realmName = &quot;foo&quot;
</del><ins>+            service.realmName = u&quot;foo&quot;
</ins><span class="cx"> 
</span><span class="cx">         self.assertRaises(AssertionError, setRealmName)
</span><span class="cx"> 
</span><span class="lines">@@ -217,7 +218,7 @@
</span><span class="cx"> 
</span><span class="cx">     def test_badRootElement(self):
</span><span class="cx">         service = self.service(xmlData=(
</span><del>-&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
</del><ins>+b&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
</ins><span class="cx"> 
</span><span class="cx"> &lt;frobnitz /&gt;
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="lines">@@ -234,7 +235,7 @@
</span><span class="cx"> 
</span><span class="cx">     def test_noRealmName(self):
</span><span class="cx">         service = self.service(xmlData=(
</span><del>-&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
</del><ins>+b&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
</ins><span class="cx"> 
</span><span class="cx"> &lt;directory /&gt;
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="lines">@@ -256,7 +257,7 @@
</span><span class="cx"> 
</span><span class="cx">     def test_unknownFieldElementsDirty(self):
</span><span class="cx">         service = self.service(xmlData=(
</span><del>-&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
</del><ins>+b&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
</ins><span class="cx"> 
</span><span class="cx"> &lt;directory realm=&quot;Unknown Record Types&quot;&gt;
</span><span class="cx">   &lt;record type=&quot;user&quot;&gt;
</span><span class="lines">@@ -269,7 +270,7 @@
</span><span class="cx">         ))
</span><span class="cx">         self.assertEquals(
</span><span class="cx">             set(service.unknownFieldElements),
</span><del>-            set((&quot;political-affiliation&quot;,))
</del><ins>+            set((u&quot;political-affiliation&quot;,))
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -280,7 +281,7 @@
</span><span class="cx"> 
</span><span class="cx">     def test_unknownRecordTypesDirty(self):
</span><span class="cx">         service = self.service(xmlData=(
</span><del>-&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
</del><ins>+b&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
</ins><span class="cx"> 
</span><span class="cx"> &lt;directory realm=&quot;Unknown Record Types&quot;&gt;
</span><span class="cx">   &lt;record type=&quot;camera&quot;&gt;
</span><span class="lines">@@ -291,7 +292,7 @@
</span><span class="cx"> &lt;/directory&gt;
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx">         ))
</span><del>-        self.assertEquals(set(service.unknownRecordTypes), set((&quot;camera&quot;,)))
</del><ins>+        self.assertEquals(set(service.unknownRecordTypes), set((u&quot;camera&quot;,)))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -301,12 +302,12 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery(
</span><span class="cx">             (
</span><del>-                service.query(&quot;emailAddresses&quot;, &quot;shared@example.com&quot;),
-                service.query(&quot;shortNames&quot;, &quot;sagen&quot;),
</del><ins>+                service.query(u&quot;emailAddresses&quot;, u&quot;shared@example.com&quot;),
+                service.query(u&quot;shortNames&quot;, u&quot;sagen&quot;),
</ins><span class="cx">             ),
</span><span class="cx">             operand=Operand.AND
</span><span class="cx">         )
</span><del>-        self.assertRecords(records, (&quot;__sagen__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__sagen__&quot;,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -317,8 +318,8 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery(
</span><span class="cx">             (
</span><del>-                service.query(&quot;emailAddresses&quot;, &quot;nobody@example.com&quot;),
-                service.query(&quot;shortNames&quot;, &quot;sagen&quot;),
</del><ins>+                service.query(u&quot;emailAddresses&quot;, u&quot;nobody@example.com&quot;),
+                service.query(u&quot;shortNames&quot;, u&quot;sagen&quot;),
</ins><span class="cx">             ),
</span><span class="cx">             operand=Operand.AND
</span><span class="cx">         )
</span><span class="lines">@@ -330,12 +331,12 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery(
</span><span class="cx">             (
</span><del>-                service.query(&quot;emailAddresses&quot;, &quot;shared@example.com&quot;),
-                service.query(&quot;shortNames&quot;, &quot;wsanchez&quot;),
</del><ins>+                service.query(u&quot;emailAddresses&quot;, u&quot;shared@example.com&quot;),
+                service.query(u&quot;shortNames&quot;, u&quot;wsanchez&quot;),
</ins><span class="cx">             ),
</span><span class="cx">             operand=Operand.OR
</span><span class="cx">         )
</span><del>-        self.assertRecords(records, (&quot;__sagen__&quot;, &quot;__dre__&quot;, &quot;__wsanchez__&quot;))
</del><ins>+        self.assertRecords(records, (u&quot;__sagen__&quot;, u&quot;__dre__&quot;, u&quot;__wsanchez__&quot;))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -343,12 +344,12 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery(
</span><span class="cx">             (
</span><del>-                service.query(&quot;emailAddresses&quot;, &quot;shared@example.com&quot;),
-                service.query(&quot;shortNames&quot;, &quot;sagen&quot;, flags=MatchFlags.NOT),
</del><ins>+                service.query(u&quot;emailAddresses&quot;, u&quot;shared@example.com&quot;),
+                service.query(u&quot;shortNames&quot;, u&quot;sagen&quot;, flags=MatchFlags.NOT),
</ins><span class="cx">             ),
</span><span class="cx">             operand=Operand.AND
</span><span class="cx">         )
</span><del>-        self.assertRecords(records, (&quot;__dre__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__dre__&quot;,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -356,15 +357,15 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery(
</span><span class="cx">             (
</span><del>-                service.query(&quot;emailAddresses&quot;, &quot;shared@example.com&quot;),
</del><ins>+                service.query(u&quot;emailAddresses&quot;, u&quot;shared@example.com&quot;),
</ins><span class="cx">                 service.query(
</span><del>-                    &quot;fullNames&quot;, &quot;Andre LaBranche&quot;,
</del><ins>+                    u&quot;fullNames&quot;, u&quot;Andre LaBranche&quot;,
</ins><span class="cx">                     flags=MatchFlags.NOT
</span><span class="cx">                 ),
</span><span class="cx">             ),
</span><span class="cx">             operand=Operand.AND
</span><span class="cx">         )
</span><del>-        self.assertRecords(records, (&quot;__sagen__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__sagen__&quot;,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -372,11 +373,11 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery((
</span><span class="cx">             service.query(
</span><del>-                &quot;shortNames&quot;, &quot;SagEn&quot;,
</del><ins>+                u&quot;shortNames&quot;, u&quot;SagEn&quot;,
</ins><span class="cx">                 flags=MatchFlags.caseInsensitive
</span><span class="cx">             ),
</span><span class="cx">         ))
</span><del>-        self.assertRecords(records, (&quot;__sagen__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__sagen__&quot;,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -384,20 +385,20 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery((
</span><span class="cx">             service.query(
</span><del>-                &quot;fullNames&quot;, &quot;moRGen SAGen&quot;,
</del><ins>+                u&quot;fullNames&quot;, u&quot;moRGen SAGen&quot;,
</ins><span class="cx">                 flags=MatchFlags.caseInsensitive
</span><span class="cx">             ),
</span><span class="cx">         ))
</span><del>-        self.assertRecords(records, (&quot;__sagen__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__sagen__&quot;,))
</ins><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><span class="cx">         records = yield service.recordsFromQuery((
</span><del>-            service.query(&quot;shortNames&quot;, &quot;wil&quot;, matchType=MatchType.startsWith),
</del><ins>+            service.query(u&quot;shortNames&quot;, u&quot;wil&quot;, matchType=MatchType.startsWith),
</ins><span class="cx">         ))
</span><del>-        self.assertRecords(records, (&quot;__wsanchez__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__wsanchez__&quot;,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -405,11 +406,11 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery((
</span><span class="cx">             service.query(
</span><del>-                &quot;fullNames&quot;, &quot;Wilfredo&quot;,
</del><ins>+                u&quot;fullNames&quot;, u&quot;Wilfredo&quot;,
</ins><span class="cx">                 matchType=MatchType.startsWith
</span><span class="cx">             ),
</span><span class="cx">         ))
</span><del>-        self.assertRecords(records, (&quot;__wsanchez__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__wsanchez__&quot;,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -417,7 +418,7 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery((
</span><span class="cx">             service.query(
</span><del>-                &quot;shortNames&quot;, &quot;w&quot;,
</del><ins>+                u&quot;shortNames&quot;, u&quot;w&quot;,
</ins><span class="cx">                 matchType=MatchType.startsWith,
</span><span class="cx">                 flags=MatchFlags.NOT,
</span><span class="cx">             ),
</span><span class="lines">@@ -425,17 +426,17 @@
</span><span class="cx">         self.assertRecords(
</span><span class="cx">             records,
</span><span class="cx">             (
</span><del>-                '__alyssa__',
-                '__calendar-dev__',
-                '__cdaboo__',
-                '__developers__',
-                '__dre__',
-                '__dreid__',
-                '__exarkun__',
-                '__glyph__',
-                '__joe__',
-                '__sagen__',
-                '__twisted__',
</del><ins>+                u&quot;__alyssa__&quot;,
+                u&quot;__calendar-dev__&quot;,
+                u&quot;__cdaboo__&quot;,
+                u&quot;__developers__&quot;,
+                u&quot;__dre__&quot;,
+                u&quot;__dreid__&quot;,
+                u&quot;__exarkun__&quot;,
+                u&quot;__glyph__&quot;,
+                u&quot;__joe__&quot;,
+                u&quot;__sagen__&quot;,
+                u&quot;__twisted__&quot;,
</ins><span class="cx">             ),
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -451,7 +452,7 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery((
</span><span class="cx">             service.query(
</span><del>-                &quot;shortNames&quot;, &quot;wil&quot;,
</del><ins>+                u&quot;shortNames&quot;, u&quot;wil&quot;,
</ins><span class="cx">                 matchType=MatchType.startsWith,
</span><span class="cx">                 flags=MatchFlags.NOT,
</span><span class="cx">             ),
</span><span class="lines">@@ -459,18 +460,18 @@
</span><span class="cx">         self.assertRecords(
</span><span class="cx">             records,
</span><span class="cx">             (
</span><del>-                '__alyssa__',
-                '__calendar-dev__',
-                '__cdaboo__',
-                '__developers__',
-                '__dre__',
-                '__dreid__',
-                '__exarkun__',
-                '__glyph__',
-                '__joe__',
-                '__sagen__',
-                '__twisted__',
-                '__wsanchez__',
</del><ins>+                u&quot;__alyssa__&quot;,
+                u&quot;__calendar-dev__&quot;,
+                u&quot;__cdaboo__&quot;,
+                u&quot;__developers__&quot;,
+                u&quot;__dre__&quot;,
+                u&quot;__dreid__&quot;,
+                u&quot;__exarkun__&quot;,
+                u&quot;__glyph__&quot;,
+                u&quot;__joe__&quot;,
+                u&quot;__sagen__&quot;,
+                u&quot;__twisted__&quot;,
+                u&quot;__wsanchez__&quot;,
</ins><span class="cx">             ),
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -480,7 +481,7 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery((
</span><span class="cx">             service.query(
</span><del>-                &quot;fullNames&quot;, &quot;Wilfredo&quot;,
</del><ins>+                u&quot;fullNames&quot;, u&quot;Wilfredo&quot;,
</ins><span class="cx">                 matchType=MatchType.startsWith,
</span><span class="cx">                 flags=MatchFlags.NOT,
</span><span class="cx">             ),
</span><span class="lines">@@ -488,17 +489,17 @@
</span><span class="cx">         self.assertRecords(
</span><span class="cx">             records,
</span><span class="cx">             (
</span><del>-                '__alyssa__',
-                '__calendar-dev__',
-                '__cdaboo__',
-                '__developers__',
-                '__dre__',
-                '__dreid__',
-                '__exarkun__',
-                '__glyph__',
-                '__joe__',
-                '__sagen__',
-                '__twisted__',
</del><ins>+                u&quot;__alyssa__&quot;,
+                u&quot;__calendar-dev__&quot;,
+                u&quot;__cdaboo__&quot;,
+                u&quot;__developers__&quot;,
+                u&quot;__dre__&quot;,
+                u&quot;__dreid__&quot;,
+                u&quot;__exarkun__&quot;,
+                u&quot;__glyph__&quot;,
+                u&quot;__joe__&quot;,
+                u&quot;__sagen__&quot;,
+                u&quot;__twisted__&quot;,
</ins><span class="cx">             ),
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -508,12 +509,12 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery((
</span><span class="cx">             service.query(
</span><del>-                &quot;shortNames&quot;, &quot;WIL&quot;,
</del><ins>+                u&quot;shortNames&quot;, u&quot;WIL&quot;,
</ins><span class="cx">                 matchType=MatchType.startsWith,
</span><span class="cx">                 flags=MatchFlags.caseInsensitive,
</span><span class="cx">             ),
</span><span class="cx">         ))
</span><del>-        self.assertRecords(records, (&quot;__wsanchez__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__wsanchez__&quot;,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -521,12 +522,12 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery((
</span><span class="cx">             service.query(
</span><del>-                &quot;fullNames&quot;, &quot;wilfrEdo&quot;,
</del><ins>+                u&quot;fullNames&quot;, u&quot;wilfrEdo&quot;,
</ins><span class="cx">                 matchType=MatchType.startsWith,
</span><span class="cx">                 flags=MatchFlags.caseInsensitive,
</span><span class="cx">             ),
</span><span class="cx">         ))
</span><del>-        self.assertRecords(records, (&quot;__wsanchez__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__wsanchez__&quot;,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -534,20 +535,20 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery((
</span><span class="cx">             service.query(
</span><del>-                &quot;shortNames&quot;, &quot;sanchez&quot;,
</del><ins>+                u&quot;shortNames&quot;, u&quot;sanchez&quot;,
</ins><span class="cx">                 matchType=MatchType.contains
</span><span class="cx">             ),
</span><span class="cx">         ))
</span><del>-        self.assertRecords(records, (&quot;__wsanchez__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__wsanchez__&quot;,))
</ins><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><span class="cx">         records = yield service.recordsFromQuery((
</span><del>-            service.query(&quot;fullNames&quot;, &quot;fred&quot;, matchType=MatchType.contains),
</del><ins>+            service.query(u&quot;fullNames&quot;, u&quot;fred&quot;, matchType=MatchType.contains),
</ins><span class="cx">         ))
</span><del>-        self.assertRecords(records, (&quot;__wsanchez__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__wsanchez__&quot;,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -555,7 +556,7 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery((
</span><span class="cx">             service.query(
</span><del>-                &quot;shortNames&quot;, &quot;sanchez&quot;,
</del><ins>+                u&quot;shortNames&quot;, u&quot;sanchez&quot;,
</ins><span class="cx">                 matchType=MatchType.contains,
</span><span class="cx">                 flags=MatchFlags.NOT,
</span><span class="cx">             ),
</span><span class="lines">@@ -563,17 +564,17 @@
</span><span class="cx">         self.assertRecords(
</span><span class="cx">             records,
</span><span class="cx">             (
</span><del>-                '__alyssa__',
-                '__calendar-dev__',
-                '__cdaboo__',
-                '__developers__',
-                '__dre__',
-                '__dreid__',
-                '__exarkun__',
-                '__glyph__',
-                '__joe__',
-                '__sagen__',
-                '__twisted__',
</del><ins>+                u&quot;__alyssa__&quot;,
+                u&quot;__calendar-dev__&quot;,
+                u&quot;__cdaboo__&quot;,
+                u&quot;__developers__&quot;,
+                u&quot;__dre__&quot;,
+                u&quot;__dreid__&quot;,
+                u&quot;__exarkun__&quot;,
+                u&quot;__glyph__&quot;,
+                u&quot;__joe__&quot;,
+                u&quot;__sagen__&quot;,
+                u&quot;__twisted__&quot;,
</ins><span class="cx">             ),
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -583,7 +584,7 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery((
</span><span class="cx">             service.query(
</span><del>-                &quot;fullNames&quot;, &quot;fred&quot;,
</del><ins>+                u&quot;fullNames&quot;, u&quot;fred&quot;,
</ins><span class="cx">                 matchType=MatchType.contains,
</span><span class="cx">                 flags=MatchFlags.NOT,
</span><span class="cx">             ),
</span><span class="lines">@@ -591,17 +592,17 @@
</span><span class="cx">         self.assertRecords(
</span><span class="cx">             records,
</span><span class="cx">             (
</span><del>-                '__alyssa__',
-                '__calendar-dev__',
-                '__cdaboo__',
-                '__developers__',
-                '__dre__',
-                '__dreid__',
-                '__exarkun__',
-                '__glyph__',
-                '__joe__',
-                '__sagen__',
-                '__twisted__',
</del><ins>+                u&quot;__alyssa__&quot;,
+                u&quot;__calendar-dev__&quot;,
+                u&quot;__cdaboo__&quot;,
+                u&quot;__developers__&quot;,
+                u&quot;__dre__&quot;,
+                u&quot;__dreid__&quot;,
+                u&quot;__exarkun__&quot;,
+                u&quot;__glyph__&quot;,
+                u&quot;__joe__&quot;,
+                u&quot;__sagen__&quot;,
+                u&quot;__twisted__&quot;,
</ins><span class="cx">             ),
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -611,12 +612,12 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery((
</span><span class="cx">             service.query(
</span><del>-                &quot;shortNames&quot;, &quot;Sanchez&quot;,
</del><ins>+                u&quot;shortNames&quot;, u&quot;Sanchez&quot;,
</ins><span class="cx">                 matchType=MatchType.contains,
</span><span class="cx">                 flags=MatchFlags.caseInsensitive,
</span><span class="cx">             ),
</span><span class="cx">         ))
</span><del>-        self.assertRecords(records, (&quot;__wsanchez__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__wsanchez__&quot;,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span><span class="lines">@@ -624,12 +625,12 @@
</span><span class="cx">         service = self.service()
</span><span class="cx">         records = yield service.recordsFromQuery((
</span><span class="cx">             service.query(
</span><del>-                &quot;fullNames&quot;, &quot;frEdo&quot;,
</del><ins>+                u&quot;fullNames&quot;, u&quot;frEdo&quot;,
</ins><span class="cx">                 matchType=MatchType.contains,
</span><span class="cx">                 flags=MatchFlags.caseInsensitive,
</span><span class="cx">             ),
</span><span class="cx">         ))
</span><del>-        self.assertRecords(records, (&quot;__wsanchez__&quot;,))
</del><ins>+        self.assertRecords(records, (u&quot;__wsanchez__&quot;,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -638,27 +639,27 @@
</span><span class="cx">     def test_updateRecord(self):
</span><span class="cx">         service = self.service()
</span><span class="cx"> 
</span><del>-        record = (yield service.recordWithUID(&quot;__wsanchez__&quot;))
</del><ins>+        record = (yield service.recordWithUID(u&quot;__wsanchez__&quot;))
</ins><span class="cx"> 
</span><span class="cx">         fields = record.fields.copy()
</span><del>-        fields[service.fieldName.fullNames] = [&quot;Wilfredo Sanchez Vega&quot;]
</del><ins>+        fields[service.fieldName.fullNames] = [u&quot;Wilfredo Sanchez Vega&quot;]
</ins><span class="cx"> 
</span><span class="cx">         updatedRecord = DirectoryRecord(service, fields)
</span><span class="cx">         yield service.updateRecords((updatedRecord,))
</span><span class="cx"> 
</span><span class="cx">         # Verify change is present immediately
</span><del>-        record = (yield service.recordWithUID(&quot;__wsanchez__&quot;))
</del><ins>+        record = (yield service.recordWithUID(u&quot;__wsanchez__&quot;))
</ins><span class="cx">         self.assertEquals(
</span><span class="cx">             set(record.fullNames),
</span><del>-            set((&quot;Wilfredo Sanchez Vega&quot;,))
</del><ins>+            set((u&quot;Wilfredo Sanchez Vega&quot;,))
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         # Verify change is persisted
</span><span class="cx">         service.flush()
</span><del>-        record = (yield service.recordWithUID(&quot;__wsanchez__&quot;))
</del><ins>+        record = (yield service.recordWithUID(u&quot;__wsanchez__&quot;))
</ins><span class="cx">         self.assertEquals(
</span><span class="cx">             set(record.fullNames),
</span><del>-            set((&quot;Wilfredo Sanchez Vega&quot;,))
</del><ins>+            set((u&quot;Wilfredo Sanchez Vega&quot;,))
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -669,22 +670,22 @@
</span><span class="cx">         newRecord = DirectoryRecord(
</span><span class="cx">             service,
</span><span class="cx">             fields={
</span><del>-                service.fieldName.uid:        &quot;__plugh__&quot;,
</del><ins>+                service.fieldName.uid:        u&quot;__plugh__&quot;,
</ins><span class="cx">                 service.fieldName.recordType: service.recordType.user,
</span><del>-                service.fieldName.shortNames: (&quot;plugh&quot;,),
</del><ins>+                service.fieldName.shortNames: (u&quot;plugh&quot;,),
</ins><span class="cx">             }
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx">         yield service.updateRecords((newRecord,), create=True)
</span><span class="cx"> 
</span><span class="cx">         # Verify change is present immediately
</span><del>-        record = (yield service.recordWithUID(&quot;__plugh__&quot;))
-        self.assertEquals(set(record.shortNames), set((&quot;plugh&quot;,)))
</del><ins>+        record = (yield service.recordWithUID(u&quot;__plugh__&quot;))
+        self.assertEquals(set(record.shortNames), set((u&quot;plugh&quot;,)))
</ins><span class="cx"> 
</span><span class="cx">         # Verify change is persisted
</span><span class="cx">         service.flush()
</span><del>-        record = (yield service.recordWithUID(&quot;__plugh__&quot;))
-        self.assertEquals(set(record.shortNames), set((&quot;plugh&quot;,)))
</del><ins>+        record = (yield service.recordWithUID(u&quot;__plugh__&quot;))
+        self.assertEquals(set(record.shortNames), set((u&quot;plugh&quot;,)))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def test_addRecordNoCreate(self):
</span><span class="lines">@@ -693,9 +694,9 @@
</span><span class="cx">         newRecord = DirectoryRecord(
</span><span class="cx">             service,
</span><span class="cx">             fields={
</span><del>-                service.fieldName.uid:        &quot;__plugh__&quot;,
</del><ins>+                service.fieldName.uid:        u&quot;__plugh__&quot;,
</ins><span class="cx">                 service.fieldName.recordType: service.recordType.user,
</span><del>-                service.fieldName.shortNames: (&quot;plugh&quot;,),
</del><ins>+                service.fieldName.shortNames: (u&quot;plugh&quot;,),
</ins><span class="cx">             }
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -709,20 +710,20 @@
</span><span class="cx">     def test_removeRecord(self):
</span><span class="cx">         service = self.service()
</span><span class="cx"> 
</span><del>-        yield service.removeRecords((&quot;__wsanchez__&quot;,))
</del><ins>+        yield service.removeRecords((u&quot;__wsanchez__&quot;,))
</ins><span class="cx"> 
</span><span class="cx">         # Verify change is present immediately
</span><del>-        self.assertEquals((yield service.recordWithUID(&quot;__wsanchez__&quot;)), None)
</del><ins>+        self.assertEquals((yield service.recordWithUID(u&quot;__wsanchez__&quot;)), None)
</ins><span class="cx"> 
</span><span class="cx">         # Verify change is persisted
</span><span class="cx">         service.flush()
</span><del>-        self.assertEquals((yield service.recordWithUID(&quot;__wsanchez__&quot;)), None)
</del><ins>+        self.assertEquals((yield service.recordWithUID(u&quot;__wsanchez__&quot;)), None)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def test_removeRecordNoExist(self):
</span><span class="cx">         service = self.service()
</span><span class="cx"> 
</span><del>-        return service.removeRecords((&quot;__plugh__&quot;,))
</del><ins>+        return service.removeRecords((u&quot;__plugh__&quot;,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -731,31 +732,31 @@
</span><span class="cx">     def test_members(self):
</span><span class="cx">         service = self.service()
</span><span class="cx"> 
</span><del>-        record = (yield service.recordWithUID(&quot;__wsanchez__&quot;))
</del><ins>+        record = (yield service.recordWithUID(u&quot;__wsanchez__&quot;))
</ins><span class="cx">         members = (yield record.members())
</span><span class="cx">         self.assertEquals(set(members), set())
</span><span class="cx"> 
</span><del>-        record = (yield service.recordWithUID(&quot;__twisted__&quot;))
</del><ins>+        record = (yield service.recordWithUID(u&quot;__twisted__&quot;))
</ins><span class="cx">         members = (yield record.members())
</span><span class="cx">         self.assertEquals(
</span><span class="cx">             set((member.uid for member in members)),
</span><span class="cx">             set((
</span><del>-                &quot;__wsanchez__&quot;,
-                &quot;__glyph__&quot;,
-                &quot;__exarkun__&quot;,
-                &quot;__dreid__&quot;,
-                &quot;__dre__&quot;,
</del><ins>+                u&quot;__wsanchez__&quot;,
+                u&quot;__glyph__&quot;,
+                u&quot;__exarkun__&quot;,
+                u&quot;__dreid__&quot;,
+                u&quot;__dre__&quot;,
</ins><span class="cx">             ))
</span><span class="cx">         )
</span><span class="cx"> 
</span><del>-        record = (yield service.recordWithUID(&quot;__developers__&quot;))
</del><ins>+        record = (yield service.recordWithUID(u&quot;__developers__&quot;))
</ins><span class="cx">         members = (yield record.members())
</span><span class="cx">         self.assertEquals(
</span><span class="cx">             set((member.uid for member in members)),
</span><span class="cx">             set((
</span><del>-                &quot;__calendar-dev__&quot;,
-                &quot;__twisted__&quot;,
-                &quot;__alyssa__&quot;,
</del><ins>+                u&quot;__calendar-dev__&quot;,
+                u&quot;__twisted__&quot;,
+                u&quot;__alyssa__&quot;,
</ins><span class="cx">             ))
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -763,13 +764,13 @@
</span><span class="cx">     def test_groups(self):
</span><span class="cx">         service = self.service()
</span><span class="cx"> 
</span><del>-        record = (yield service.recordWithUID(&quot;__wsanchez__&quot;))
</del><ins>+        record = (yield service.recordWithUID(u&quot;__wsanchez__&quot;))
</ins><span class="cx">         groups = (yield record.groups())
</span><span class="cx">         self.assertEquals(
</span><span class="cx">             set(group.uid for group in groups),
</span><span class="cx">             set((
</span><del>-                &quot;__calendar-dev__&quot;,
-                &quot;__twisted__&quot;,
</del><ins>+                u&quot;__calendar-dev__&quot;,
+                u&quot;__twisted__&quot;,
</ins><span class="cx">             ))
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -806,7 +807,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-testXMLConfig = &quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
</del><ins>+testXMLConfig = b&quot;&quot;&quot;&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
</ins><span class="cx"> 
</span><span class="cx"> &lt;directory realm=&quot;xyzzy&quot;&gt;
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktwextwhoxmlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/xml.py (11895 => 11896)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/xml.py        2013-11-06 22:20:51 UTC (rev 11895)
+++ CalendarServer/trunk/twext/who/xml.py        2013-11-06 22:52:10 UTC (rev 11896)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> ]
</span><span class="cx"> 
</span><span class="cx"> from time import time
</span><ins>+from uuid import UUID
</ins><span class="cx"> 
</span><span class="cx"> from xml.etree.ElementTree import parse as parseXML
</span><span class="cx"> from xml.etree.ElementTree import ParseError as XMLParseError
</span><span class="lines">@@ -62,38 +63,38 @@
</span><span class="cx"> ##
</span><span class="cx"> 
</span><span class="cx"> class Element(Values):
</span><del>-    directory = ValueConstant(&quot;directory&quot;)
-    record    = ValueConstant(&quot;record&quot;)
</del><ins>+    directory = ValueConstant(u&quot;directory&quot;)
+    record    = ValueConstant(u&quot;record&quot;)
</ins><span class="cx"> 
</span><span class="cx">     #
</span><span class="cx">     # Field names
</span><span class="cx">     #
</span><del>-    uid = ValueConstant(&quot;uid&quot;)
</del><ins>+    uid = ValueConstant(u&quot;uid&quot;)
</ins><span class="cx">     uid.fieldName = BaseFieldName.uid
</span><span class="cx"> 
</span><del>-    guid = ValueConstant(&quot;guid&quot;)
</del><ins>+    guid = ValueConstant(u&quot;guid&quot;)
</ins><span class="cx">     guid.fieldName = BaseFieldName.guid
</span><span class="cx"> 
</span><del>-    shortName = ValueConstant(&quot;short-name&quot;)
</del><ins>+    shortName = ValueConstant(u&quot;short-name&quot;)
</ins><span class="cx">     shortName.fieldName = BaseFieldName.shortNames
</span><span class="cx"> 
</span><del>-    fullName = ValueConstant(&quot;full-name&quot;)
</del><ins>+    fullName = ValueConstant(u&quot;full-name&quot;)
</ins><span class="cx">     fullName.fieldName = BaseFieldName.fullNames
</span><span class="cx"> 
</span><del>-    emailAddress = ValueConstant(&quot;email&quot;)
</del><ins>+    emailAddress = ValueConstant(u&quot;email&quot;)
</ins><span class="cx">     emailAddress.fieldName = BaseFieldName.emailAddresses
</span><span class="cx"> 
</span><del>-    password = ValueConstant(&quot;password&quot;)
</del><ins>+    password = ValueConstant(u&quot;password&quot;)
</ins><span class="cx">     password.fieldName = BaseFieldName.password
</span><span class="cx"> 
</span><del>-    memberUID = ValueConstant(&quot;member-uid&quot;)
</del><ins>+    memberUID = ValueConstant(u&quot;member-uid&quot;)
</ins><span class="cx">     memberUID.fieldName = IndexFieldName.memberUIDs
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> class Attribute(Values):
</span><del>-    realm      = ValueConstant(&quot;realm&quot;)
-    recordType = ValueConstant(&quot;type&quot;)
</del><ins>+    realm      = ValueConstant(u&quot;realm&quot;)
+    recordType = ValueConstant(u&quot;type&quot;)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -101,16 +102,16 @@
</span><span class="cx">     #
</span><span class="cx">     # Booleans
</span><span class="cx">     #
</span><del>-    true  = ValueConstant(&quot;true&quot;)
-    false = ValueConstant(&quot;false&quot;)
</del><ins>+    true  = ValueConstant(u&quot;true&quot;)
+    false = ValueConstant(u&quot;false&quot;)
</ins><span class="cx"> 
</span><span class="cx">     #
</span><span class="cx">     # Record types
</span><span class="cx">     #
</span><del>-    user = ValueConstant(&quot;user&quot;)
</del><ins>+    user = ValueConstant(u&quot;user&quot;)
</ins><span class="cx">     user.recordType = RecordType.user
</span><span class="cx"> 
</span><del>-    group = ValueConstant(&quot;group&quot;)
</del><ins>+    group = ValueConstant(u&quot;group&quot;)
</ins><span class="cx">     group.recordType = RecordType.group
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -235,8 +236,8 @@
</span><span class="cx">             )
</span><span class="cx"> 
</span><span class="cx">         realmName = directoryNode.get(
</span><del>-            self.attribute.realm.value, &quot;&quot;
-        ).encode(&quot;utf-8&quot;)
</del><ins>+            self.attribute.realm.value, u&quot;&quot;
+        )
</ins><span class="cx"> 
</span><span class="cx">         if not realmName:
</span><span class="cx">             raise ParseError(&quot;No realm name.&quot;)
</span><span class="lines">@@ -289,8 +290,8 @@
</span><span class="cx"> 
</span><span class="cx">     def parseRecordNode(self, recordNode, unknownFieldElements=None):
</span><span class="cx">         recordTypeAttribute = recordNode.get(
</span><del>-            self.attribute.recordType.value, &quot;&quot;
-        ).encode(&quot;utf-8&quot;)
</del><ins>+            self.attribute.recordType.value, u&quot;&quot;
+        )
</ins><span class="cx">         if recordTypeAttribute:
</span><span class="cx">             try:
</span><span class="cx">                 recordType = (
</span><span class="lines">@@ -317,8 +318,16 @@
</span><span class="cx">                 if unknownFieldElements is not None:
</span><span class="cx">                     unknownFieldElements.add(fieldNode.tag)
</span><span class="cx"> 
</span><del>-            value = fieldNode.text.encode(&quot;utf-8&quot;)
</del><ins>+            vType = BaseFieldName.valueType(fieldName)
</ins><span class="cx"> 
</span><ins>+            if vType in (unicode, UUID):
+                value = unicode(fieldNode.text)
+            else:
+                raise AssertionError(
+                    &quot;Unknown value type {0} for field {1}&quot;,
+                    vType, fieldName
+                )
+
</ins><span class="cx">             if BaseFieldName.isMultiValue(fieldName):
</span><span class="cx">                 values = fields.setdefault(fieldName, [])
</span><span class="cx">                 values.append(value)
</span></span></pre>
</div>
</div>

</body>
</html>