Brandon Poole
Brandon Poole

Reputation: 372

How to debug and setup break points with Aptana/Eclipse using Pyramid Framework?

I'm having trouble starting debug mode in Aptana using the Pyramid Framework.

The platform I'm using is Debian/Linux, running Python 3.

These are the commands I use to create and run a Pyramid project. (source)

1. pcreate -s starter MyProject      //create project
2. python3.2 setup.py develop        //setup develop mode
3. pserve development.ini            //run application

When I run the 3rd step the terminal shows this and I able to open the browser and view the site.

Starting server in PID 15507.
serving on "http://0.0.0.0:6543"

How do I run the debugger and setup breakpoints so I can step through the code.

Upvotes: 1

Views: 1447

Answers (3)

user4318530
user4318530

Reputation:

I use Xubuntu/linux - python3 I am using eclipse-pydev., this is how i debug through eclipse, i use app.py, inside the project folder(*MyProject)

app.py

from MyProject import main

if __name__ == '__main__':
    settings = {
    'pyramid.reload_templates': 'true',
    'pyramid.debug_authorization': 'false',
    'pyramid.debug_notfound': 'false',
    'pyramid.debug_routematch': 'false',
    'pyramid.default_locale_name': 'en'
    }
    ip="127.0.0.1"
    port="6543"
    app = main(None,settings)

#For waitress
    from waitress import serve
    print("Starting Server on http://{0}:{1}".format(ip,port))    
    serve(app,host=ip,port=port,threads=50)

place breakpoints(for example place it in app.py and see the code travel, place it in views.py-return statements and see it gets triggered, when you move to different route) and click on DEBUG Icon in eclipse- debug python app.py., eclipse asks for opening debug perspective window and the eclipse-console shows,

pydev debugger: starting (pid: 9380)

eclipse open debug perspective window and the breakpoints triggered are shown in the debug window.

I was using,

 pserve development.ini

but i felt launching web app from eclipse using the above script easy, i can stop running server-localhost using console(eclipse) easily.

Upvotes: 0

daniel
daniel

Reputation: 403

I would suggest you to look into the python debugger. There is also an example for debugging Pyramid applications. This might also help: Debug Pylons application through Eclipse.

Upvotes: 2

glockman
glockman

Reputation: 189

This is (or at least was) an issue with Waitress' (the local server running your webapp) interaction with Aptana/pydev/Eclipse.

For Python 2.7, the simple answer is to use paster instead as the local server, which is what I did successfully. Unfortunately Paster has not yet been ported to Python 3 yet, so out of luck there if Python 3 is a requirement.

This may now have been fixed though, as detailed here. Also has some more detailed instructions on how to get paster working, although for 3.x that will not be helpful to you.

Upvotes: 0

Related Questions