eclipse Web2Py 的良好开发环境设置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4075758/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 15:16:07  来源:igfitidea点击:

A good development environment setup for Web2Py

eclipseideweb2py

提问by joeriks

Have been trying out Web2Py for a couple of days now and I decided it to be a keeper. But there is one thing that concerns me a lot and that might be a showstopper in the end. I need a nice development environment & setup I can trust and be productive with. Coming from the MS Visual Studio world I'm looking for something with good autocomplete / intellisense + functions for versioning and deployment.

已经尝试 Web2Py 几天了,我决定让它成为一个守护者。但是有一件事情让我非常担心,这最终可能会成为一个阻碍。我需要一个良好的开发环境和设置,我可以信任并提高工作效率。来自 MS Visual Studio 世界,我正在寻找具有良好自动完成/智能感知 + 版本控制和部署功能的东西。

I did some attempts to edit my code in Eclipse but it needs additional setup to run with autocomplete, and for debugging I dont know if it's possible. (Noticed there was a Django project template in Eclipse which is a bit tempting I must say.)

我做了一些尝试在 Eclipse 中编辑我的代码,但它需要额外的设置才能使用自动完成运行,而对于调试,我不知道是否可能。(注意到 Eclipse 中有一个 Django 项目模板,我必须说这有点诱人。)

Wing Ide has a instruction on how to get web2py up and running and I am up to testing that one. Not free, but very cheap compared to much in the Windows world.

Wing Ide 有一个关于如何启动和运行 web2py 的说明,我正在测试那个。不是免费的,但与 Windows 世界中的很多相比非常便宜。

I also want a good versioning (hg) setup, and preferably a semi-automatic FTP-deployment-method.

我还想要一个好的版本控制 (hg) 设置,最好是半自动的 FTP 部署方法。

What IDE do Web2Py developers use, and how do your setup look like?

Web2Py 开发人员使用什么 IDE,您的设置如何?

A complete setup script for a project in a good IDE would be awesome! (Just like the installation is, one click to get it running 100%).

一个好的 IDE 中项目的完整设置脚本会很棒!(就像安装一样,一键运行100%)。

Pycharm looks good, perhaps that one can add web2py support http://youtrack.jetbrains.net/issue/PY-1648

Pycharm 看起来不错,也许可以添加 web2py 支持 http://youtrack.jetbrains.net/issue/PY-1648

Thanks a lot!

非常感谢!

采纳答案by mwolfe02

Scripts

脚本

Once I create a new project in web2py I add a few scripts to my main app folder:

在 web2py 中创建一个新项目后,我将一些脚本添加到我的主应用程序文件夹中:

web2py\applications\myapp\DebugWinpdb.bat:

web2py\applications\myapp\DebugWinpdb.bat

C:\Python25\Scripts\winpdb.bat ..\..\web2py.py -i 127.0.0.1 -p8000 -mypassword

web2py\applications\myapp\DebugShell.bat:

web2py\applications\myapp\DebugShell.bat

C:\Python25\Scripts\winpdb.bat ..\..\web2py.py -S myapp -M

web2py\applications\myapp\Shell.bat:

web2py\applications\myapp\Shell.bat

python ..\..\web2py.py -S myapp -M

IDE

集成开发环境

As others have stated you need to do some extra stuffto get autocomplete/intellisense for web2py no matter what IDE you use.

正如其他人所说,无论您使用什么 IDE,您都需要做一些额外的事情来获得 web2py 的自动完成/智能感知。

For me NetBeans was a good compromise between does-everything-if-only-you-can-figure-out-how (Eclipse/PyDev) and does-the-basics-but-few-extras (PyScripter).

对我来说,NetBeans 是在 do-every-if-you-can-figure-out-how (Eclipse/PyDev) 和 do-the-the-basics-but-few-extras (PyScripter) 之间的一个很好的折衷。

NetBeans Setup (Project Properties):

NetBeans 设置(项目属性)

  • Python Category
    • Python Platform: Python 2.x (default is Jython)
  • Run Category
    • Main Module: web2py.py
    • Application Arguments: -i 127.0.0.1 -p 8000 -a mypassword
  • 蟒蛇类
    • Python 平台:Python 2.x(默认为 Jython)
  • 运行类别
    • 主要模块: web2py.py
    • 应用参数: -i 127.0.0.1 -p 8000 -a mypassword

NetBeans Pros:

NetBeans 优点

  • Tight Mercurial integration
    • Highlights which lines have been added, changed, or deleted in your source file as you edit it
    • Selective rollback of individual changes you've made since your last commit
    • One of the nicest visual diff viewers I have used
  • Python PEP8 style hints (fully customizable)
    • Name "foo" is not a valid class name according to your code style (CapitalizedWords)
    • Name "Bar" is not a valid function name according to your code style (lowercase_with_underscores)
    • Auto-format hotkey (corrects spacing around operators, etc)
  • Navigation within source file
    • semantically indexes current source file
    • organizes alphabetically by type (Class, method, attribute, etc)
    • makes even enormous style sheets manageable
  • 紧密的 Mercurial 集成
    • 在编辑源文件时突出显示在源文件中添加、更改或删除了哪些行
    • 选择性回滚自上次提交以来所做的个别更改
    • 我用过的最好的视觉差异查看器之一
  • Python PEP8 样式提示(完全可定制)
    • 根据您的代码风格,名称“foo”不是有效的类名(CapitalizedWords)
    • 根据您的代码样式,名称“Bar”不是有效的函数名称(lowercase_with_underscores)
    • 自动格式化热键(更正操作符周围的间距等)
  • 在源文件中导航
    • 语义索引当前源文件
    • 按类型(类、方法、属性等)按字母顺序组织
    • 甚至可以管理庞大的样式表

NetBeans Cons:

NetBeans 缺点

  • Integrated Debugger doesn't work with web2py (that one really hurts)
  • Long startup time (but acceptably snappy for me once up and running)
  • 集成调试器不能与 web2py 一起工作(那个真的很伤人)
  • 启动时间长(但一旦启动并运行对我来说很快就可以接受)

Version Control

版本控制

I use and highly recommend Mercurial for source control. As mentioned earlier, NetBeans has great support for Mercurial but there are some things I'd just rather do in TortoiseHg.

我使用并强烈推荐 Mercurial 进行源代码控制。正如前面提到的,NetBeans 对 Mercurial 有很大的支持,但有些事情我宁愿在 TortoiseHg 中做。

TortoiseHg Pros:

TortoiseHg 优点

  • Shell overlay icons
  • Repository Explorer
    • view repos history with graphical display of branching/merging
    • one stop shop for Incoming, Outgoing, Push, Pull, Update, etc with button for Commit tool
  • Commit tool
    • Hunk Selection: cherry pick changes from within a file for more focused Commits
    • Add, Remove, Diff, Revert, Move, Remove, Forget
  • 外壳覆盖图标
  • 资源库浏览器
    • 查看带有分支/合并图形显示的回购历史记录
    • 带有提交工具按钮的传入、传出、推送、拉取、更新等一站式服务
  • 提交工具
    • 大块选择:从文件中挑选更改以获得更集中的提交
    • 添加、删除、差异、还原、移动、删除、忘记

TortoiseHg Cons:

TortoiseHg 缺点

  • No easy way to drop directly into a command line
  • Bug that regularly prevents files from being removed during commit (waits indef for a lock to be released; running hg addremovefrom command line is a reliable workaround)
  • 没有简单的方法可以直接进入命令行
  • 在提交期间定期阻止文件被删除的错误(等待 indef 释放锁定;hg addremove从命令行运行是一种可靠的解决方法)

Publishing

出版

I use a combination of WinSCP (for browsing), PuTTY (for terminal commands), and TortoiseHg (for push/pull of my repos) to work with my shared hosting account on Webfaction.

我使用 WinSCP(用于浏览)、PuTTY(用于终端命令)和 TortoiseHg(用于推/拉我的存储库)的组合来处理我在 Webfaction 上的共享主机帐户。

The first thing I do is set up public/private key encryption. If you are having trouble getting this set up between Windows and Linux, try these instructions from Andre Molnar. Short story is you need to generate your private key using ssh-keygen on Linux, copy it down to your Windows machine using WinSCP, then convert it for use with WinSCP and PuTTY.

我做的第一件事是设置公钥/私钥加密。如果您在 Windows 和 Linux 之间进行此设置时遇到问题,请尝试这些来自 Andre Molnar 的说明。简而言之,您需要在 Linux 上使用 ssh-keygen 生成您的私钥,使用 WinSCP 将其复制到您的 Windows 机器上,然后将其转换为与 WinSCP 和 PuTTY 一​​起使用。

Then add the following lines to your global mercurial.ini file:

然后将以下行添加到您的全局 mercurial.ini 文件中:

[ui]
ssh = "C:\Program Files\TortoiseHg\TortoisePlink.exe" -ssh -2 -i "c:\path\to\your\privatekey.ppk"

Even if you have to connect to multiple servers, you need only copy your public key to each of the different servers. You'll also want to let WinSCP and PuTTY know where your private key is located, but those are fairly easy to figure out.

即使您必须连接到多个服务器,您也只需将您的公钥复制到每个不同的服务器上。您还需要让 WinSCP 和 PuTTY 知道您的私钥所在的位置,但这些很容易弄清楚。

回答by mdipierro

Try the new web2py admininterface in trunk. It has a web based mercurial interface and a google deploy interface.

在主干中尝试新的 web2py 管理界面。它有一个基于 Web 的 mercurial 界面和一个谷歌部署界面。

In web2py you can edit applications/admin/models/0.py and set

在 web2py 中,您可以编辑 applications/admin/models/0.py 并设置

TEXT_EDITOR = 'amy'

And you will get the web based Amy editor with autocompletion. It is not default because because it does not work with some browsers and because autocompletion is not as good as eclipse. It may work for you.

您将获得具有自动完成功能的基于 Web 的 Amy 编辑器。它不是默认的,因为它不适用于某些浏览器,并且因为自动完成不如 eclipse。它可能对你有用。

You can use web2py with Eclipse but you need a minor workaround to let Eclipse know about the web2py environment. It is explained here.

您可以将 web2py 与 Eclipse 一起使用,但您需要一个小的解决方法来让 Eclipse 了解 web2py 环境。解释here

I know other users have used other IDEs with web2py, for example WinIDE and pyCharm. I suggest you ask on the web2py mailing list where people are very helpful.

我知道其他用户已经将其他 IDE 与 web2py 一起使用,例如 WinIDE 和 pyCharm。我建议您在 web2py 邮件列表上询问人们非常有帮助的地方。

回答by keybits

I'm pretty sure that the 'one-click setup script' to do all that you are looking for does not exist (at the moment). But don't be put off - you can achieve a nice development environment to suit your needs and there are lots of choices.

我很确定“一键安装脚本”来完成您正在寻找的所有事情(目前)不存在。但是不要犹豫 - 您可以实现一个很好的开发环境来满足您的需求,并且有很多选择。

Although I develop on Windows, I like the setup I have as it's more of a 'Unixy' way of thinking whereby I have a number of tools each doing a specific task. Once you get a workflow setup you can be very productive - although I realise it may look a bit confusing initially coming from a Visual Studio world.

虽然我在 Windows 上开发,但我喜欢我的设置,因为它更像是一种“Unixy”的思维方式,我有许多工具,每个工具都可以完成特定的任务。一旦您获得了工作流设置,您就可以非常高效 - 尽管我意识到它最初来自 Visual Studio 世界可能看起来有点混乱。

Below I outline what I've settled on. I'm sure others will have their own recommendations. Pick the options you like best.

下面我概述一下我已经确定的内容。我相信其他人会有他们自己的建议。选择您最喜欢的选项。

(There should be hyperlinks to useful software below but I don't have enough reputation to include more than 1 link...)

(下面应该有指向有用软件的超链接,但我没有足够的声誉来包含超过 1 个链接......)

For developing on Windows I'm enjoying using Pyscripter. It's free, fast (compared to Aptana / Eclipse / Netbeans etc) and has some nice features (dark theme, integrated python console and code explorer to name a few).

对于在 Windows 上开发,我很喜欢使用 Pyscripter。它免费、快速(与 Aptana / Eclipse / Netbeans 等相比)并且具有一些不错的功能(黑暗主题、集成的 Python 控制台和代码浏览器等等)。

To get code completion / intellisense to work for web2py you need to add some code to your model / controller files because of the way web2py works. There are some instructions in this discussion topicon the web2py group.

由于 web2py 的工作方式,为了让代码完成/智能感知为 web2py 工作,您需要向模型/控制器文件中添加一些代码。在 web2py 组的这个讨论主题中有一些说明。

web2py has a great error ticketing system built in (see the web2py book chapter 3). For more comprehensive debugging, pydb seems to be the way to go. Just put the code below as a breakpoint:

web2py 内置了一个很棒的错误票证系统(请参阅 web2py 书籍第 3 章)。对于更全面的调试,pydb 似乎是要走的路。只需将下面的代码作为断点:

import pydb 
pydb.debugger()

and it'll take you to the debugger.

它会带你到调试器。

I use TortoiseHg for Mercurial integration and it works wonderfully. Combine that with winscp and you can deploy easily.

我使用 TortoiseHg 进行 Mercurial 集成,并且效果很好。将其与 winscp 结合使用,您可以轻松部署。

回答by JLundell

Caveats: I work in OS X, and do most of my coding in BBEdit.

注意事项:我在 OS X 中工作,并且在 BBEdit 中完成我的大部分编码。

That said, I've used both Wing and Komodo IDE for web2py debugging, and they've both worked quite well for me. I haven't tried NetBeans in a while now; when I did the Python support seemed a little rough around the edges. And I've never had the time or patience to come up to speed with Eclipse; it's filed in my mental file cabinet with Emacs, no doubt unjustly to Eclipse and/or Emacs.

也就是说,我使用 Wing 和 Komodo IDE 进行 web2py 调试,它们对我来说都很好。我有一段时间没有尝试过 NetBeans;当我这样做时,Python 支持似乎有点粗糙。而且我从来没有时间或耐心来跟上 Eclipse 的速度。它与 Emacs 一起归档在我的精神文件柜中,这对 Eclipse 和/或 Emacs 无疑是不公正的。

(And I'll echo mdipierro's recommendation to try the web2py mailing list; it's really indispensable--one of web2py's strongest points.)

(我会回应 mdipierro 的建议,尝试使用 web2py 邮件列表;它真的是必不可少的——web2py 的最强点之一。)

回答by pbreitenbach

Have you considered using fewer tools? Both Python and web2py don't require a whole lot of code to get a lot accomplished. web2py only adds 10 or 15 new function calls (besides the HTML helpers and validators). You might find that Eclipse and other IDEs actually get in the way. Setting up new apps in web2py is simple through the admin system. Since the new app scaffolding copies the welcome app, you can customize new app setup by editing the welcome app. With Mercurial (or Git, Subversion or Bazaar) you can set up a server on your machine or with one of the public sites and either push or pull updates to your production server. Keep it simple, I say.

您是否考虑过使用更少的工具?Python 和 web2py 都不需要大量代码来完成很多工作。web2py 只添加了 10 或 15 个新的函数调用(除了 HTML 帮助器和验证器)。您可能会发现 Eclipse 和其他 IDE 实际上会妨碍您。通过管理系统在 web2py 中设置新应用程序很简单。由于新的应用程序脚手架复制了欢迎应用程序,因此您可以通过编辑欢迎应用程序来自定义新应用程序设置。使用 Mercurial(或 Git、Subversion 或 Bazaar),您可以在您的机器上或公共站点之一设置服务器,并将更新推送或拉取到您的生产服务器。保持简单,我说。

回答by kommradHomer

we are using web2py framework for all our web application needs and this is our setup :

我们正在使用 web2py 框架来满足我们所有的 Web 应用程序需求,这是我们的设置:

OS - Ubuntu up-to-date
IDE - Aptana Studio 3.0 with pyDev
Version Control - git
Python 2.7 Browser for developing phase : Chrome

操作系统 - Ubuntu 最新
IDE - 带有 pyDev
版本控制的Aptana Studio 3.0 -
用于开发阶段的git Python 2.7 浏览器:Chrome

回答by Chris Johnson

I've found the Wing IDE debugger to be very useful. It's a powerful debugger across the board, and also can be configured to do remote debugging, which is really important when you are running web2py on a no-GUI remote machine (e.g. at Amazon Web Services).

我发现 Wing IDE 调试器非常有用。它是一个全面的强大调试器,也可以配置为进行远程调试,当您在无 GUI 远程机器(例如在 Amazon Web Services)上运行 web2py 时,这非常重要。