<!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>[12981] CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py</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/12981">12981</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2014-03-19 18:36:19 -0700 (Wed, 19 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Undo 12980 for this file</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserssagenmove2who4txdavwhodirectorypy">CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserssagenmove2who4txdavwhodirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py (12980 => 12981)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py        2014-03-20 01:29:32 UTC (rev 12980)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py        2014-03-20 01:36:19 UTC (rev 12981)
</span><span class="lines">@@ -42,13 +42,12 @@
</span><span class="cx"> 
</span><span class="cx"> class CalendarDirectoryServiceMixin(object):
</span><span class="cx"> 
</span><del>-    guid = u&quot;1332A615-4D3A-41FE-B636-FBE25BFB982E&quot;
</del><ins>+    guid = &quot;1332A615-4D3A-41FE-B636-FBE25BFB982E&quot;
</ins><span class="cx"> 
</span><span class="cx">     # Must maintain the hack for a bit longer:
</span><span class="cx">     def setPrincipalCollection(self, principalCollection):
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        Set the principal service that the directory relies on for doing proxy
-        tests.
</del><ins>+        Set the principal service that the directory relies on for doing proxy tests.
</ins><span class="cx"> 
</span><span class="cx">         @param principalService: the principal service.
</span><span class="cx">         @type principalService: L{DirectoryProvisioningResource}
</span><span class="lines">@@ -62,26 +61,24 @@
</span><span class="cx">         from txdav.caldav.datastore.scheduling.cuaddress import normalizeCUAddr
</span><span class="cx">         address = normalizeCUAddr(address)
</span><span class="cx">         record = None
</span><del>-        if address.startswith(u&quot;urn:uuid:&quot;):
</del><ins>+        if address.startswith(&quot;urn:uuid:&quot;):
</ins><span class="cx">             guid = address[9:]
</span><span class="cx">             record = yield self.recordWithGUID(uuid.UUID(guid))
</span><del>-        elif address.startswith(u&quot;mailto:&quot;):
</del><ins>+        elif address.startswith(&quot;mailto:&quot;):
</ins><span class="cx">             records = yield self.recordsWithEmailAddress(address[7:])
</span><span class="cx">             if records:
</span><span class="cx">                 returnValue(records[0])
</span><span class="cx">             else:
</span><span class="cx">                 returnValue(None)
</span><del>-        elif address.startswith(u&quot;/principals/&quot;):
-            parts = address.split(u&quot;/&quot;)
</del><ins>+        elif address.startswith(&quot;/principals/&quot;):
+            parts = address.split(&quot;/&quot;)
</ins><span class="cx">             if len(parts) == 4:
</span><del>-                if parts[2] == u&quot;__uids__&quot;:
</del><ins>+                if parts[2] == &quot;__uids__&quot;:
</ins><span class="cx">                     uid = parts[3]
</span><span class="cx">                     record = yield self.recordWithUID(uid)
</span><span class="cx">                 else:
</span><span class="cx">                     recordType = self.fieldName.lookupByName(parts[2])
</span><del>-                    record = (
-                        yield self.recordWithShortName(recordType, parts[3])
-                    )
</del><ins>+                    record = yield self.recordWithShortName(recordType, parts[3])
</ins><span class="cx"> 
</span><span class="cx">         returnValue(record if record and record.hasCalendars else None)
</span><span class="cx"> 
</span><span class="lines">@@ -89,8 +86,8 @@
</span><span class="cx">     def recordsMatchingTokens(self, tokens, context=None, limitResults=50,
</span><span class="cx">                               timeoutSeconds=10):
</span><span class="cx">         fields = [
</span><del>-            (u&quot;fullNames&quot;, MatchType.contains),
-            (u&quot;emailAddresses&quot;, MatchType.startsWith),
</del><ins>+            (&quot;fullNames&quot;, MatchType.contains),
+            (&quot;emailAddresses&quot;, MatchType.startsWith),
</ins><span class="cx">         ]
</span><span class="cx">         outer = []
</span><span class="cx">         for token in tokens:
</span><span class="lines">@@ -126,9 +123,7 @@
</span><span class="cx">         )
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def recordsMatchingFields(
-        self, fields, operand=Operand.OR, recordType=None
-    ):
</del><ins>+    def recordsMatchingFields(self, fields, operand=Operand.OR, recordType=None):
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         @param fields: a iterable of tuples, each tuple consisting of:
</span><span class="cx">             directory field name (C{unicode})
</span><span class="lines">@@ -175,15 +170,15 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     _oldRecordTypeNames = {
</span><del>-        u&quot;address&quot;: u&quot;addresses&quot;,
-        u&quot;group&quot;: u&quot;groups&quot;,
-        u&quot;location&quot;: u&quot;locations&quot;,
-        u&quot;resource&quot;: u&quot;resources&quot;,
-        u&quot;user&quot;: u&quot;users&quot;,
-        u&quot;readDelegateGroup&quot;: u&quot;readDelegateGroups&quot;,
-        u&quot;writeDelegateGroup&quot;: u&quot;writeDelegateGroups&quot;,
-        u&quot;readDelegatorGroup&quot;: u&quot;readDelegatorGroups&quot;,
-        u&quot;writeDelegatorGroup&quot;: u&quot;writeDelegatorGroups&quot;,
</del><ins>+        &quot;address&quot;: &quot;addresses&quot;,
+        &quot;group&quot;: &quot;groups&quot;,
+        &quot;location&quot;: &quot;locations&quot;,
+        &quot;resource&quot;: &quot;resources&quot;,
+        &quot;user&quot;: &quot;users&quot;,
+        &quot;readDelegateGroup&quot;: &quot;readDelegateGroups&quot;,
+        &quot;writeDelegateGroup&quot;: &quot;writeDelegateGroups&quot;,
+        &quot;readDelegatorGroup&quot;: &quot;readDelegatorGroups&quot;,
+        &quot;writeDelegatorGroup&quot;: &quot;writeDelegatorGroups&quot;,
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     # FIXME: Existing code assumes record type names are plural. Is there any
</span><span class="lines">@@ -217,8 +212,8 @@
</span><span class="cx"> 
</span><span class="cx">         elif isinstance(credentials, DigestedCredentials):
</span><span class="cx">             log.debug(&quot;DigestedCredentials&quot;)
</span><del>-            returnValue((
-                yield self.verifyHTTPDigest(
</del><ins>+            returnValue(
+                (yield self.verifyHTTPDigest(
</ins><span class="cx">                     self.shortNames[0],
</span><span class="cx">                     self.service.realmName,
</span><span class="cx">                     credentials.fields[&quot;uri&quot;],
</span><span class="lines">@@ -229,8 +224,8 @@
</span><span class="cx">                     credentials.fields.get(&quot;qop&quot;, &quot;&quot;),
</span><span class="cx">                     credentials.fields[&quot;response&quot;],
</span><span class="cx">                     credentials.method
</span><del>-                )
-            ))
</del><ins>+                ))
+            )
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @property
</span><span class="lines">@@ -239,10 +234,10 @@
</span><span class="cx">             return frozenset()
</span><span class="cx"> 
</span><span class="cx">         try:
</span><del>-            cuas = set([
-                u&quot;mailto:{}&quot;.format(emailAddress)
-                for emailAddress in self.emailAddresses
-            ])
</del><ins>+            cuas = set(
+                [&quot;mailto:%s&quot; % (emailAddress,)
+                 for emailAddress in self.emailAddresses]
+            )
</ins><span class="cx">         except AttributeError:
</span><span class="cx">             cuas = set()
</span><span class="cx"> 
</span><span class="lines">@@ -252,32 +247,30 @@
</span><span class="cx">                     guid = unicode(self.guid).upper()
</span><span class="cx">                 else:
</span><span class="cx">                     guid = self.guid
</span><del>-                cuas.add(u&quot;urn:uuid:{guid}&quot;.format(guid=guid))
</del><ins>+                cuas.add(&quot;urn:uuid:{guid}&quot;.format(guid=guid))
</ins><span class="cx">         except AttributeError:
</span><span class="cx">             # No guid
</span><span class="cx">             pass
</span><del>-        cuas.add(u&quot;/principals/__uids__/{uid}/&quot;.format(uid=self.uid))
</del><ins>+        cuas.add(&quot;/principals/__uids__/{uid}/&quot;.format(uid=self.uid))
</ins><span class="cx">         for shortName in self.shortNames:
</span><del>-            cuas.add(
-                u&quot;/principals/{rt}/{sn}/&quot;.format(
-                    rt=self.service.recordTypeToOldName(self.recordType),
-                    sn=shortName
-                )
</del><ins>+            cuas.add(&quot;/principals/{rt}/{sn}/&quot;.format(
+                rt=self.service.recordTypeToOldName(self.recordType),
+                sn=shortName)
</ins><span class="cx">             )
</span><span class="cx">         return frozenset(cuas)
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     # Mapping from directory record.recordType to RFC2445 CUTYPE values
</span><span class="cx">     _cuTypes = {
</span><del>-        BaseRecordType.user: u&quot;INDIVIDUAL&quot;,
-        BaseRecordType.group: u&quot;GROUP&quot;,
-        DAVRecordType.resource: u&quot;RESOURCE&quot;,
-        DAVRecordType.location: u&quot;ROOM&quot;,
</del><ins>+        BaseRecordType.user: 'INDIVIDUAL',
+        BaseRecordType.group: 'GROUP',
+        DAVRecordType.resource: 'RESOURCE',
+        DAVRecordType.location: 'ROOM',
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def getCUType(self):
</span><del>-        return self._cuTypes.get(self.recordType, u&quot;UNKNOWN&quot;)
</del><ins>+        return self._cuTypes.get(self.recordType, &quot;UNKNOWN&quot;)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     @classmethod
</span><span class="lines">@@ -293,20 +286,16 @@
</span><span class="cx">         Disable calendaring and addressbooks as dictated by SACLs
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        # # FIXME: need to re-implement SACLs
</del><ins>+        # FIXME: need to re-implement SACLs
</ins><span class="cx">         # if config.EnableSACLs and self.CheckSACL:
</span><span class="cx">         #     username = self.shortNames[0]
</span><span class="cx">         #     if self.CheckSACL(username, &quot;calendar&quot;) != 0:
</span><del>-        #         self.log.debug(
-        #             &quot;{user} is not enabled for calendaring due to SACL&quot;,
-        #             user=username
-        #         )
</del><ins>+        #         self.log.debug(&quot;%s is not enabled for calendaring due to SACL&quot;
+        #                        % (username,))
</ins><span class="cx">         #         self.enabledForCalendaring = False
</span><span class="cx">         #     if self.CheckSACL(username, &quot;addressbook&quot;) != 0:
</span><del>-        #         self.log.debug(
-        #             &quot;{user} is not enabled for addressbooks due to SACL&quot;,
-        #             user=username
-        #         )
</del><ins>+        #         self.log.debug(&quot;%s is not enabled for addressbooks due to SACL&quot;
+        #                        % (username,))
</ins><span class="cx">         #         self.enabledForAddressBooks = False
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -317,15 +306,14 @@
</span><span class="cx"> 
</span><span class="cx">     def cacheToken(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        Generate a token that can be uniquely used to identify the state of
-        this record for use in a cache.
</del><ins>+        Generate a token that can be uniquely used to identify the state of this record for use
+        in a cache.
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         return hash((
</span><span class="cx">             self.__class__.__name__,
</span><span class="cx">             self.service.realmName,
</span><span class="cx">             self.recordType.name,
</span><del>-            # MOVE2WHO FIXME: is this needed? it's not hashable
-            # self.shortNames,
</del><ins>+            # self.shortNames, # MOVE2WHO FIXME: is this needed? it's not hashable
</ins><span class="cx">             self.uid,
</span><span class="cx">             self.hasCalendars,
</span><span class="cx">         ))
</span><span class="lines">@@ -333,23 +321,23 @@
</span><span class="cx"> 
</span><span class="cx">     def canonicalCalendarUserAddress(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><del>-        Return a CUA for this record, preferring in this order:
-        urn:uuid: form
-        mailto: form
-        first in calendarUserAddresses list
</del><ins>+            Return a CUA for this record, preferring in this order:
+            urn:uuid: form
+            mailto: form
+            first in calendarUserAddresses list
</ins><span class="cx">         &quot;&quot;&quot;
</span><span class="cx"> 
</span><del>-        cua = u&quot;&quot;
</del><ins>+        cua = &quot;&quot;
</ins><span class="cx">         for candidate in self.calendarUserAddresses:
</span><span class="cx">             # Pick the first one, but urn:uuid: and mailto: can override
</span><span class="cx">             if not cua:
</span><span class="cx">                 cua = candidate
</span><span class="cx">             # But always immediately choose the urn:uuid: form
</span><del>-            if candidate.startswith(u&quot;urn:uuid:&quot;):
</del><ins>+            if candidate.startswith(&quot;urn:uuid:&quot;):
</ins><span class="cx">                 cua = candidate
</span><span class="cx">                 break
</span><span class="cx">             # Prefer mailto: if no urn:uuid:
</span><del>-            elif candidate.startswith(u&quot;mailto:&quot;):
</del><ins>+            elif candidate.startswith(&quot;mailto:&quot;):
</ins><span class="cx">                 cua = candidate
</span><span class="cx">         return cua
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>