bottle with current (10.*) cherrypy

304 views
Skip to first unread message

tomasz bandura

unread,
Jan 31, 2017, 10:02:11 AM1/31/17
to bottlepy
Hello,

For standard bottle app configuration with installed current cherrypy server:

run(app,..., server='cherrypy')

bottle raises an exception:

Traceback (most recent call last):
File "C:\opt\Python27\lib\site-packages\bottle.py", line 3123, in run
server.run(app)
File "C:\opt\Python27\lib\site-packages\bottle.py", line 2787, in run
from cherrypy import wsgiserver
ImportError: cannot import name wsgiserver


I've checked cherrypy and it looks wsgisever now is not a part of cherrypy (was moved to cheroot project from 9.0 version)
I'm not sure if it is change request?

Regards,
Tomasz

Lars van Gemerden

unread,
Apr 27, 2017, 7:54:52 AM4/27/17
to bottlepy
exact same problem here

hennin...@googlemail.com

unread,
Mar 19, 2018, 8:54:39 AM3/19/18
to bottlepy
I had the same problem and managed to solve it based on the Code posted here.

Apparently, you import the wsgi module from cheroot and then create a new server adapter (extending the ServerAdapter Baseclass in bottlepy). This class can then be passed as the "server" parameter to the normal bottlepy run() function. Here is my code. I currently do not use the SSL Features.

from bottle import debug, run, ServerAdapter
from cheroot import wsgi
from cheroot.ssl.builtin import BuiltinSSLAdapter

# Server implementation and interplay with bottlepy based on
# https://github.com/nickbabcock/bottle-ssl/blob/master/main.py
class SSLCherryPyServer(ServerAdapter):
def run(self, handler):
server = wsgi.Server((self.host, self.port), handler)
#server.ssl_adapter = BuiltinSSLAdapter('cacert.pem', 'privkey.pem')

# By default, the server will allow negotiations with extremely old protocols
# that are susceptible to attacks, so we only allow TLSv1.2
#server.ssl_adapter.context.options |= ssl.OP_NO_TLSv1
#server.ssl_adapter.context.options |= ssl.OP_NO_TLSv1_1

try:
server.start()
finally:
server.stop()

debug(True)
if __name__ == '__main__':
port = int(os.environ.get("PORT", 8080))
run(app, reloader=True, host='0.0.0.0', port=port, server=SSLCherryPyServer)
Reply all
Reply to author
Forward
0 new messages