skyork
skyork

Reputation: 7391

Different ways to debug a web2py application

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.

Upvotes: 5

Views: 1232

Answers (4)

elachell
elachell

Reputation: 2687

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.

Upvotes: 0

Chris Johnson
Chris Johnson

Reputation: 21966

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.

Upvotes: 0

Derek
Derek

Reputation: 60

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

Upvotes: 3

David Nehme
David Nehme

Reputation: 21597

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.

Upvotes: 3

Related Questions