[CalendarServer-changes] [6595] CalendarServer/branches/users/glyph/dont-start-postgres/ calendarserver/tap/caldav.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Nov 10 18:53:11 PST 2010
Revision: 6595
http://trac.macosforge.org/projects/calendarserver/changeset/6595
Author: glyph at apple.com
Date: 2010-11-10 18:53:07 -0800 (Wed, 10 Nov 2010)
Log Message:
-----------
Factor out port configuration validation into a method.
Modified Paths:
--------------
CalendarServer/branches/users/glyph/dont-start-postgres/calendarserver/tap/caldav.py
Modified: CalendarServer/branches/users/glyph/dont-start-postgres/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/branches/users/glyph/dont-start-postgres/calendarserver/tap/caldav.py 2010-11-11 02:52:46 UTC (rev 6594)
+++ CalendarServer/branches/users/glyph/dont-start-postgres/calendarserver/tap/caldav.py 2010-11-11 02:53:07 UTC (rev 6595)
@@ -621,22 +621,7 @@
config.BindAddresses = [""]
for bindAddress in config.BindAddresses:
- if config.BindHTTPPorts:
- if config.HTTPPort == 0:
- raise UsageError(
- "HTTPPort required if BindHTTPPorts is not empty"
- )
- elif config.HTTPPort != 0:
- config.BindHTTPPorts = [config.HTTPPort]
-
- if config.BindSSLPorts:
- if config.SSLPort == 0:
- raise UsageError(
- "SSLPort required if BindSSLPorts is not empty"
- )
- elif config.SSLPort != 0:
- config.BindSSLPorts = [config.SSLPort]
-
+ self._validatePortConfig()
if config.EnableSSL:
for port in config.BindSSLPorts:
self.log_info("Adding SSL server at %s:%s"
@@ -686,6 +671,32 @@
return service
+ def _validatePortConfig(self):
+ """
+ If BindHTTPPorts is specified, HTTPPort must also be specified to
+ indicate which is the preferred port (the one to be used in URL
+ generation, etc). If only HTTPPort is specified, BindHTTPPorts should
+ be set to a list containing only that port number. Similarly for
+ BindSSLPorts/SSLPort.
+
+ @raise UsageError: if configuration is not valid.
+ """
+ if config.BindHTTPPorts:
+ if config.HTTPPort == 0:
+ raise UsageError(
+ "HTTPPort required if BindHTTPPorts is not empty"
+ )
+ elif config.HTTPPort != 0:
+ config.BindHTTPPorts = [config.HTTPPort]
+ if config.BindSSLPorts:
+ if config.SSLPort == 0:
+ raise UsageError(
+ "SSLPort required if BindSSLPorts is not empty"
+ )
+ elif config.SSLPort != 0:
+ config.BindSSLPorts = [config.SSLPort]
+
+
def scheduleOnDiskUpgrade(self):
"""
Schedule any on disk upgrades we might need. Note that this will only
@@ -866,22 +877,7 @@
s._inheritedSockets = [] # keep a reference to these so they don't close
for bindAddress in config.BindAddresses:
- if config.BindHTTPPorts:
- if config.HTTPPort == 0:
- raise UsageError(
- "HTTPPort required if BindHTTPPorts is not empty"
- )
- elif config.HTTPPort != 0:
- config.BindHTTPPorts = [config.HTTPPort]
-
- if config.BindSSLPorts:
- if config.SSLPort == 0:
- raise UsageError(
- "SSLPort required if BindSSLPorts is not empty"
- )
- elif config.SSLPort != 0:
- config.BindSSLPorts = [config.SSLPort]
-
+ self._validatePortConfig()
if config.UseMetaFD:
portsList = [(config.BindHTTPPorts, "TCP")]
if config.EnableSSL:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101110/c3931bba/attachment.html>
More information about the calendarserver-changes
mailing list