score:16

Accepted answer

Scripts

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

web2py\applications\myapp\DebugWinpdb.bat:

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

web2py\applications\myapp\DebugShell.bat:

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

web2py\applications\myapp\Shell.bat:

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

IDE

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

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 Setup (Project Properties):

  • 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

NetBeans Pros:

  • 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

NetBeans Cons:

  • Integrated Debugger doesn't work with web2py (that one really hurts)
  • Long startup time (but acceptably snappy for me once up and running)

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.

TortoiseHg Pros:

  • 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:

  • 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 addremove from command line is a reliable workaround)

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.

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.

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

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

score:0

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

score:1

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

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

score:5

Caveats: I work in OS X, and do most of my coding in 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.

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

score:5

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.

score:8

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.

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

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

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 topic on the web2py group.

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:

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.

score:12

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

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

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.

You can use web2py with Eclipse but you need a minor workaround to let Eclipse know about the web2py environment. It is explained 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.


Related Query

More Query from same tag