Skip to content

Commit

Permalink
Merge branch 'release-0.12+cheroot' of https://github.com/juergh/bottle
Browse files Browse the repository at this point in the history
… into release-0.12
  • Loading branch information
defnull committed May 26, 2022
2 parents e140e1b + 6e9c55a commit 04b27f1
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions bottle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2795,7 +2795,11 @@ class server_cls(server_cls):

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

Expand All @@ -2818,6 +2822,25 @@ def run(self, handler): # pragma: no cover
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
Expand Down Expand Up @@ -2985,7 +3008,9 @@ def run(self, handler):

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:
Expand All @@ -2999,6 +3024,7 @@ def run(self, handler):
'wsgiref': WSGIRefServer,
'waitress': WaitressServer,
'cherrypy': CherryPyServer,
'cheroot': CherootServer,
'paste': PasteServer,
'fapws3': FapwsServer,
'tornado': TornadoServer,
Expand Down

0 comments on commit 04b27f1

Please sign in to comment.