From 888aa8e7b8f6490015463ee370ff4026fc951b1f Mon Sep 17 00:00:00 2001 From: 06180339 Date: Sat, 28 Jan 2017 23:29:29 +0100 Subject: Add ServerAdapter for CherryPy >= 9 Since CherryPy >= 9, the server part of CherryPy has been extracted and named Cheroot. Thus the old CherryPy ServerAdapter does not work for CherryPy >= 9: the import fails, and the SSL part should be different too. Cheroot can be installed (git install cheroot) without CherryPy so that we can just have a CherootServer adapter in addition to the CherryPyServer adapter for the older versions. (cherry picked from commit b9229eef97ea246e3d0e0c455071d54435a1557d) Signed-off-by: Juerg Haefliger --- bottle.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bottle.py b/bottle.py index 04ccf7d..73886a2 100644 --- a/bottle.py +++ b/bottle.py @@ -2816,6 +2816,25 @@ class CherryPyServer(ServerAdapter): server.stop() +class CherootServer(ServerAdapter): + def run(self, handler): # pragma: no cover + from cheroot import wsgi + from cheroot.ssl import builtin + self.options['bind_addr'] = (self.host, self.port) + self.options['wsgi_app'] = handler + certfile = self.options.pop('certfile', None) + keyfile = self.options.pop('keyfile', None) + chainfile = self.options.pop('chainfile', None) + server = wsgi.Server(**self.options) + if certfile and keyfile: + server.ssl_adapter = builtin.BuiltinSSLAdapter( + certfile, keyfile, chainfile) + try: + server.start() + finally: + server.stop() + + class WaitressServer(ServerAdapter): def run(self, handler): from waitress import serve -- cgit v1.2.1 From a3ba0eb30e7becdfe0eb83dc2babaa40847cd7d0 Mon Sep 17 00:00:00 2001 From: Marcel Hellkamp Date: Sat, 25 Mar 2017 17:59:26 +0100 Subject: Added 'cheroot' server adapter to list of server names, so it can be selected from the command line and by name. Alos added cheroot after cherrypy in the 'auto' adapter to make it future proof. (backported from commit 617d08a2ccca95b2e8668fef7057127049595fd9) [juergh: Adjust context.] Signed-off-by: Juerg Haefliger --- bottle.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bottle.py b/bottle.py index 73886a2..11121b8 100644 --- a/bottle.py +++ b/bottle.py @@ -3002,7 +3002,9 @@ class BjoernServer(ServerAdapter): class AutoServer(ServerAdapter): """ Untested. """ - adapters = [WaitressServer, PasteServer, TwistedServer, CherryPyServer, WSGIRefServer] + adapters = [WaitressServer, PasteServer, TwistedServer, CherryPyServer, + CherootServer, WSGIRefServer] + def run(self, handler): for sa in self.adapters: try: @@ -3016,6 +3018,7 @@ server_names = { 'wsgiref': WSGIRefServer, 'waitress': WaitressServer, 'cherrypy': CherryPyServer, + 'cheroot': CherootServer, 'paste': PasteServer, 'fapws3': FapwsServer, 'tornado': TornadoServer, -- cgit v1.2.1 From 6e9c55ac25993e12eb9674c4b11c8673c55cfd54 Mon Sep 17 00:00:00 2001 From: Marcel Hellkamp Date: Sat, 25 Mar 2017 17:53:27 +0100 Subject: Added depr warning for the outdated cherrypy server adapter. If you are using this adapter, simply switch to 'cheroot' This should fix some recent and some very old issues regarding cherrypy: fix #947 Leave explicit the maxima version supported the CherryPy (<= 9.0.0) fix #932 Add ServerAdapter (fix CherryPy ServerAdapter) fix #685 Update CherryPy SSL to use latest API and work on Py3 fix #574 Allow custom bind_addr for CherryPy (backported from commit be90814117008e6f19a2d8d5c67b876787888aa6) [juergh: Adjust context, drop modifications of test/travis-requirements.txt which does not exist in 0.12.] Signed-off-by: Juerg Haefliger --- bottle.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bottle.py b/bottle.py index 11121b8..60e6c9d 100644 --- a/bottle.py +++ b/bottle.py @@ -2793,7 +2793,11 @@ class WSGIRefServer(ServerAdapter): class CherryPyServer(ServerAdapter): def run(self, handler): # pragma: no cover - from cherrypy import wsgiserver + depr(0, 13, "The wsgi server part of cherrypy was split into a new " + "project called 'cheroot'.", "Use the 'cheroot' server " + "adapter instead of cherrypy.") + from cherrypy import wsgiserver # This will fail for CherryPy >= 9 + self.options['bind_addr'] = (self.host, self.port) self.options['wsgi_app'] = handler -- cgit v1.2.1