通过 Eclipse 调试 Pylons 应用程序
我使用 PyDev 设置了 Eclipse,并且喜欢能够调试我的脚本/应用程序。 我刚刚开始使用 Pylons,想知道是否有办法通过 Eclipse 启动 Paster 服务器,以便我可以调试我的 Web 应用程序?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
创建一个新的启动配置(Python运行)
主选项卡
使用paster-script.py作为主模块(你可以在Python安装目录的Scripts子目录中找到它)
不要忘记添加PYTHONPATH 区域中应用程序的根文件夹
参数
将基本目录也设置为根文件夹。
由于程序参数使用“servedevelopment.ini”(或任何您用来调试应用程序的内容)
通用选项卡
检查分配控制台并在后台启动
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
如果您不想将 Python 安装包含在项目工作区中来获取粘贴,您可以创建一个纯 Python 驱动程序,例如:
...并在 Eclipse 中运行/调试该驱动程序。
注意:这是在没有
--reload
选项的情况下运行的,因此您不会进行热部署(即,您需要重新加载服务器才能看到更改)。 或者,您可以添加--reload
选项来进行热部署,但 Pydev 不会在您的断点处停止。 不能鱼与熊掌兼得……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:
...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...yanjost 说得对,只是想补充一点,您需要确保不使用 --reload 选项,这将阻止调试器正确附加自身并导致断点不起作用。 只是我遇到的一件小事。
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.
我能够通过将参数选项卡中的“工作目录”更改为不使用默认值来获得 --reload 工作(即选择“其他”->文件系统->“Pylons 的根”应用程序,其中development.ini 是存储。
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.
在Linux上,可能是 /usr/bin/paster 或 /usr/local/bin/paster 用于粘贴脚本,对于参数我有:serve ${workspace_loc}${project_path}/development.ini
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
我也成功了(终于)。 我使用 buildout 而不是 virtualenv 来安装 pylons (说明位于: http: //wiki.pylonshq.com/display/pylonscommunity/Howto+install+Pylons+with+buildout),因此上面的说明需要对路径进行一些更改。
-对于“主模块”,我使用:(
添加 --reload 使断点对我不起作用,我测试了几次)
-对于“程序参数”,我使用:
-对于“工作目录,其他:”,我使用:
- 如上所述,在“公共选项卡”中,“检查分配控制台并在后台启动”
- 并记住在尝试之前设置断点。
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:
(adding --reload made breakpoints not work for me, and I tested this a couple times)
-for "Program Arguments", I use:
-for "Working Directory, Other:", I use:
-as mentioned above, in "Common Tab", "Check allocate console and launch in background"
-and remember to set a breakpoint before trying.
这并没有真正回答有关如何在 Eclipse 中执行此操作的问题。 但我一直在使用 winpdb 调试 Paster 服务器,这是一个非常好的图形化 Python 调试器(您可以使用 easy_install winpdb 安装它)。
只需启动您的服务器,例如:
然后单击运行按钮。
正如韦恩所说,有必要不使用--reload选项。 至少在选择应该进入哪个分叉进程调试器时(可以使用“forkparent”和“forkchild”调试器命令控制输入不同的进程),我什至无法找到如何附加到实际的web应用程序。
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.:
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).