Question

I have Eclipse setup with PyDev and love being able to debug my scripts/apps. I've just started playing around with Pylons and was wondering if there is a way to start up the paster server through Eclipse so I can debug my webapp?

Was it helpful?

Solution

Create a new launch configuration (Python Run)

Main tab

Use paster-script.py as main module (you can find it in the Scripts sub-directory in your python installation directory)

Don't forget to add the root folder of your application in the PYTHONPATH zone

Arguments Set the base directory to the root folder also.

As Program Arguments use "serve development.ini" (or whatever you use to debug your app")

Common Tab

Check allocate console and launch in background

OTHER TIPS

If you'd rather not include your Python installation in your project's workspace to get paster, you can create a pure-Python driver like:

#!/usr/bin/env python

from paste.script.serve import ServeCommand

ServeCommand("serve").run(["development.ini"])

...and run/debug that in Eclipse.

Note: this is running without the --reload option, so you don't get hot deploys (i.e., you'll need to reload server to see changes). Alternatively, you can add the --reload option to get hot deploys, but then Pydev won't stop at your breakpoints. Can't have your cake and eat it too...

ServeCommand("serve").run(["--reload", "development.ini"])

yanjost has it right, just wanted to add that you need to make sure you do not use the --reload option, this will prevent the debugger from properly attaching itself and cause your breakpoints not to work. Just a little thing I ran in to.

I was able to get --reload working by changing the 'Working directory' in the arguments tab to not use default (i.e. select 'Other'->File System->'Root of your Pylons' app where development.ini is stored.

On linux that will probably be /usr/bin/paster or /usr/local/bin/paster for paste script, and for arguments i have: serve ${workspace_loc}${project_path}/development.ini

I also got this working (finally). I used buildout instead of virtualenv to install pylons (instructions at: http://wiki.pylonshq.com/display/pylonscommunity/Howto+install+Pylons+with+buildout), so the instructions above needed to be changed a little as far as the paths go.

-for "Main Module", I use:

${workspace_loc:myeclipseprojectname/bin/paster}

(adding --reload made breakpoints not work for me, and I tested this a couple times)

-for "Program Arguments", I use:

serve ${workspace_loc:myeclipseprojectname/mypylonsprojectname/development.ini}

-for "Working Directory, Other:", I use:

${workspace_loc:myeclipseprojectname/mypylonsprojectname}

-as mentioned above, in "Common Tab", "Check allocate console and launch in background"

-and remember to set a breakpoint before trying.

This doesn't really answer question about how to do it in eclipse. But I've been debugging paster server with winpdb, which is quite nice graphical python debugger (you can install it with easy_install winpdb).

Just start your server e.g.:

winpdb /usr/local/bin/paster serve development.ini

And click run button.

As wayne said, it's necessary to not use --reload option. At least I wasn't able to find how to attach to actual webapp even, when selecting to which forked process debugger should enter (entering different processes can be controlled with "fork parent" and "fork child" debugger commands).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top