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