From e085c76355e935fe9558fff4d14e0da751210e64 Mon Sep 17 00:00:00 2001 From: Florent Gallaire Date: Wed, 10 Aug 2016 05:48:03 +0200 Subject: [PATCH] Simplify SSLAdapter and remove get_ssl_adapter_class() --- wsgiserver.py | 55 +++------------------------------------------------ 1 file changed, 3 insertions(+), 52 deletions(-) diff --git a/wsgiserver.py b/wsgiserver.py index 567d1dd..0a6432c 100644 --- a/wsgiserver.py +++ b/wsgiserver.py @@ -87,7 +87,7 @@ def my_crazy_app(environ, start_response): 'WorkerThread', 'ThreadPool', 'SSLAdapter', 'WSGIServer', 'Gateway', 'WSGIGateway', 'WSGIGateway_10', 'WSGIGateway_u0', - 'WSGIPathInfoDispatcher', 'get_ssl_adapter_class', + 'WSGIPathInfoDispatcher', 'socket_errors_to_ignore'] import os @@ -1755,29 +1755,6 @@ def prevent_socket_inheritance(sock): fcntl.fcntl(fd, fcntl.F_SETFD, old_flags | fcntl.FD_CLOEXEC) -class SSLAdapter(object): - - """Base class for SSL driver library adapters. - - Required methods: - - * ``wrap(sock) -> (wrapped socket, ssl environ dict)`` - * ``makefile(sock, mode='r', bufsize=DEFAULT_BUFFER_SIZE) -> - socket file object`` - """ - - def __init__(self, certificate, private_key, certificate_chain=None): - self.certificate = certificate - self.private_key = private_key - self.certificate_chain = certificate_chain - - def wrap(self, sock): - raise NotImplemented - - def makefile(self, sock, mode='r', bufsize=DEFAULT_BUFFER_SIZE): - raise NotImplemented - - try: import ssl except ImportError: @@ -1789,9 +1766,9 @@ def makefile(self, sock, mode='r', bufsize=DEFAULT_BUFFER_SIZE): DEFAULT_BUFFER_SIZE = -1 -class BuiltinSSLAdapter(SSLAdapter): +class SSLAdapter(object): - """A wrapper for integrating Python's builtin ssl module with CherryPy.""" + """A wrapper for integrating Python's builtin ssl module with WSGIServer.""" certificate = None """The filename of the server SSL certificate.""" @@ -2320,32 +2297,6 @@ def respond(self): """Process the current request. Must be overridden in a subclass.""" raise NotImplemented - -def get_ssl_adapter_class(): - """Return an SSL adapter class for the given name.""" - adapter = 'wsgiserver.ssl_builtin.BuiltinSSLAdapter' - if isinstance(adapter, six.string_types): - last_dot = adapter.rfind(".") - attr_name = adapter[last_dot + 1:] - mod_path = adapter[:last_dot] - - try: - mod = sys.modules[mod_path] - if mod is None: - raise KeyError() - except KeyError: - # The last [''] is important. - mod = __import__(mod_path, globals(), locals(), ['']) - - # Let an AttributeError propagate outward. - try: - adapter = getattr(mod, attr_name) - except AttributeError: - raise AttributeError("'%s' object has no attribute '%s'" - % (mod_path, attr_name)) - - return adapter - # ------------------------------- WSGI Stuff -------------------------------- #