Pycharm and Cherrypy

I'm planning to use CherryPy for a project and was wondering how to set up my Pycharm environment in order to run and debug code using the CherryPy framework?  Right now I'm most curious about how to set up a project, implement some sample code, and then be able to trigger a breakpoint when exercising it via a web browser interface.

Thanks for any information you can provide on how to go about doing the above!

Best regards,

Mark
2 comments
Comment actions Permalink
Hi Mark,  I'm currently working on a CherryPy application myself and found that I didn't really have to do anything special with the PyCharm environment to run and debug the application.  Setting breakpoints in PyCharm work just as you would expect.  In case it helps, following is what I'm currently using for my CherryPy global config and startup (I put this in the __main__ of the startup python file).

Regards,
John

    global_conf = {
        'global': { 'engine.autoreload.on': False,
     'server.socket_host': '0.0.0.0',
     'server.socket_port': 8080,
     'log.screen': True,

   }}


    cherrypy.config.update(global_conf)

    # mount the application on the '/' base path
    app = cherrypy.tree.mount(Root(), '/', config = application_conf)

    # Initialize signal handler.
    if hasattr(cherrypy.engine, 'signal_handler'):
        cherrypy.engine.signal_handler.subscribe()
    
    # Initialize console control
    if hasattr(cherrypy.engine, "console_control_handler"):
        cherrypy.engine.console_control_handler.subscribe()

    # Start the engine.
    cherrypy.engine.start()
    
    # Running standalone so we need to block.
    cherrypy.engine.block()
0
Comment actions Permalink
John - I finally had a chance to give this a try last night and it worked as you stated.  I was expecting to have to connect to a remote running process where this isn't the case.  Thanks for the help.  I really appreciate it!

Mark
0

Please sign in to leave a comment.