Skip to content
Permalink
Browse files

Use newly available config dotted notation.

  • Loading branch information...
wsanchez committed Nov 11, 2008
1 parent 9efaa95 commit 59a79d0fbdef30fa35b21e7a6ab85a015c6c3dbc
@@ -247,7 +247,7 @@ def getConfig(configFileName):
def getDirectory(config):
global _directory
if _directory is None:
BaseDirectoryService = namedClass(config.DirectoryService["type"])
BaseDirectoryService = namedClass(config.DirectoryService.type)

class MyDirectoryService (BaseDirectoryService):
def principalCollection(self):
@@ -272,7 +272,7 @@ def calendarHomeForShortName(self, recordType, shortName):
return principal.calendarHome()
return None

_directory = MyDirectoryService(**config.DirectoryService["params"])
_directory = MyDirectoryService(**config.DirectoryService.params)

return _directory

@@ -85,26 +85,26 @@ def getCommandLine(self):
if config.GroupName:
args.extend(("-g", config.GroupName))

if config.Profiling["Enabled"]:
if config.Profiling.Enabled:
args.append(
"--profile=%s/%s.pstats"
% (config.Profiling["BaseDirectory"], self.getName())
% (config.Profiling.BaseDirectory, self.getName())
)
args.extend(("--savestats", "--nothotshot"))

args.extend([
"--reactor=%s" % (config.Twisted["reactor"],),
"--reactor=%s" % (config.Twisted.reactor,),
"-n", self.tapname,
"-f", self.configFile,
"-o", "ProcessType=Slave",
"-o", "BindAddresses=%s" % (",".join(self.interfaces),),
"-o", "PIDFile=None",
"-o", "ErrorLogFile=None",
"-o", "MultiProcess/ProcessCount=%d"
% (config.MultiProcess["ProcessCount"],)
% (config.MultiProcess.ProcessCount,)
])

if config.Memcached["ServerEnabled"]:
if config.Memcached.ServerEnabled:
args.extend(["-o", "Memcached/ClientEnabled=True"])

if self.ports:
@@ -147,8 +147,8 @@ def startService(self):

delay = 0

if config.MultiProcess["StaggeredStartup"]["Enabled"]:
delay_interval = config.MultiProcess["StaggeredStartup"]["Interval"]
if config.MultiProcess.StaggeredStartup.Enabled:
delay_interval = config.MultiProcess.StaggeredStartup.Interval
else:
delay_interval = 0

@@ -219,7 +219,7 @@ def makeService_Combined(self, options):
#
# Attempt to calculate the number of processes to use 1 per processor
#
if config.MultiProcess["ProcessCount"] == 0:
if config.MultiProcess.ProcessCount == 0:
try:
cpuCount = getNCPU()
except NotImplementedError, e:
@@ -240,16 +240,16 @@ def makeService_Combined(self, options):
log.err("Assuming one CPU, configuring one process.")
cpuCount = 1

config.MultiProcess["ProcessCount"] = cpuCount
config.MultiProcess.ProcessCount = cpuCount

if config.MultiProcess["ProcessCount"] > 1:
if config.MultiProcess.ProcessCount > 1:
if config.BindHTTPPorts:
port = [list(reversed(config.BindHTTPPorts))[0]]

if config.BindSSLPorts:
sslPort = [list(reversed(config.BindSSLPorts))[0]]

elif config.MultiProcess["ProcessCount"] == 1:
elif config.MultiProcess.ProcessCount == 1:
if config.BindHTTPPorts:
port = config.BindHTTPPorts

@@ -266,21 +266,21 @@ def makeService_Combined(self, options):
# We listen directly on the interfaces.

if (
not config.MultiProcess["LoadBalancer"]["Enabled"] or
config.MultiProcess["ProcessCount"] == 1
not config.MultiProcess.LoadBalancer.Enabled or
config.MultiProcess.ProcessCount == 1
):
bindAddress = config.BindAddresses

for p in xrange(0, config.MultiProcess["ProcessCount"]):
if config.MultiProcess["ProcessCount"] > 1:
for p in xrange(0, config.MultiProcess.ProcessCount):
if config.MultiProcess.ProcessCount > 1:
if port is not None:
port = [port[0] + 1]

if sslPort is not None:
sslPort = [sslPort[0] + 1]

process = TwistdSlaveProcess(
config.Twisted["twistd"],
config.Twisted.twistd,
self.tapname,
options["config"],
bindAddress,
@@ -303,8 +303,8 @@ def makeService_Combined(self, options):
#
# Set up pydirector config file.
#
if (config.MultiProcess["LoadBalancer"]["Enabled"] and
config.MultiProcess["ProcessCount"] > 1):
if (config.MultiProcess.LoadBalancer.Enabled and
config.MultiProcess.ProcessCount > 1):
services = []

if not config.BindAddresses:
@@ -342,7 +342,7 @@ def makeService_Combined(self, options):
}
)

scheduler = config.MultiProcess["LoadBalancer"]["Scheduler"]
scheduler = config.MultiProcess.LoadBalancer.Scheduler

if httpPorts:
services.append(
@@ -368,7 +368,7 @@ def makeService_Combined(self, options):

pdconfig = configTemplate % {
"services": "\n".join(services),
"controlSocket": config.PythonDirector["ControlSocket"],
"controlSocket": config.PythonDirector.ControlSocket,
}

fd, fname = tempfile.mkstemp(prefix="pydir")
@@ -379,52 +379,52 @@ def makeService_Combined(self, options):

monitor.addProcess(
"pydir",
[sys.executable, config.PythonDirector["pydir"], fname],
[sys.executable, config.PythonDirector.pydir, fname],
env=parentEnv,
)

if config.Memcached["ServerEnabled"]:
if config.Memcached.ServerEnabled:
log.msg("Adding memcached service")

memcachedArgv = [
config.Memcached["memcached"],
"-p", str(config.Memcached["Port"]),
"-l", config.Memcached["BindAddress"],
config.Memcached.memcached,
"-p", str(config.Memcached.Port),
"-l", config.Memcached.BindAddress,
]

if config.Memcached["MaxMemory"] is not 0:
memcachedArgv.extend(["-m", str(config.Memcached["MaxMemory"])])
if config.Memcached.MaxMemory is not 0:
memcachedArgv.extend(["-m", str(config.Memcached.MaxMemory)])

if config.UserName:
memcachedArgv.extend(["-u", config.UserName])

memcachedArgv.extend(config.Memcached["Options"])
memcachedArgv.extend(config.Memcached.Options)

monitor.addProcess("memcached", memcachedArgv, env=parentEnv)

if (
config.Notifications["Enabled"] and
config.Notifications["InternalNotificationHost"] == "localhost"
config.Notifications.Enabled and
config.Notifications.InternalNotificationHost == "localhost"
):
log.msg("Adding notification service")

notificationsArgv = [
sys.executable,
config.Twisted["twistd"],
config.Twisted.twistd,
"-n", "caldav_notifier",
"-f", options["config"],
]
monitor.addProcess("notifications", notificationsArgv, env=parentEnv)

if (
config.Scheduling["iMIP"]["Enabled"] and
config.Scheduling["iMIP"]["MailGatewayServer"] == "localhost"
config.Scheduling.iMIP.Enabled and
config.Scheduling.iMIP.MailGatewayServer == "localhost"
):
log.msg("Adding mail gateway service")

mailGatewayArgv = [
sys.executable,
config.Twisted["twistd"],
config.Twisted.twistd,
"-n", "caldav_mailgateway",
"-f", options["config"],
]
@@ -447,14 +447,14 @@ def makeService_Master(self, options):
parentEnv = {"PYTHONPATH": os.environ.get("PYTHONPATH", "")}

log.msg("Adding pydirector service with configuration: %s"
% (config.PythonDirector["ConfigFile"],))
% (config.PythonDirector.ConfigFile,))

service.addProcess(
"pydir",
[
sys.executable,
config.PythonDirector["pydir"],
config.PythonDirector["ConfigFile"]
config.PythonDirector.pydir,
config.PythonDirector.ConfigFile
],
env=parentEnv
)
@@ -273,7 +273,7 @@ def __init__(self, parent, record):
childlist += (
("dropbox", DropBoxHomeResource),
)
if config.FreeBusyURL["Enabled"]:
if config.FreeBusyURL.Enabled:
childlist += (
("freebusy", FreeBusyURLResource),
)
@@ -303,7 +303,7 @@ def setupFreeBusy(_):
inbox.processFreeBusyCalendar(childURL, True)

# Default calendar may need to be marked as the default for scheduling
if config.Scheduling["CalDAV"]["DefaultCalendarProvisioned"]:
if config.Scheduling.CalDAV.DefaultCalendarProvisioned:
inbox.writeDeadProperty(caldavxml.ScheduleDefaultCalendarURL(davxml.HRef(childURL)))

return self
@@ -148,7 +148,7 @@ def getWikiACL(resource, request):
if hasattr(request, 'wikiACL'):
returnValue(request.wikiACL)

wikiConfig = config.Authentication["Wiki"]
wikiConfig = config.Authentication.Wiki
userID = "unauthenticated"
wikiID = resource.record.shortName

@@ -71,7 +71,7 @@ def defaultAccessControlList(self):
davxml.Privilege(davxml.Read()),
davxml.Privilege(caldavxml.ScheduleDeliver()),
)
if config.Scheduling["CalDAV"]["OldDraftCompatibility"]:
if config.Scheduling.CalDAV.OldDraftCompatibility:
privs += (davxml.Privilege(caldavxml.Schedule()),)

aces = (
@@ -82,7 +82,7 @@ def defaultAccessControlList(self):
davxml.Protected(),
),
)
if config.FreeBusyURL["AnonymousAccess"]:
if config.FreeBusyURL.AnonymousAccess:
aces += (
# DAV:Read, for unauthenticated principals
davxml.ACE(
@@ -190,7 +190,7 @@ def _processFBURL(self, request):
if self.duration:
self.end = self.start + self.duration
if self.end is None:
self.end = self.start + datetime.timedelta(days=config.FreeBusyURL["TimePeriod"])
self.end = self.start + datetime.timedelta(days=config.FreeBusyURL.TimePeriod)

# End > start
if self.end <= self.start:
@@ -98,7 +98,7 @@ class translationTo(object):
def __init__(self, lang, domain='calendarserver', localeDir=None):

if localeDir is None:
localeDir = config.Localization["LocalesDirectory"]
localeDir = config.Localization.LocalesDirectory

# Cache gettext translation objects in class.translations
key = (lang, domain, localeDir)
@@ -176,7 +176,7 @@ def defaultAccessControlList(self):
davxml.Privilege(davxml.Read()),
davxml.Privilege(caldavxml.ScheduleDeliver()),
)
if config.Scheduling["CalDAV"]["OldDraftCompatibility"]:
if config.Scheduling.CalDAV.OldDraftCompatibility:
privs += (davxml.Privilege(caldavxml.Schedule()),)
return davxml.ACL(
# DAV:Read, CalDAV:schedule-deliver for all principals (includes anonymous)
@@ -503,7 +503,7 @@ def render_POST(self, request):
# Compute token, add to db, generate email and send it
calendar = ical.Component.fromString(request.content.read())
headers = request.getAllHeaders()
language = config.Localization["Language"]
language = config.Localization.Language
self.mailer.outbound(headers['originator'], headers['recipient'],
calendar, language=language)

@@ -777,7 +777,7 @@ def generateEmail(self, newInvitation, calendar, orgEmail, orgCN,

details = self.getEventDetails(calendar, language=language)

iconDir = config.Scheduling["iMIP"]["MailIconsDirectory"].rstrip("/")
iconDir = config.Scheduling.iMIP.MailIconsDirectory.rstrip("/")
iconName = "cal-icon-%02d-%02d.png" % (details['month'],
details['day'])
iconPath = os.path.join(iconDir, language, iconName)
@@ -888,7 +888,7 @@ def generateEmail(self, newInvitation, calendar, orgEmail, orgCN,

details['iconName'] = iconName

templateDir = config.Scheduling["iMIP"]["MailTemplatesDirectory"].rstrip("/")
templateDir = config.Scheduling.iMIP.MailTemplatesDirectory.rstrip("/")
templateName = "cancel.html" if canceled else "invite.html"
templatePath = os.path.join(templateDir, templateName)

@@ -392,7 +392,7 @@ def validIfScheduleMatch(self):
raise HTTPError(responsecode.PRECONDITION_FAILED)
self.schedule_tag_match = True

elif config.Scheduling["CalDAV"]["ScheduleTagCompatibility"]:
elif config.Scheduling.CalDAV.ScheduleTagCompatibility:
# Compatibility with old clients. Policy:
#
# 1. If If-Match header is not present, never do smart merge.
@@ -623,7 +623,7 @@ def preservePrivateComments(self):
# NB Do this before implicit scheduling as we don't want old clients to trigger scheduling when
# the X- property is missing.
new_has_private_comments = False
if config.Scheduling["CalDAV"].get("EnablePrivateComments", True) and self.calendar is not None:
if config.Scheduling.CalDAV.get("EnablePrivateComments", True) and self.calendar is not None:
old_has_private_comments = self.destination.exists() and self.destinationcal and self.destination.hasDeadProperty(TwistedCalendarHasPrivateCommentsProperty)
new_has_private_comments = self.calendar.hasPropertyInAnyComponent((
"X-CALENDARSERVER-PRIVATE-COMMENT",
@@ -946,7 +946,7 @@ def _removeEtag(request, response):
response.headers.setHeader("Schedule-Tag", self.scheduletag)

# Handle weak etag compatibility
if config.Scheduling["CalDAV"]["ScheduleTagCompatibility"]:
if config.Scheduling.CalDAV.ScheduleTagCompatibility:
if change_scheduletag:
# Schedule-Tag change => weak ETag behavior must not happen
etags = ()
@@ -967,7 +967,7 @@ def _removeEtag(request, response):
self.destination.removeDeadProperty(TwistedScheduleMatchETags)

# Check for existence of private comments and write property
if config.Scheduling["CalDAV"].get("EnablePrivateComments", True):
if config.Scheduling.CalDAV.get("EnablePrivateComments", True):
if new_has_private_comments:
self.destination.writeDeadProperty(TwistedCalendarHasPrivateCommentsProperty())
elif not self.destinationcal:

0 comments on commit 59a79d0

Please sign in to comment.
You can’t perform that action at this time.