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.