<!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>[11903] 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/11903">11903</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2013-11-07 11:10:12 -0800 (Thu, 07 Nov 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Better type handling:
 * Field values have an expected type.
   * Most are (default is) `unicode`.
   * guid is `UUID`.
 * Be explicit about string types everywhere.

Add CompoundExpression class.</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="#CalendarServertrunktwextwhoindexpy">CalendarServer/trunk/twext/who/index.py</a></li>
<li><a href="#CalendarServertrunktwextwhotesttest_aggregatepy">CalendarServer/trunk/twext/who/test/test_aggregate.py</a></li>
<li><a href="#CalendarServertrunktwextwhotesttest_directorypy">CalendarServer/trunk/twext/who/test/test_directory.py</a></li>
<li><a href="#CalendarServertrunktwextwhotesttest_expressionpy">CalendarServer/trunk/twext/who/test/test_expression.py</a></li>
<li><a href="#CalendarServertrunktwextwhotesttest_utilpy">CalendarServer/trunk/twext/who/test/test_util.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 (11902 => 11903)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/directory.py        2013-11-07 18:24:00 UTC (rev 11902)
+++ CalendarServer/trunk/twext/who/directory.py        2013-11-07 19:10:12 UTC (rev 11903)
</span><span class="lines">@@ -92,7 +92,7 @@
</span><span class="cx">     def __init__(self, realmName):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         @param realmName: a realm name
</span><del>-        @type realmName: unicode
</del><ins>+        @type realmName: L{unicode}
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         self.realmName = realmName
</span><span class="cx"> 
</span><span class="lines">@@ -337,25 +337,31 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def description(self):
</span><del>-        description = [self.__class__.__name__, &quot;:&quot;]
</del><ins>+        &quot;&quot;&quot;
+        Generate a string description of this directory record.
</ins><span class="cx"> 
</span><ins>+        @return: A description.
+        @rtype: L{unicode}
+        &quot;&quot;&quot;
+        description = [self.__class__.__name__, u&quot;:&quot;]
+
</ins><span class="cx">         for name, value in self.fields.items():
</span><span class="cx">             if hasattr(name, &quot;description&quot;):
</span><span class="cx">                 name = name.description
</span><span class="cx">             else:
</span><del>-                name = str(name)
</del><ins>+                name = unicode(name)
</ins><span class="cx"> 
</span><span class="cx">             if hasattr(value, &quot;description&quot;):
</span><span class="cx">                 value = value.description
</span><span class="cx">             else:
</span><del>-                value = str(value)
</del><ins>+                value = unicode(value)
</ins><span class="cx"> 
</span><del>-            description.append(&quot;\n  &quot;)
</del><ins>+            description.append(u&quot;\n  &quot;)
</ins><span class="cx">             description.append(name)
</span><del>-            description.append(&quot; = &quot;)
</del><ins>+            description.append(u&quot; = &quot;)
</ins><span class="cx">             description.append(value)
</span><span class="cx"> 
</span><del>-        return &quot;&quot;.join(description)
</del><ins>+        return u&quot;&quot;.join(description)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def members(self):
</span></span></pre></div>
<a id="CalendarServertrunktwextwhoexpressionpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/expression.py (11902 => 11903)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/expression.py        2013-11-07 18:24:00 UTC (rev 11902)
+++ CalendarServer/trunk/twext/who/expression.py        2013-11-07 19:10:12 UTC (rev 11903)
</span><span class="lines">@@ -20,6 +20,8 @@
</span><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx"> __all__ = [
</span><ins>+    &quot;CompoundExpression&quot;,
+
</ins><span class="cx">     &quot;MatchType&quot;,
</span><span class="cx">     &quot;MatchFlags&quot;,
</span><span class="cx">     &quot;MatchExpression&quot;,
</span><span class="lines">@@ -30,12 +32,28 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-##
-# Match expression
-##
</del><ins>+#
+# Compound expression
+#
</ins><span class="cx"> 
</span><ins>+class CompoundExpression(object):
+    &quot;&quot;&quot;
+    An expression that groups multiple expressions with an operand.
</ins><span class="cx"> 
</span><ins>+    @ivar expressions: An iterable of expressions.
</ins><span class="cx"> 
</span><ins>+    @ivar operand: A L{NamedConstant} specifying an operand.
+    &quot;&quot;&quot;
+
+    def __init__(self, expressions, operand):
+        self.expressions = expressions
+        self.operand = operand
+
+
+#
+# Match expression
+#
+
</ins><span class="cx"> class MatchType(Names):
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     Query match types.
</span><span class="lines">@@ -44,9 +62,9 @@
</span><span class="cx">     startsWith = NamedConstant()
</span><span class="cx">     contains   = NamedConstant()
</span><span class="cx"> 
</span><del>-    equals.description     = &quot;equals&quot;
-    startsWith.description = &quot;starts with&quot;
-    contains.description   = &quot;contains&quot;
</del><ins>+    equals.description     = u&quot;equals&quot;
+    startsWith.description = u&quot;starts with&quot;
+    contains.description   = u&quot;contains&quot;
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -55,10 +73,10 @@
</span><span class="cx">     Match expression flags.
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx">     NOT = FlagConstant()
</span><del>-    NOT.description = &quot;not&quot;
</del><ins>+    NOT.description = u&quot;not&quot;
</ins><span class="cx"> 
</span><span class="cx">     caseInsensitive = FlagConstant()
</span><del>-    caseInsensitive.description = &quot;case insensitive&quot;
</del><ins>+    caseInsensitive.description = u&quot;case insensitive&quot;
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -88,7 +106,7 @@
</span><span class="cx"> 
</span><span class="cx">     def __repr__(self):
</span><span class="cx">         def describe(constant):
</span><del>-            return getattr(constant, &quot;description&quot;, str(constant))
</del><ins>+            return getattr(constant, &quot;description&quot;, unicode(constant))
</ins><span class="cx"> 
</span><span class="cx">         if self.flags is None:
</span><span class="cx">             flags = &quot;&quot;
</span></span></pre></div>
<a id="CalendarServertrunktwextwhoidirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/idirectory.py (11902 => 11903)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/idirectory.py        2013-11-07 18:24:00 UTC (rev 11902)
+++ CalendarServer/trunk/twext/who/idirectory.py        2013-11-07 19:10:12 UTC (rev 11903)
</span><span class="lines">@@ -16,7 +16,7 @@
</span><span class="cx"> ##
</span><span class="cx"> 
</span><span class="cx"> &quot;&quot;&quot;
</span><del>-Directory service interface.
</del><ins>+Directory service interfaces.
</ins><span class="cx"> &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="cx"> __all__ = [
</span><span class="lines">@@ -111,8 +111,8 @@
</span><span class="cx">     user  = NamedConstant()
</span><span class="cx">     group = NamedConstant()
</span><span class="cx"> 
</span><del>-    user.description  = &quot;user&quot;
-    group.description = &quot;group&quot;
</del><ins>+    user.description  = u&quot;user&quot;
+    group.description = u&quot;group&quot;
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -152,13 +152,13 @@
</span><span class="cx">     emailAddresses = NamedConstant()
</span><span class="cx">     password       = NamedConstant()
</span><span class="cx"> 
</span><del>-    uid.description            = &quot;UID&quot;
-    guid.description           = &quot;GUID&quot;
-    recordType.description     = &quot;record type&quot;
-    shortNames.description     = &quot;short names&quot;
-    fullNames.description      = &quot;full names&quot;
-    emailAddresses.description = &quot;email addresses&quot;
-    password.description       = &quot;password&quot;
</del><ins>+    uid.description            = u&quot;UID&quot;
+    guid.description           = u&quot;GUID&quot;
+    recordType.description     = u&quot;record type&quot;
+    shortNames.description     = u&quot;short names&quot;
+    fullNames.description      = u&quot;full names&quot;
+    emailAddresses.description = u&quot;email addresses&quot;
+    password.description       = u&quot;password&quot;
</ins><span class="cx"> 
</span><span class="cx">     guid.valueType = UUID
</span><span class="cx"> 
</span><span class="lines">@@ -203,8 +203,8 @@
</span><span class="cx">     OR  = NamedConstant()
</span><span class="cx">     AND = NamedConstant()
</span><span class="cx"> 
</span><del>-    OR.description  = &quot;or&quot;
-    AND.description = &quot;and&quot;
</del><ins>+    OR.description  = u&quot;or&quot;
+    AND.description = u&quot;and&quot;
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktwextwhoindexpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/index.py (11902 => 11903)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/index.py        2013-11-07 18:24:00 UTC (rev 11902)
+++ CalendarServer/trunk/twext/who/index.py        2013-11-07 19:10:12 UTC (rev 11903)
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx"> 
</span><span class="cx"> class FieldName(Names):
</span><span class="cx">     memberUIDs = NamedConstant()
</span><del>-    memberUIDs.description = &quot;member UIDs&quot;
</del><ins>+    memberUIDs.description = u&quot;member UIDs&quot;
</ins><span class="cx">     memberUIDs.multiValue = True
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre></div>
<a id="CalendarServertrunktwextwhotesttest_aggregatepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/test/test_aggregate.py (11902 => 11903)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/test/test_aggregate.py        2013-11-07 18:24:00 UTC (rev 11902)
+++ CalendarServer/trunk/twext/who/test/test_aggregate.py        2013-11-07 19:10:12 UTC (rev 11903)
</span><span class="lines">@@ -49,7 +49,7 @@
</span><span class="cx">         class TestService(DirectoryService, QueryMixIn):
</span><span class="cx">             pass
</span><span class="cx"> 
</span><del>-        return TestService(&quot;xyzzy&quot;, services)
</del><ins>+        return TestService(u&quot;xyzzy&quot;, services)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def xmlService(self, xmlData=None, serviceClass=None):
</span><span class="lines">@@ -60,7 +60,7 @@
</span><span class="cx"> class DirectoryServiceBaseTest(BaseTest, test_xml.DirectoryServiceBaseTest):
</span><span class="cx">     def test_repr(self):
</span><span class="cx">         service = self.service()
</span><del>-        self.assertEquals(repr(service), &quot;&lt;TestService 'xyzzy'&gt;&quot;)
</del><ins>+        self.assertEquals(repr(service), &quot;&lt;TestService u'xyzzy'&gt;&quot;)
</ins><span class="cx"> 
</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 (11902 => 11903)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/test/test_directory.py        2013-11-07 18:24:00 UTC (rev 11902)
+++ CalendarServer/trunk/twext/who/test/test_directory.py        2013-11-07 19:10:12 UTC (rev 11903)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> class ServiceMixIn(object):
</span><del>-    realmName = &quot;xyzzy&quot;
</del><ins>+    realmName = u&quot;xyzzy&quot;
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def service(self):
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx"> 
</span><span class="cx">     def test_repr(self):
</span><span class="cx">         service = self.service()
</span><del>-        self.assertEquals(repr(service), &quot;&lt;DirectoryService 'xyzzy'&gt;&quot;)
</del><ins>+        self.assertEquals(repr(service), &quot;&lt;DirectoryService u'xyzzy'&gt;&quot;)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def test_recordTypes(self):
</span><span class="lines">@@ -161,9 +161,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">@@ -183,7 +183,7 @@
</span><span class="cx"> 
</span><span class="cx">         service.removeRecords(())
</span><span class="cx">         self.assertFailure(
</span><del>-            service.removeRecords((&quot;foo&quot;,)),
</del><ins>+            service.removeRecords((u&quot;foo&quot;,)),
</ins><span class="cx">             NotAllowedError,
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="lines">@@ -199,41 +199,41 @@
</span><span class="cx"> 
</span><span class="cx"> class BaseDirectoryRecordTest(ServiceMixIn):
</span><span class="cx">     fields_wsanchez = {
</span><del>-        FieldName.uid: &quot;UID:wsanchez&quot;,
</del><ins>+        FieldName.uid: u&quot;UID:wsanchez&quot;,
</ins><span class="cx">         FieldName.recordType: RecordType.user,
</span><del>-        FieldName.shortNames: (&quot;wsanchez&quot;, &quot;wilfredo_sanchez&quot;),
</del><ins>+        FieldName.shortNames: (u&quot;wsanchez&quot;, u&quot;wilfredo_sanchez&quot;),
</ins><span class="cx">         FieldName.fullNames: (
</span><del>-            &quot;Wilfredo Sanchez&quot;,
-            &quot;Wilfredo Sanchez Vega&quot;,
</del><ins>+            u&quot;Wilfredo Sanchez&quot;,
+            u&quot;Wilfredo Sanchez Vega&quot;,
</ins><span class="cx">         ),
</span><span class="cx">         FieldName.emailAddresses: (
</span><del>-            &quot;wsanchez@calendarserver.org&quot;,
-            &quot;wsanchez@example.com&quot;,
</del><ins>+            u&quot;wsanchez@calendarserver.org&quot;,
+            u&quot;wsanchez@example.com&quot;,
</ins><span class="cx">         )
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     fields_glyph = {
</span><del>-        FieldName.uid: &quot;UID:glyph&quot;,
</del><ins>+        FieldName.uid: u&quot;UID:glyph&quot;,
</ins><span class="cx">         FieldName.recordType: RecordType.user,
</span><del>-        FieldName.shortNames: (&quot;glyph&quot;,),
-        FieldName.fullNames: (&quot;Glyph Lefkowitz&quot;,),
-        FieldName.emailAddresses: (&quot;glyph@calendarserver.org&quot;,)
</del><ins>+        FieldName.shortNames: (u&quot;glyph&quot;,),
+        FieldName.fullNames: (u&quot;Glyph Lefkowitz&quot;,),
+        FieldName.emailAddresses: (u&quot;glyph@calendarserver.org&quot;,)
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     fields_sagen = {
</span><del>-        FieldName.uid: &quot;UID:sagen&quot;,
</del><ins>+        FieldName.uid: u&quot;UID:sagen&quot;,
</ins><span class="cx">         FieldName.recordType: RecordType.user,
</span><del>-        FieldName.shortNames: (&quot;sagen&quot;,),
-        FieldName.fullNames: (&quot;Morgen Sagen&quot;,),
-        FieldName.emailAddresses: (&quot;sagen@CalendarServer.org&quot;,)
</del><ins>+        FieldName.shortNames: (u&quot;sagen&quot;,),
+        FieldName.fullNames: (u&quot;Morgen Sagen&quot;,),
+        FieldName.emailAddresses: (u&quot;sagen@CalendarServer.org&quot;,)
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     fields_staff = {
</span><del>-        FieldName.uid: &quot;UID:staff&quot;,
</del><ins>+        FieldName.uid: u&quot;UID:staff&quot;,
</ins><span class="cx">         FieldName.recordType: RecordType.group,
</span><del>-        FieldName.shortNames: (&quot;staff&quot;,),
-        FieldName.fullNames: (&quot;Staff&quot;,),
-        FieldName.emailAddresses: (&quot;staff@CalendarServer.org&quot;,)
</del><ins>+        FieldName.shortNames: (u&quot;staff&quot;,),
+        FieldName.fullNames: (u&quot;Staff&quot;,),
+        FieldName.emailAddresses: (u&quot;staff@CalendarServer.org&quot;,)
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -267,7 +267,7 @@
</span><span class="cx">         self.assertRaises(ValueError, self.makeRecord, fields)
</span><span class="cx"> 
</span><span class="cx">         fields = self.fields_wsanchez.copy()
</span><del>-        fields[FieldName.uid] = &quot;&quot;
</del><ins>+        fields[FieldName.uid] = u&quot;&quot;
</ins><span class="cx">         self.assertRaises(ValueError, self.makeRecord, fields)
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -277,7 +277,7 @@
</span><span class="cx">         self.assertRaises(ValueError, self.makeRecord, fields)
</span><span class="cx"> 
</span><span class="cx">         fields = self.fields_wsanchez.copy()
</span><del>-        fields[FieldName.recordType] = &quot;&quot;
</del><ins>+        fields[FieldName.recordType] = None
</ins><span class="cx">         self.assertRaises(ValueError, self.makeRecord, fields)
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -291,11 +291,11 @@
</span><span class="cx">         self.assertRaises(ValueError, self.makeRecord, fields)
</span><span class="cx"> 
</span><span class="cx">         fields = self.fields_wsanchez.copy()
</span><del>-        fields[FieldName.shortNames] = (&quot;&quot;,)
</del><ins>+        fields[FieldName.shortNames] = (u&quot;&quot;,)
</ins><span class="cx">         self.assertRaises(ValueError, self.makeRecord, fields)
</span><span class="cx"> 
</span><span class="cx">         fields = self.fields_wsanchez.copy()
</span><del>-        fields[FieldName.shortNames] = (&quot;wsanchez&quot;, &quot;&quot;)
</del><ins>+        fields[FieldName.shortNames] = (u&quot;wsanchez&quot;, u&quot;&quot;)
</ins><span class="cx">         self.assertRaises(ValueError, self.makeRecord, fields)
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -310,7 +310,7 @@
</span><span class="cx"> 
</span><span class="cx">         self.assertEquals(
</span><span class="cx">             sagen.fields[FieldName.emailAddresses],
</span><del>-            (&quot;sagen@calendarserver.org&quot;,)
</del><ins>+            (u&quot;sagen@calendarserver.org&quot;,)
</ins><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -318,7 +318,7 @@
</span><span class="cx">         fields_glyphmod = self.fields_glyph.copy()
</span><span class="cx">         del fields_glyphmod[FieldName.emailAddresses]
</span><span class="cx"> 
</span><del>-        plugh = DirectoryService(&quot;plugh&quot;)
</del><ins>+        plugh = DirectoryService(u&quot;plugh&quot;)
</ins><span class="cx"> 
</span><span class="cx">         wsanchez    = self.makeRecord(self.fields_wsanchez)
</span><span class="cx">         wsanchezmod = self.makeRecord(self.fields_wsanchez, plugh)
</span></span></pre></div>
<a id="CalendarServertrunktwextwhotesttest_expressionpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/test/test_expression.py (11902 => 11903)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/test/test_expression.py        2013-11-07 18:24:00 UTC (rev 11902)
+++ CalendarServer/trunk/twext/who/test/test_expression.py        2013-11-07 19:10:12 UTC (rev 11903)
</span><span class="lines">@@ -26,29 +26,31 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> class MatchExpressionTest(unittest.TestCase):
</span><del>-    def test_repr(self):
</del><ins>+    def test_repr_name(self):
</ins><span class="cx">         self.assertEquals(
</span><del>-            &quot;&lt;MatchExpression: 'full names' equals 'Wilfredo Sanchez'&gt;&quot;,
</del><ins>+            &quot;&lt;MatchExpression: u'full names' equals u'Wilfredo Sanchez'&gt;&quot;,
</ins><span class="cx">             repr(MatchExpression(
</span><span class="cx">                 FieldName.fullNames,
</span><del>-                &quot;Wilfredo Sanchez&quot;,
</del><ins>+                u&quot;Wilfredo Sanchez&quot;,
</ins><span class="cx">             )),
</span><span class="cx">         )
</span><span class="cx"> 
</span><ins>+    def test_repr_type(self):
</ins><span class="cx">         self.assertEquals(
</span><del>-            &quot;&lt;MatchExpression: 'full names' contains 'Sanchez'&gt;&quot;,
</del><ins>+            &quot;&lt;MatchExpression: u'full names' contains u'Sanchez'&gt;&quot;,
</ins><span class="cx">             repr(MatchExpression(
</span><span class="cx">                 FieldName.fullNames,
</span><del>-                &quot;Sanchez&quot;,
</del><ins>+                u&quot;Sanchez&quot;,
</ins><span class="cx">                 matchType=MatchType.contains,
</span><span class="cx">             )),
</span><span class="cx">         )
</span><span class="cx"> 
</span><ins>+    def test_repr_flags(self):
</ins><span class="cx">         self.assertEquals(
</span><del>-            &quot;&lt;MatchExpression: 'full names' starts with 'Wilfredo' (not)&gt;&quot;,
</del><ins>+            &quot;&lt;MatchExpression: u'full names' starts with u'Wilfredo' (not)&gt;&quot;,
</ins><span class="cx">             repr(MatchExpression(
</span><span class="cx">                 FieldName.fullNames,
</span><del>-                &quot;Wilfredo&quot;,
</del><ins>+                u&quot;Wilfredo&quot;,
</ins><span class="cx">                 matchType=MatchType.startsWith,
</span><span class="cx">                 flags=MatchFlags.NOT,
</span><span class="cx">             )),
</span></span></pre></div>
<a id="CalendarServertrunktwextwhotesttest_utilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/test/test_util.py (11902 => 11903)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/test/test_util.py        2013-11-07 18:24:00 UTC (rev 11902)
+++ CalendarServer/trunk/twext/who/test/test_util.py        2013-11-07 19:10:12 UTC (rev 11903)
</span><span class="lines">@@ -29,11 +29,11 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> class Tools(Names):
</span><del>-    hammer      = NamedConstant()
</del><ins>+    hammer = NamedConstant()
</ins><span class="cx">     screwdriver = NamedConstant()
</span><span class="cx"> 
</span><del>-    hammer.description      = &quot;nail pounder&quot;
-    screwdriver.description = &quot;screw twister&quot;
</del><ins>+    hammer.description = u&quot;nail pounder&quot;
+    screwdriver.description = u&quot;screw twister&quot;
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -48,9 +48,9 @@
</span><span class="cx">     g = FlagConstant()
</span><span class="cx">     b = FlagConstant()
</span><span class="cx"> 
</span><del>-    r.description = &quot;red&quot;
-    g.description = &quot;green&quot;
-    b.description = &quot;blue&quot;
</del><ins>+    r.description = u&quot;red&quot;
+    g.description = u&quot;green&quot;
+    b.description = u&quot;blue&quot;
</ins><span class="cx"> 
</span><span class="cx">     black = FlagConstant()
</span><span class="cx"> 
</span><span class="lines">@@ -115,10 +115,10 @@
</span><span class="cx">         self.assertRaises(DirectoryServiceError, uniqueResult, (1, 2, 3))
</span><span class="cx"> 
</span><span class="cx">     def test_describe(self):
</span><del>-        self.assertEquals(&quot;nail pounder&quot;, describe(Tools.hammer))
-        self.assertEquals(&quot;hammer&quot;, describe(Instruments.hammer))
</del><ins>+        self.assertEquals(u&quot;nail pounder&quot;, describe(Tools.hammer))
+        self.assertEquals(u&quot;hammer&quot;, describe(Instruments.hammer))
</ins><span class="cx"> 
</span><span class="cx">     def test_describeFlags(self):
</span><del>-        self.assertEquals(&quot;blue&quot;, describe(Switches.b))
-        self.assertEquals(&quot;red|green&quot;, describe(Switches.r | Switches.g))
-        self.assertEquals(&quot;blue|black&quot;, describe(Switches.b | Switches.black))
</del><ins>+        self.assertEquals(u&quot;blue&quot;, describe(Switches.b))
+        self.assertEquals(u&quot;red|green&quot;, describe(Switches.r | Switches.g))
+        self.assertEquals(u&quot;blue|black&quot;, describe(Switches.b | Switches.black))
</ins></span></pre></div>
<a id="CalendarServertrunktwextwhotesttest_xmlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/test/test_xml.py (11902 => 11903)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/test/test_xml.py        2013-11-07 18:24:00 UTC (rev 11902)
+++ CalendarServer/trunk/twext/who/test/test_xml.py        2013-11-07 19:10:12 UTC (rev 11903)
</span><span class="lines">@@ -57,7 +57,7 @@
</span><span class="cx"> 
</span><span class="cx">         self.assertEquals(repr(service), &quot;&lt;TestService (not loaded)&gt;&quot;)
</span><span class="cx">         service.loadRecords()
</span><del>-        self.assertEquals(repr(service), &quot;&lt;TestService 'xyzzy'&gt;&quot;)
</del><ins>+        self.assertEquals(repr(service), &quot;&lt;TestService u'xyzzy'&gt;&quot;)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @inlineCallbacks
</span></span></pre></div>
<a id="CalendarServertrunktwextwhoxmlpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twext/who/xml.py (11902 => 11903)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twext/who/xml.py        2013-11-07 18:24:00 UTC (rev 11902)
+++ CalendarServer/trunk/twext/who/xml.py        2013-11-07 19:10:12 UTC (rev 11903)
</span><span class="lines">@@ -235,9 +235,9 @@
</span><span class="cx">                 &quot;Incorrect root element: {0}&quot;.format(directoryNode.tag)
</span><span class="cx">             )
</span><span class="cx"> 
</span><del>-        realmName = directoryNode.get(
</del><ins>+        realmName = unicode(directoryNode.get(
</ins><span class="cx">             self.attribute.realm.value, u&quot;&quot;
</span><del>-        )
</del><ins>+        ))
</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">@@ -321,7 +321,7 @@
</span><span class="cx">             vType = BaseFieldName.valueType(fieldName)
</span><span class="cx"> 
</span><span class="cx">             if vType in (unicode, UUID):
</span><del>-                value = unicode(fieldNode.text)
</del><ins>+                value = vType(fieldNode.text)
</ins><span class="cx">             else:
</span><span class="cx">                 raise AssertionError(
</span><span class="cx">                     &quot;Unknown value type {0} for field {1}&quot;,
</span></span></pre>
</div>
</div>

</body>
</html>