Skip to content

Commit 888aa8e

Browse files
06180339juergh
authored andcommitted
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 b9229ee) Signed-off-by: Juerg Haefliger <[email protected]>
1 parent e1be22d commit 888aa8e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

bottle.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2816,6 +2816,25 @@ def run(self, handler): # pragma: no cover
28162816
server.stop()
28172817

28182818

2819+
class CherootServer(ServerAdapter):
2820+
def run(self, handler): # pragma: no cover
2821+
from cheroot import wsgi
2822+
from cheroot.ssl import builtin
2823+
self.options['bind_addr'] = (self.host, self.port)
2824+
self.options['wsgi_app'] = handler
2825+
certfile = self.options.pop('certfile', None)
2826+
keyfile = self.options.pop('keyfile', None)
2827+
chainfile = self.options.pop('chainfile', None)
2828+
server = wsgi.Server(**self.options)
2829+
if certfile and keyfile:
2830+
server.ssl_adapter = builtin.BuiltinSSLAdapter(
2831+
certfile, keyfile, chainfile)
2832+
try:
2833+
server.start()
2834+
finally:
2835+
server.stop()
2836+
2837+
28192838
class WaitressServer(ServerAdapter):
28202839
def run(self, handler):
28212840
from waitress import serve

0 commit comments

Comments
 (0)