[CalendarServer-changes] [11014] CalendarServer/trunk/calendarserver/tools/util.py
source_changes at macosforge.org
source_changes at macosforge.org
Mon Apr 8 11:05:27 PDT 2013
Revision: 11014
http://trac.calendarserver.org//changeset/11014
Author: cdaboo at apple.com
Date: 2013-04-08 11:05:27 -0700 (Mon, 08 Apr 2013)
Log Message:
-----------
Fix copy/paste error.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tools/util.py
Modified: CalendarServer/trunk/calendarserver/tools/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/util.py 2013-04-08 17:58:32 UTC (rev 11013)
+++ CalendarServer/trunk/calendarserver/tools/util.py 2013-04-08 18:05:27 UTC (rev 11014)
@@ -76,6 +76,8 @@
return config
+
+
def getDirectory(config=config):
class MyDirectoryService (AggregateDirectoryService):
@@ -93,7 +95,7 @@
notifierFactory = None
# Need a data store
- _newStore = CommonDataStore(FilePath(config.DocumentRoot),
+ _newStore = CommonDataStore(FilePath(config.DocumentRoot),
notifierFactory, True, False)
if notifierFactory is not None:
notifierFactory.store = _newStore
@@ -133,10 +135,12 @@
return principal.calendarHome()
return None
+ def principalForCalendarUserAddress(self, cua):
+ return self.principalCollection.principalForCalendarUserAddress(cua)
+
def principalForUID(self, uid):
return self.principalCollection.principalForUID(uid)
-
# Load augment/proxy db classes now
if config.AugmentService.type:
augmentClass = namedClass(config.AugmentService.type)
@@ -154,7 +158,6 @@
while not directory.isAvailable():
sleep(5)
-
directories = [directory]
if config.ResourceService.Enabled:
@@ -189,34 +192,47 @@
return aggregate
+
+
class DummyDirectoryService (DirectoryService):
realmName = ""
baseGUID = "51856FD4-5023-4890-94FE-4356C4AAC3E4"
- def recordTypes(self): return ()
- def listRecords(self): return ()
- def recordWithShortName(self): return None
+ def recordTypes(self):
+ return ()
+
+ def listRecords(self):
+ return ()
+
+
+ def recordWithShortName(self):
+ return None
+
dummyDirectoryRecord = DirectoryRecord(
- service = DummyDirectoryService(),
- recordType = "dummy",
- guid = "8EF0892F-7CB6-4B8E-B294-7C5A5321136A",
- shortNames = ("dummy",),
- fullName = "Dummy McDummerson",
- firstName = "Dummy",
- lastName = "McDummerson",
+ service=DummyDirectoryService(),
+ recordType="dummy",
+ guid="8EF0892F-7CB6-4B8E-B294-7C5A5321136A",
+ shortNames=("dummy",),
+ fullName="Dummy McDummerson",
+ firstName="Dummy",
+ lastName="McDummerson",
)
class UsageError (StandardError):
pass
+
+
def booleanArgument(arg):
- if arg in ("true", "yes", "yup", "uh-huh", "1", "t", "y"):
+ if arg in ("true", "yes", "yup", "uh-huh", "1", "t", "y"):
return True
- elif arg in ("false", "no", "nope", "nuh-uh", "0", "f", "n"):
+ elif arg in ("false", "no", "nope", "nuh-uh", "0", "f", "n"):
return False
else:
raise ValueError("Not a boolean: %s" % (arg,))
+
+
def autoDisableMemcached(config):
"""
If memcached is not running, set config.Memcached.ClientEnabled to False
@@ -235,6 +251,7 @@
config.Memcached.Pools.Default.ClientEnabled = False
+
def setupMemcached(config):
#
# Connect to memcached
@@ -246,6 +263,7 @@
autoDisableMemcached(config)
+
def checkDirectory(dirpath, description, access=None, create=None, wait=False):
"""
Make sure dirpath is an existing directory, and optionally ensure it has the
@@ -319,9 +337,9 @@
def principalForPrincipalID(principalID, checkOnly=False, directory=None):
-
+
# Allow a directory parameter to be passed in, but default to config.directory
- # But config.directory isn't set right away, so only use it when we're doing more
+ # But config.directory isn't set right away, so only use it when we're doing more
# than checking.
if not checkOnly and not directory:
directory = config.directory
@@ -339,7 +357,6 @@
return directory.principalCollection.principalForUID(uid)
-
if principalID.startswith("("):
try:
i = principalID.index(")")
@@ -348,7 +365,7 @@
return None
recordType = principalID[1:i]
- shortName = principalID[i+1:]
+ shortName = principalID[i + 1:]
if not recordType or not shortName or "(" in recordType:
raise ValueError()
@@ -379,9 +396,13 @@
raise ValueError("Invalid principal identifier: %s" % (principalID,))
+
+
def proxySubprincipal(principal, proxyType):
return principal.getChild("calendar-proxy-" + proxyType)
+
+
@inlineCallbacks
def action_addProxyPrincipal(rootResource, directory, store, principal, proxyType, proxyPrincipal):
try:
@@ -394,6 +415,8 @@
except ProxyWarning, e:
print(e)
+
+
@inlineCallbacks
def action_removeProxyPrincipal(rootResource, directory, store, principal, proxyPrincipal, **kwargs):
try:
@@ -408,6 +431,8 @@
except ProxyWarning, e:
print(e)
+
+
@inlineCallbacks
def addProxy(rootResource, directory, store, principal, proxyType, proxyPrincipal):
proxyURL = proxyPrincipal.url()
@@ -439,6 +464,8 @@
yield scheduleNextGroupCachingUpdate(store, 0)
+
+
@inlineCallbacks
def removeProxy(rootResource, directory, store, principal, proxyPrincipal, **kwargs):
removed = False
@@ -478,16 +505,17 @@
return "\"%s\" (%s:%s)" % (record.fullName, record.recordType,
record.shortNames[0])
+
+
class ProxyError(Exception):
"""
Raised when proxy assignments cannot be performed
"""
+
+
class ProxyWarning(Exception):
"""
Raised for harmless proxy assignment failures such as trying to add a
duplicate or remove a non-existent assignment.
"""
-
-
-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130408/ccd4f18f/attachment-0001.html>
More information about the calendarserver-changes
mailing list