如何在 Pydev for Eclipse 中启用 WebOb 响应/请求对象的自动完成功能?
我一直在使用 Pydev/Eclipse 开发 Google App Engine (GAE) 应用程序,但我无法从 WebOb 获取响应/请求对象以进行自动完成。 我使用了广泛推荐的教程来完成所有配置; 自动完成功能适用于我遇到的所有其他情况。
举个例子:如果我输入“self”。 我可以自动完成响应和请求; 如果我选择其中之一,请说“响应”,然后添加一个“。” (到目前为止,将整行内容带到“self.response”。)我没有得到任何选项 - 由于包含了 WebOb 库,我希望得到诸如“out.write()”之类的选项作为选项。
我将以下库包含到我的 Pydev 项目中:
- C:\Program Files\Google\google_appengine
- C:\Program Files\Google\google_appengine\lib\django
- C:\Program Files\Google\google_appengine\lib\webob
- C:\ Program Files\Google\google_appengine\lib\yaml\lib
任何帮助将不胜感激,谢谢。
I've been using Pydev/Eclipse to develop Google App Engine (GAE) applications but I've been unable to get the response/request objects from WebOb to have auto-completion. I used a widely recommended tutorial to get everything configured; auto-completion is working for everything else I've run into.
As an example: if I type in "self." I get auto-completion for response and request; if I select one of those, say "response", and add a "." (bringing the full line to "self.response." thus far) I don't get any options - since the WebOb library is included, I would expect to get things like "out.write()" as an option.
I'm including the following libraries into my Pydev project:
- C:\Program Files\Google\google_appengine
- C:\Program Files\Google\google_appengine\lib\django
- C:\Program Files\Google\google_appengine\lib\webob
- C:\Program Files\Google\google_appengine\lib\yaml\lib
Any help would be much appreciated, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经尝试过安装,并且有效。
但是,请记住,PyDev 的分析在遇到错误时就会停止,这可能是自动完成功能在您的情况下不起作用的原因。
我建议您与主要开发人员 Fabio Zadrozny 联系; 他非常友好、乐于助人,还运行一个 博客,其中包含许多使用各种框架配置 PyDev 的有用技巧,和所有限制。
I have tried on my installation, and it works.
However, bear in mind that PyDev's analysis stops whenever it encounters an error, and this could be a reason why autocompletion is not working in your case.
I would suggest you getting in contact with the main developer, Fabio Zadrozny; he is very friendly and helpful, and also runs a blog with many useful tips for configuring PyDev with various framework, and all limitations.
显然,这是各种 Python IDE 的一个已知问题 - 似乎没有人有单一的解决方案。 Google 更改了一些内部路径,使其只能通过执行 python 脚本来真正确定。 尽管 Wing IDE 有一个不错的解决方案,但我一直无法为 Pydev 提供令人满意的解决方案:
改进自动完成和转到定义
Wing 无法解析最近的 sys.path 黑客行为版本的 Google App Engine,因此可能无法找到某些用于自动完成、转到定义和其他功能的模块。 要解决此问题,请在 dev_appserver.py 的 fix_sys_path 中设置断点并开始调试。
然后,在调试探针工具(仅限 Wing Pro 中)中键入以下内容:
将其复制到剪贴板并通过右键单击该文件打开 dev_appserver.py 的文件属性。 然后,在“环境”选项卡下,为“Python 路径”选择“自定义”,单击“以文本形式查看”按钮并粘贴额外的路径。
如果移动应用程序引擎安装,则需要重做此操作,或者可以使用 ${WING:PROJECT_DIR} 将这些路径转换为基于项目文件的位置。
(摘自:http://www.wingware.com/doc/howtos/谷歌应用引擎)
Apparently this is a known issue with various Python IDEs - and no one seems to have a singular solution. Google changed some internal pathing such that it can only really be determined by executing the python scripts. I haven't been able to come up with a satisfactory solution for Pydev, though there is a decent work-around for the Wing IDE:
Improving Auto-Completion and Goto-Definition
Wing can't parse the sys.path hackery in more recent versions of Google App Engine so it may fail to find some modules for auto-completion, goto-definition and other features. To work around this, set a breakpoint in fix_sys_path in dev_appserver.py and start debugging.
Then, in the Debug Probe tool (in Wing Pro only) type the following:
Copy this to the clipboard and open up the file properties for dev_appserver.py by right-clicking on the file. Then, under the Environment tab select Custom for the Python Path, click on the View as Text button and paste in the extra path.
You will need to redo this if you move the app engine installation, or you can use ${WING:PROJECT_DIR} to convert those paths to base on the location of the project file.
(Taken from: http://www.wingware.com/doc/howtos/google-app-engine)