<!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>[12980] CalendarServer/branches/users/sagen/move2who-4</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/12980">12980</a></dd>
<dt>Author</dt> <dd>wsanchez@apple.com</dd>
<dt>Date</dt> <dd>2014-03-19 18:29:32 -0700 (Wed, 19 Mar 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>quote shortName</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserssagenmove2who4twistedcaldavdirectoryprincipalpy">CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/principal.py</a></li>
<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="CalendarServerbranchesuserssagenmove2who4twistedcaldavdirectoryprincipalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/principal.py (12979 => 12980)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/principal.py        2014-03-20 01:28:13 UTC (rev 12979)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/principal.py        2014-03-20 01:29:32 UTC (rev 12980)
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx"> "DirectoryCalendarPrincipalResource",
</span><span class="cx"> ]
</span><span class="cx">
</span><del>-from urllib import unquote
</del><ins>+from urllib import quote, unquote
</ins><span class="cx"> from urlparse import urlparse
</span><span class="cx"> import uuid
</span><span class="cx">
</span><span class="lines">@@ -826,7 +826,12 @@
</span><span class="cx">
</span><span class="cx"> # MOVE2WHO - hack: just adding an "s" using recordType.name (need a mapping)
</span><span class="cx"> self._alternate_urls = tuple([
</span><del>- joinURL(parent.parent.principalCollectionURL(), record.recordType.name+"s", shortName) + slash for shortName in record.shortNames
</del><ins>+ joinURL(
+ parent.parent.principalCollectionURL(),
+ (record.recordType.name + "s"),
+ quote(shortName.encode("utf-8"))
+ ) + slash
+ for shortName in record.shortNames
</ins><span class="cx"> ])
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -838,7 +843,10 @@
</span><span class="cx"> """
</span><span class="cx"> Principals are the same if their principalURLs are the same.
</span><span class="cx"> """
</span><del>- return (self.principalURL() == other.principalURL()) if isinstance(other, DirectoryPrincipalResource) else False
</del><ins>+ if isinstance(other, DirectoryPrincipalResource):
+ return (self.principalURL() == other.principalURL())
+ else:
+ return False
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> def __ne__(self, other):
</span></span></pre></div>
<a id="CalendarServerbranchesuserssagenmove2who4txdavwhodirectorypy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py (12979 => 12980)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py        2014-03-20 01:28:13 UTC (rev 12979)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/who/directory.py        2014-03-20 01:29:32 UTC (rev 12980)
</span><span class="lines">@@ -42,12 +42,13 @@
</span><span class="cx">
</span><span class="cx"> class CalendarDirectoryServiceMixin(object):
</span><span class="cx">
</span><del>- guid = "1332A615-4D3A-41FE-B636-FBE25BFB982E"
</del><ins>+ guid = u"1332A615-4D3A-41FE-B636-FBE25BFB982E"
</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"> """
</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">@@ -61,24 +62,26 @@
</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("urn:uuid:"):
</del><ins>+ if address.startswith(u"urn:uuid:"):
</ins><span class="cx"> guid = address[9:]
</span><span class="cx"> record = yield self.recordWithGUID(uuid.UUID(guid))
</span><del>- elif address.startswith("mailto:"):
</del><ins>+ elif address.startswith(u"mailto:"):
</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("/principals/"):
- parts = address.split("/")
</del><ins>+ elif address.startswith(u"/principals/"):
+ parts = address.split(u"/")
</ins><span class="cx"> if len(parts) == 4:
</span><del>- if parts[2] == "__uids__":
</del><ins>+ if parts[2] == u"__uids__":
</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">@@ -86,8 +89,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>- ("fullNames", MatchType.contains),
- ("emailAddresses", MatchType.startsWith),
</del><ins>+ (u"fullNames", MatchType.contains),
+ (u"emailAddresses", MatchType.startsWith),
</ins><span class="cx"> ]
</span><span class="cx"> outer = []
</span><span class="cx"> for token in tokens:
</span><span class="lines">@@ -123,7 +126,9 @@
</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"> """
</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">@@ -170,15 +175,15 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> _oldRecordTypeNames = {
</span><del>- "address": "addresses",
- "group": "groups",
- "location": "locations",
- "resource": "resources",
- "user": "users",
- "readDelegateGroup": "readDelegateGroups",
- "writeDelegateGroup": "writeDelegateGroups",
- "readDelegatorGroup": "readDelegatorGroups",
- "writeDelegatorGroup": "writeDelegatorGroups",
</del><ins>+ u"address": u"addresses",
+ u"group": u"groups",
+ u"location": u"locations",
+ u"resource": u"resources",
+ u"user": u"users",
+ u"readDelegateGroup": u"readDelegateGroups",
+ u"writeDelegateGroup": u"writeDelegateGroups",
+ u"readDelegatorGroup": u"readDelegatorGroups",
+ u"writeDelegatorGroup": u"writeDelegatorGroups",
</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">@@ -212,8 +217,8 @@
</span><span class="cx">
</span><span class="cx"> elif isinstance(credentials, DigestedCredentials):
</span><span class="cx"> log.debug("DigestedCredentials")
</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["uri"],
</span><span class="lines">@@ -224,8 +229,8 @@
</span><span class="cx"> credentials.fields.get("qop", ""),
</span><span class="cx"> credentials.fields["response"],
</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">@@ -234,10 +239,10 @@
</span><span class="cx"> return frozenset()
</span><span class="cx">
</span><span class="cx"> try:
</span><del>- cuas = set(
- ["mailto:%s" % (emailAddress,)
- for emailAddress in self.emailAddresses]
- )
</del><ins>+ cuas = set([
+ u"mailto:{}".format(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">@@ -247,30 +252,32 @@
</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("urn:uuid:{guid}".format(guid=guid))
</del><ins>+ cuas.add(u"urn:uuid:{guid}".format(guid=guid))
</ins><span class="cx"> except AttributeError:
</span><span class="cx"> # No guid
</span><span class="cx"> pass
</span><del>- cuas.add("/principals/__uids__/{uid}/".format(uid=self.uid))
</del><ins>+ cuas.add(u"/principals/__uids__/{uid}/".format(uid=self.uid))
</ins><span class="cx"> for shortName in self.shortNames:
</span><del>- cuas.add("/principals/{rt}/{sn}/".format(
- rt=self.service.recordTypeToOldName(self.recordType),
- sn=shortName)
</del><ins>+ cuas.add(
+ u"/principals/{rt}/{sn}/".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: 'INDIVIDUAL',
- BaseRecordType.group: 'GROUP',
- DAVRecordType.resource: 'RESOURCE',
- DAVRecordType.location: 'ROOM',
</del><ins>+ BaseRecordType.user: u"INDIVIDUAL",
+ BaseRecordType.group: u"GROUP",
+ DAVRecordType.resource: u"RESOURCE",
+ DAVRecordType.location: u"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, "UNKNOWN")
</del><ins>+ return self._cuTypes.get(self.recordType, u"UNKNOWN")
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @classmethod
</span><span class="lines">@@ -286,16 +293,20 @@
</span><span class="cx"> Disable calendaring and addressbooks as dictated by SACLs
</span><span class="cx"> """
</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, "calendar") != 0:
</span><del>- # self.log.debug("%s is not enabled for calendaring due to SACL"
- # % (username,))
</del><ins>+ # self.log.debug(
+ # "{user} is not enabled for calendaring due to SACL",
+ # user=username
+ # )
</ins><span class="cx"> # self.enabledForCalendaring = False
</span><span class="cx"> # if self.CheckSACL(username, "addressbook") != 0:
</span><del>- # self.log.debug("%s is not enabled for addressbooks due to SACL"
- # % (username,))
</del><ins>+ # self.log.debug(
+ # "{user} is not enabled for addressbooks due to SACL",
+ # user=username
+ # )
</ins><span class="cx"> # self.enabledForAddressBooks = False
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -306,14 +317,15 @@
</span><span class="cx">
</span><span class="cx"> def cacheToken(self):
</span><span class="cx"> """
</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"> """
</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>- # self.shortNames, # MOVE2WHO FIXME: is this needed? it's not hashable
</del><ins>+ # MOVE2WHO FIXME: is this needed? it's not hashable
+ # self.shortNames,
</ins><span class="cx"> self.uid,
</span><span class="cx"> self.hasCalendars,
</span><span class="cx"> ))
</span><span class="lines">@@ -321,23 +333,23 @@
</span><span class="cx">
</span><span class="cx"> def canonicalCalendarUserAddress(self):
</span><span class="cx"> """
</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"> """
</span><span class="cx">
</span><del>- cua = ""
</del><ins>+ cua = u""
</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("urn:uuid:"):
</del><ins>+ if candidate.startswith(u"urn:uuid:"):
</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("mailto:"):
</del><ins>+ elif candidate.startswith(u"mailto:"):
</ins><span class="cx"> cua = candidate
</span><span class="cx"> return cua
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>