Debug Pylons application through Eclipse

后端 未结 7 1927
[愿得一人]
[愿得一人] 2020-12-24 09:22

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

相关标签:
7条回答
  • 2020-12-24 09:50

    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

    0 讨论(0)
  • 2020-12-24 09:51

    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.

    0 讨论(0)
  • 2020-12-24 09:51

    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

    0 讨论(0)
  • 2020-12-24 09:51

    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.

    0 讨论(0)
  • 2020-12-24 10:04

    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.

    0 讨论(0)
  • 2020-12-24 10:05

    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"])
    
    0 讨论(0)
提交回复
热议问题