通过 Eclipse 调试 Pylons 应用程序

发布于 2024-07-06 20:57:57 字数 116 浏览 10 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

满地尘埃落定 2024-07-13 20:57:57

创建一个新的启动配置(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

半寸时光 2024-07-13 20:57:57

如果您不想将 Python 安装包含在项目工作区中来获取粘贴,您可以创建一个纯 Python 驱动程序,例如:

#!/usr/bin/env python

from paste.script.serve import ServeCommand

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

...并在 Eclipse 中运行/调试该驱动程序。

注意:这是在没有 --reload 选项的情况下运行的,因此您不会进行热部署(即,您需要重新加载服务器才能看到更改)。 或者,您可以添加 --reload 选项来进行热部署,但 Pydev 不会在您的断点处停止。 不能鱼与熊掌兼得……

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

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"])
假面具 2024-07-13 20:57:57

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.

故事和酒 2024-07-13 20:57:57

我能够通过将参数选项卡中的“工作目录”更改为不使用默认值来获得 --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.

压抑⊿情绪 2024-07-13 20:57:57

在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

狂之美人 2024-07-13 20:57:57

我也成功了(终于)。 我使用 buildout 而不是 virtualenv 来安装 pylons (说明位于: http: //wiki.pylonshq.com/display/pylonscommunity/Howto+install+Pylons+with+buildout),因此上面的说明需要对路径进行一些更改。

-对于“主模块”,我使用:(

${workspace_loc:myeclipseprojectname/bin/paster}

添加 --reload 使断点对我不起作用,我测试了几次)

-对于“程序参数”,我使用:

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

-对于“工作目录,其他:”,我使用:

${workspace_loc:myeclipseprojectname/mypylonsprojectname}

- 如上所述,在“公共选项卡”中,“检查分配控制台并在后台启动”

- 并记住在尝试之前设置断点。

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.

寂寞花火° 2024-07-13 20:57:57

这并没有真正回答有关如何在 Eclipse 中执行此操作的问题。 但我一直在使用 winpdb 调试 Paster 服务器,这是一个非常好的图形化 Python 调试器(您可以使用 easy_install winpdb 安装它)。

只需启动您的服务器,例如:

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

然后单击运行按钮。

正如韦恩所说,有必要使用--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.:

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文