Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 940
skyork Avatar asked Mar 28 '12 04:03

skyork


People also ask

How do you debug a Python application?

Starting Python Debugger To start debugging within the program just insert import pdb, pdb. set_trace() commands. Run your script normally, and execution will stop where we have introduced a breakpoint. So basically we are hard coding a breakpoint on a line below where we call set_trace().

How do I use web2py?

for the different applications that you create. To start your Web2py web server, run the web2py.exe from your extracted files and it will then ask you to set up an administrative password to access your applications at a later point in time. Clicking on start server will open your web2py applications in the browser.


1 Answers

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.

like image 192
David Nehme Avatar answered Sep 22 '22 15:09

David Nehme