5

As I am new to web2py, I wonder what are the ways available for debugging a web2py application. So far, I've come across the following scenarios:

  1. when a runtime error occurs in a web2py app, an error ticket is generated and normally useful information is contained in the ticket.

  2. however, sometimes only a plain error message is available on a page, for example, 'bad request'. that's it. So what would be the best way in this case to track down what goes wrong? Logging? If so, how do we do it properly?

  3. if no obvious error message is shown, but the app doesn't perform as expected. Usually, I use a debugger with breakpoints to check it out. Any other suggestion?

Any experience/insight is extremely welcome.

skyork
  • 7,113
  • 18
  • 63
  • 103

4 Answers4

3

You can detect errors at your model or controller layer by adding unit tests. That will help narrow your debugging efforts, especially when the error ticket system breaks down. Unfortunately the web2py documentation doesn't stress the importance of unit tests enough. You can run doctests on your controllers with

python web2py.py -T <application_name>

Since the model layers run for each controller, you will at least find syntax errors in your at the model layer.

David Nehme
  • 21,379
  • 8
  • 78
  • 117
3

The latest version has an integrated debugger. You can set breakpoints on your code and step through it.

Derek
  • 60
  • 2
  • 8
0

The other suggestions are good. I would also suggest the Wing IDE debugger. It isn't very expensive, and works well with Python generally and web2py specifically.

Wing has a capability to do remote debugging -- very useful when you're working through production-style deployment with remote app servers. That capability saved my bacon any number of times.

Chris Johnson
  • 20,650
  • 6
  • 81
  • 80
0

As @Derek pointed out there is an integrated debugger for web2py

You can set a breakpoint from the integrated Web2py editor (clicking on 'toggle breakpoint') or setting it manually as indicated in the above link.

Once you hit the breakpoint, you can open http://localhost:8000/admin/debug/interact (if running locally to evaluate any expression at that point.

elachell
  • 2,527
  • 1
  • 26
  • 25