Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A good development environment setup for Web2Py

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!

like image 287
joeriks Avatar asked Nov 02 '10 07:11

joeriks


People also ask

What is web2py framework?

To summarize, Web2py is a free, fast, secure web development framework that is entirely written in python and encourages using python in every way possible (model, view, controller). It is a very good framework for small web applications or prototypes but fails to fulfil the enterprise class quality requirements.

Is web2py an mvc framework?

The design of web2py was inspired by the Ruby on Rails and Django frameworks. Like these frameworks, web2py focuses on rapid development, favors convention over configuration approach and follows a model–view–controller (MVC) architectural pattern.

How web2py works?

web2py separates the data representation (the model) from the data presentation (the view) and also from the application logic and workflow (the controller). web2py provides libraries to help the developer design, implement, and test each of these three parts separately, and makes them work together.


2 Answers

  • OS: Windows 7/Windows XP
  • IDE: NetBeans
  • Version control: TortoiseHg/NetBeans
  • Debugger: winpdb
  • Shell: IPython
  • Publish: WinSCP/PuTTY/TortoiseHg

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.

like image 90
mwolfe02 Avatar answered Sep 24 '22 21:09

mwolfe02


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.

like image 44
mdipierro Avatar answered Sep 24 '22 21:09

mdipierro