How to debug Web2py applications?

Is it possible? By debug I mean setting breakpoints, inspect values and advance step by step.


Asked by: Emily321 | Posted: 05-10-2021






Answer 1

You can do remote debugging of python web apps over TCP/IP with winpdb.

(Link appears down as of June 2019. Try PyPI winpdb)

Answered by: Fenton851 | Posted: 06-11-2021



Answer 2

I haven't used web2py, but if it runs in a terminal window, you can use standard pdb stuff. Add this line somewhere in your code:

import pdb; pdb.set_trace() 

This will invoke the debugger and break. Then you can use PDB commands: n to step to the next line, l to list code, s to step into a function, p to print values, etc.

Answered by: Audrey820 | Posted: 06-11-2021



Answer 3

One can debug applications built on Web2py using the following set-up:

  1. Eclipse IDE
  2. Install Pydev into Eclipse
  3. Set Breakpoints on your code as needed
  4. Within Eclipse right-click the file web2py.py and select Debug As -> Python Run
  5. When a breakpoint is hit Eclipse will jump to the breakpoint where you can inspect variables and step thru the code

Answered by: Roland210 | Posted: 06-11-2021



Answer 4

You can also use Visual Studio 2010. Here's how:

  • Download and install Python Tools for Visual Studio.
  • Create a new project from existing code (File > New > Project From Existing Code...)
  • Specify your web2py folder and use the defaults.
  • Right-click on web2py.py and choose Set as Startup File.
  • Set breakpoints and hit F5 (run) or right-click on web2py.py and choose Start with Debugging.

This is a nice setup if you already use visual studio.

Answered by: Aida317 | Posted: 06-11-2021



Answer 5

Yes, it is possible, Due to the "span prevention" I am still not allowed to post screenshots, but here is a full screenshot hosted at my website:

http://static.techfuel.net/debug_web2py.png

Answered by: Briony785 | Posted: 06-11-2021



Answer 6

I'm debugging web2py applications with Eclipse and PyDev. Here is an article: http://www.web2pyslices.com/main/slices/take_slice/2

Answered by: Roland981 | Posted: 06-11-2021



Answer 7

Here is an article on debugging python with pdb, which will work with web2py. http://sontek.net/debugging-python-with-pdb

Answered by: Adelaide573 | Posted: 06-11-2021



Answer 8

As Carl stated, it is as easy as:

  1. Installing PyDev in Eclipse
  2. Right Click on your Web2Py project, selecting Debug As > Python Run
  3. Selecting web2py.py as the file to run

No other plugins or downloads are needed.

Answered by: Julian487 | Posted: 06-11-2021



Answer 9

@Ned Batchelder is almost right, but the standard way of doing it in web2py is slightly different.

Instead of `import pdb; pdb.set_trace(), you use the code:

from gluon.debug import dbg
dbg.set_trace()

When executing the web application, the application will freeze when it reaches this section of code. You then go to http://127.0.0.1:8000/admin/debug/interact (using the root URL for your application) and it will show a fully interactive, web based debugger:

enter image description here

See documentation.

Answered by: Dainton578 | Posted: 06-11-2021



Similar questions

How will Python and Ruby applications be affected by .NET?

I'm curious about how .NET will affect Python and Ruby applications. Will applications written in IronPython/IronRuby be so specific to the .NET environment, that they will essentially become platform specific? If they don't use any of the .NET features, then what is the advantage of IronPython/IronRuby over their non .NET counterparts?


python - Charts in django Web Applications

I want to Embed a chart in a Web Application developed using django. I have come across Google charts API, ReportLab, PyChart, MatPlotLib and ...


Applications of Python

What are some applications for Python that relative amateur programmers can get into? For example, Ruby has Rails for building web applications. What are some cool applications of Python? Thanks.


What kind of applications are built using Python?

Closed. This question is opinion-based. It is not c...


python - Apache Can't Access Django Applications

so here's the setting: The whole site is working fine if I remove the application (whose name is myapp) in the INSTALLED_APPS section in the settings file I added WSGIPythonHome in apache2.conf I can successfully access the apps via the the interactive python shell in Django (python manage.py shell). I can create, update and delete data. I am using the standard Apache 2 setup for Ub...


web applications - Python / TG2 - Sprox

I am looking into using sprox but I can't seem to find any information about styling the generated form. I am sure its got to be something obvious but i didn't see it in the docs or find anything using a google/google groups search. Ideally i would use sprox to generate the form but be able to pass in some css for layout. I could just manually create the forms but with the built in validation and select, drop down...


web applications - Python code to create link based on the title

Can someone please post a python snippet to create a link based on the title, like in stackoverflow (or wordpress)... e.g. title : Global across "Modules" ? corresponding link : http://example.com/8277516/globals-across-modules I do not need any chars other than alphabets or numbers or '-'. Also i don't need the starting or ending character of the output string to be '...


python - Where to put the debug flag in flask applications

Reading the flask documentation I see that there are two places where usually put the debug flag: after the creation of the flask object app = Flask(__name__) app.debug = True or by the run method app.run(host='0.0.0.0', debug = True) In my project I have the app/init.py file: from fl...


python - How to make APIs for ios applications using django


python - Need queue module to be shared between two applications

I need to share some queue between two applications on same machine, one is Tornado which is going to occasionally add message to that queue and another is python script runs from cron which is going in every iteration add new messages. Can anyone suggest me module for this ? (Can this be solved with redis usage, I avoid to use mysql for this purpose )


web applications - How would one make Python objects persistent in a web-app?

I'm writing a reasonably complex web application. The Python backend runs an algorithm whose state depends on data stored in several interrelated database tables which does not change often, plus user specific data which does change often. The algorithm's per-user state undergoes many small changes as a user works with the application. This algorithm is used often during each user's work to make certain important decisions...


deployment - How to build and deploy Python web applications

I have a Python web application consisting of several Python packages. What is the best way of building and deploying this to the servers? Currently I'm deploying the packages with Capistrano, installing the packages into a virtualenv with bash, and configuring the servers with puppet, but I would like to go for a more Python based solution. I've been looking a bit into zc.buildout, but it's not clear for m...


Remote debugging of multi threaded Python Applications

How can I do remote debugging of a multi threaded Python application, running on an Embedded Linux based system, from Windows XP or Vista? So far I have only come across PyScripter based remote debugging. How does it perform?


design patterns - Open source examples of well designed Python applications


How will Python and Ruby applications be affected by .NET?

I'm curious about how .NET will affect Python and Ruby applications. Will applications written in IronPython/IronRuby be so specific to the .NET environment, that they will essentially become platform specific? If they don't use any of the .NET features, then what is the advantage of IronPython/IronRuby over their non .NET counterparts?


python - How can I get a list of the running applications with GTK?

How can I get a list of the running applications? I'm referring to the ones in the panel at the bottom of the screen.


django - Testing time sensitive applications in Python

I've written an auction system in Django. I want to write unit tests but the application is time sensitive (e.g. the amount advertisers are charged is a function of how long their ad has been active on a website). What's a good approach for testing this type of application? Here's one possible solution: a DateFactory clas...


python - Charts in django Web Applications

I want to Embed a chart in a Web Application developed using django. I have come across Google charts API, ReportLab, PyChart, MatPlotLib and ...


python - How do you deploy django applications for windows?

Closed. This question does not meet Stack Overflow guid...


Packaging Ruby or Python applications for distribution?

Are there any good options other than the JVM for packaging Python or Ruby applications for distribution to end-users? Specifically, I'm looking for ways to be able to write and test a web-based application written in either Ruby or Python, complete with a back-end database, that I can then wrap up in a convenient set of platform-independent packages (of some type) for deployment on Windows, Linux, OS X, and Free...






Still can't find your answer? Check out these communities...



PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python



top