6

I've seen this question posted here before but I want to get a final yes/no on this.

I've been trying to debug my app using Netbeans 6.8 (no luck at all) and the newly released Netbeans 6.9 (notices that code has been called but fails to stop the code from executing).

Is it possible to debug CherryPy applications?

Community
  • 1
  • 1
OrganicPanda
  • 2,667
  • 1
  • 27
  • 28
  • I can say with certainty it's possible in CPython (I do it all the time). I have no idea if it's true in a Jython environment (which I'm assuming your using). – Eric Palakovich Carr Jun 29 '10 at 14:11
  • I have Netbeans configured to use my standard Python (CPython) installation. Can you provide any more information about how you got it working? What IDE (if any) do you use? – OrganicPanda Jun 29 '10 at 15:59
  • You can certainly debug CherryPy with pdb, so if you can't debug it with Netbeans, that's a fault of Netbeans. – Nick Bastin Jul 13 '10 at 08:03

4 Answers4

4

I use wdb. It uses websockets, looks great and can be hooked in any WSGI app (like CherryPy). It opens a new debugging tab in your browser when triggered.

Follow these instructions to configure your CherryPy app, and in your code write a line like the next and restart the app:

import wdb;wdb.set_trace()

Also any exceptions in the app (not all in CherryPy, though) should be catched.

Yajo
  • 5,808
  • 2
  • 30
  • 34
4

I use breakpoints in cherrypy all the time in Wing IDE (3.x). I should mentions that I don't debug when the application is hosted through a webserver. I run the application using cherrypy's build in webserver, using my CPython interpreter installed on the machine.

The code looks something like this:

# main.py

# ...snip...

if __name__ == '__main__':

    # Handle configuration settings, calling cherrypy.tree.mount in the process
    generate_app(options.environment)

    # Run the web server
    engine = cherrypy.engine
    try:
        engine.start()
    except:
        sys.exit(1)
    else:
        engine.block()

Then, in Wing IDE, I put a break point somewhere (say in one of my controllers) and then run main.py through the IDE. Pointing a browser at the url of the controller will cause the breakpoint to trigger.

Hope that information was helpful.

Eric Palakovich Carr
  • 22,701
  • 8
  • 49
  • 54
  • Wing looks a bit pricey for me; I'd like to stick to Netbeans but it's good to know that this is possible - I guess the Netbeans python plugin just needs to mature a bit first to catch up with Wing – OrganicPanda Jun 30 '10 at 08:56
3

There's debugging (stepping through code) and then there's debugging (playing with a live system). You can do the latter easily by mounting an http://www.aminus.net/wiki/HTTPREPL in your app.

fumanchu
  • 14,419
  • 6
  • 31
  • 36
0

In Spyder I've managed to use pdb in a CherryPy application by writing breakpoint() just before the line I want to inspect.

This breaks into the Spyder debugger, exposing all the regular step in/out functionality.

Saaru Lindestøkke
  • 2,067
  • 1
  • 25
  • 51