web2py / Google App Engine

Bob Cotton, Feb 22, 2011 interim report

web2py is a website framework using Python. Its home website is at http://www.web2py.com.

Advantages:

  1. Easy-to-use web based tools.
  2. Python is compatible with the Google App Engine.
  3. Standard MVC organization.
  4. URLs control the action defaults.
  5. Built-in protections against the usual attack strategies.
  6. Presentation templates use {{ }} (as with Django) to surround unrestricted Python code.
  7. InstantPress is a web2py blogging application that is both useful and serves as an example.
  8. Can be used with many servers and hosting services, not just GAE.
  9. It provides a common DBS interface that works both with GAE and other databases.
  10. web2py is compatible with Jython, but not on the GAE (where Python may be used).

Documentation:

  1. The website has an online book, as well as other resources. The book is also available at low cost as an e-book or paperback.
  2. The web2py web app is pretty easy to find one's way around.

Set-up gotchas

  1.  If you plan to use Google App Engine, download the source version of web2py even if you are using Windows. After deployment the GAE compiles your code.
  2. web2py may use many recent versions of Python. However, GAE is more picky. See below.

The web2py SDK server is run by using the web2py directory as the current directory, then running web2py.py. (To avoid the console that may appear, instead run pythonw.exe web2py.py.) A temporary password is requested. To get the web2py admin screen even if your app is called "init" or "welcome", set your browser to http://127.0.0.1:8000/admin. 

Google App Engine is a web app platform that is both inexpensive and scalable. The website is at

http://code.google.com/intl/en/appengine/

Advantages:

  1. Well documented.
  2. Huge reliable company.
  3. Painlessly scalable.
  4.  Improvements are added over time.
  5. Free until your app is pulling a lot of traffic, then inexpensive. AlwaysOn, providing three running instances at all times, is $.30 per day.
  6. https is available. However, see below.
  7. Java is also available on the GAE.

Disadvantages:

  1. GAE does not use global transactions, and so web2py with GAE does not use DB transactions at all. Instead it uses the request/response cycle to simulate a transaction, which it can abort on failure.
  2. The Bigtable does not implement certain database ops like joins.
  3. You cannot use both https and a custom domain at the same time. When using https, you will be using a domain like myapp.appspot.com. There is provision for forwarded domains such that the browser displays your domain name, but when in this mode users cannot bookmark individual pages, and https is not available.

Set-up gotchas

  1. GAE seems to require Python version 2.5.4 at this time.
  2. For bat files and icons, map .py, .pyc and pyo. to the above version of python.exe
  3. The following links may be useful for arranging your files: http://groups.google.com/group/web2py/browse_thread/thread/53274e9550174c04  http://groups.google.com/group/opensourcebroadcasting/browse_thread/thread/c95f4828b571eb76?pli=1  http://wiki.web2py.com/Deploying_web2py_on_Google_App_Engine_GAE_

Currently, I have arranged my files differently from the suggestions in the links above. For each application, within the directory google_appengine I add directories appname/web2py (appname\web2py in windows), with a full installation of web2py in each. Then, with the google_appengine directory as current, I can run dev_appserver.py appname/web2py. This starts the server. Within the web2py directory one may use "init" or "welcome" as the app name, so that a bare URL will find the app. The browser URL for your app then is is http://localhost:8080. In the windows version of the GAE SDK, there is a GUI called "launcher" that provides an alternative to using dev_appserver.py for testing and appcfg.py for uploading.

I am working on two GAE apps. The first is simply a copy of InstantPress for blogging. The second is my voting web app, to allow users to make use of my new voting system for their own purposes.