Make the HTTPServer class inherit from object

This commit is contained in:
Guillaume Ayoub 2011-05-01 16:45:04 +02:00
parent 6389411edd
commit 882d70e2cb

View File

@ -48,7 +48,7 @@ from radicale import acl, config, ical, log, xmlutils
VERSION = "git" VERSION = "git"
class HTTPServer(wsgiref.simple_server.WSGIServer): class HTTPServer(wsgiref.simple_server.WSGIServer, object):
"""HTTP server.""" """HTTP server."""
def __init__(self, address, handler, bind_and_activate=True): def __init__(self, address, handler, bind_and_activate=True):
"""Create server.""" """Create server."""
@ -57,8 +57,8 @@ class HTTPServer(wsgiref.simple_server.WSGIServer):
if ipv6: if ipv6:
self.address_family = socket.AF_INET6 self.address_family = socket.AF_INET6
# Do not bind and activate, as we might change socketopts # Do not bind and activate, as we might change socket options
wsgiref.simple_server.WSGIServer.__init__(self, address, handler, False) super(HTTPServer, self).__init__(address, handler, False)
if ipv6: if ipv6:
# Only allow IPv6 connections to the IPv6 socket # Only allow IPv6 connections to the IPv6 socket
@ -71,14 +71,15 @@ class HTTPServer(wsgiref.simple_server.WSGIServer):
class HTTPSServer(HTTPServer): class HTTPSServer(HTTPServer):
"""HTTPS server.""" """HTTPS server."""
def __init__(self, address, handler, bind_and_activate=True): def __init__(self, address, handler):
"""Create server by wrapping HTTP socket in an SSL socket.""" """Create server by wrapping HTTP socket in an SSL socket."""
# Fails with Python 2.5, import if needed # Fails with Python 2.5, import if needed
# pylint: disable=F0401 # pylint: disable=F0401
import ssl import ssl
# pylint: enable=F0401 # pylint: enable=F0401
HTTPServer.__init__(self, address, handler, False) super(HTTPSServer, self).__init__(address, handler, False)
self.socket = ssl.wrap_socket( self.socket = ssl.wrap_socket(
self.socket, self.socket,
server_side=True, server_side=True,
@ -86,9 +87,8 @@ class HTTPSServer(HTTPServer):
keyfile=config.get("server", "key"), keyfile=config.get("server", "key"),
ssl_version=ssl.PROTOCOL_SSLv23) ssl_version=ssl.PROTOCOL_SSLv23)
if bind_and_activate: self.server_bind()
self.server_bind() self.server_activate()
self.server_activate()
class Application(object): class Application(object):