A good development environment setup for Web2Py
Asked Answered
B

7

27

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.

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

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.

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

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

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

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

Thanks a lot!

Barcot answered 2/11, 2010 at 7:45 Comment(4)
Wow! 11 hours after my question I already have a four elaborated answers. I am impressed.Barcot
I left web2py temporarily for a month, but now I'm back - and I think I will leave the Ubuntu-track and stick with the server I know, IIS for the live site. Also - I will "keep it simple" in means of less tools, using included versioning (if it works in win env). I hope this is still the valid instructions for IIS-hosting web2py web2py.com/AlterEgo/default/show/207Barcot
(My Ubuntu server crashed for me, dont know what happend. And I seriously lack knowledge about how to safely host with Ubuntu, therefore that platform really is a bad choice for me.)Barcot
web2py support is on the PyCharm 3 roadmap, fwiw.Beker
P
16

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.

Palembang answered 2/11, 2010 at 15:48 Comment(3)
Many thanks for your rich answer! I will have a look at NetBeans and winpdb.Barcot
So you have Web2Py running on a shared hosting account at Webfaction?Barcot
Yes. I don't have any Web2py apps in production on Webfaction but that's just because I haven't gotten that far yet. When I set it up there was a web2py install script on Webfaction (either written by or heavily contributed to by Massimo) that worked very well.Palembang
R
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.

Rudiment answered 2/11, 2010 at 13:26 Comment(3)
Wow, Amy is really cool amyeditor.com/api/embed/test_python.html and I really like where you're going with the new interface, kudos! Wouldn't it be a good idea to have each section models/controllers/views etc on a separate page? In that case one could easily open each one in a browser tab and switch between them easily (with the tab named accordingly).Barcot
We are refactoring admin as we speak. This will happen fast. We are also looking into yemacs. We could use your advise on the web2py google group.Rudiment
It's most for learning I need the intellisense/autocomplete, on the web ui I guess compatibility and a stable environment always should be priority #1.Barcot
N
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.

Nance answered 2/11, 2010 at 12:36 Comment(3)
Do you host your web2py sites on Windows + IIS ? Is this web2py.com/AlterEgo/default/show/207 the way to go?Barcot
Sorry, I host on a Debian VPS with Apache and mod_wsgi - very easy to set up with this web2py.com/book/default/chapter/…Nance
Ok, thanks, but even though it might be easy to setup - for me, I'm not familiar enough with Apache and *nix to run a website that should be reliable on them. A simple error and I'm lost googling for answers for hours.Barcot
S
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.)

Session answered 2/11, 2010 at 18:17 Comment(0)
Q
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.

Quinlan answered 29/11, 2010 at 23:41 Comment(1)
only 10 or 15 new function calls? Elaborate on that.Trulatrull
U
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

Univalence answered 2/4, 2012 at 11:14 Comment(0)
B
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).

Borage answered 24/11, 2012 at 10:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.