The selector4cherrypy is a dispatcher for CherryPy 3 that uses the selector dispatcher to perform URL lookup and matching.
import cherrypy from selector4cherrypy import SelectorDispatcher class Root(object): def index(self): return "blah" def profile(self, name): return name class EventPublisher(object): def __call__(self, environ, start_response): start_response('200 OK', [('content-type', 'text/html')]) return ['hey there'] global_conf = {'engine.autoreload_on' : False, 'server.socket_port' : 8090, 'server.socket_host': '127.0.0.1', 'checker.on': False} cherrypy.config.update({ 'global' : global_conf }) root = Root() ev = EventPublisher() disp = SelectorDispatcher() disp.add('/test', GET=root.index) disp.add('/', GET=ev) # we map / for script_name /some, see below the grafting of the selector WSGI app conf = {'/' : {'request.dispatch': disp}} cherrypy.tree.mount(root, '/', config=conf) cherrypy.tree.graft(disp.s, '/some') cherrypy.engine.start() cherrypy.engine.block()
