Some of the information here may be outdated, please check the book instead

(source: web2py and google appengine)

It kicks ass.

There's a video that demonstrates web2py and Google appengine that pretty much says it all. If you're like me, and you'd rather read a set of step-by-step instructions than watch a video, this is for you. (OK, this is actually for me when I start a new project 6 months down the road and have forgotten how to do this stuff).

Go to the Google SDK Download page. Get the Linux/Other Platforms one. Doesn't matter what platform you're actually running. I've seen weird stuff happen with the Windows installer. Unzip it wherever you feel like. (If you're a python geek, feel free to put it in you PYTHONPATH. If not, it really doesn't matter). Just somewhere that's convenient for you.

Download web2py. I recommend the source code version, because it gives you more flexibility about where to put stuff. But whatever floats your boat.

After you've extracted/installed web2py, run it. If you're on windows, it's web2py.exe. If you're on linux, the command is "python". It opens a server controller dialog.

Enter an admin password. Doesn't matter what it is. But, if you don't enter it, you won't be able to get to the admin control panel. Click the "Start Server" button.

It should open up a browser window that is looking at its home page. There's a link to the admin interface (if you gave it an admin password) and another to a set of examples.

Go to the admin page. Build your app there. (This is the fun part...seriously, check out that video). There are some limitations about what you can do with the models. These are actually due to limitations in appengine. Don't try to get too fancy, and you should be fine.

When you're ready to move forward, update your models. If you've been sticking to the default sqlite (and I can't think of any reason to change), comment out the first line that imports that. Replace it with

from gluon.contrib.gql import GQLDB
db = GQLDB()

(the last line tells web2py to store session in the google DB)

Stop and close the web2py server.

There's an app.yaml file in the root of the web2py distribution. Update it to reflect your application's name.

Open a command prompt in the folder that contains your web2py directory. Start the appengine server with "python [web2py directory]".

Test your app! (I know that seems like a no-brainer, but some people...)

Update the version in app.yaml, and upload with "python [web2py root directory]".

NOTE: This leaves all the "extra" stuff that web2py installs. Examples and such. And the root of your app is still the default web2py greeting page. So the URL to your app is something like http://[appname][appname]. That may be what you want. If you want your app to be the defalt one, just call it "init". It also uses up around 382 files, which could/should probably be stripped down immensely. The command line stuff should probably be replaced with .BAT files (or whatever's the equivalent on your OS).

So far, I've introduced two friends to web2py. They both had previously tried to get into Ruby On Rails, but they didn't like dealing with all the command line stuff. They both agree with me that python's more intuitive and simpler than ruby. They don't really care that it isn't as powerful, because they're really coming from lower level languages like C#.

Of course, there are all sorts of other frameworks out there, and web2py seems to be pretty young. There are things about it I don't like, but that's true about every framework. I've only begun to scratch the surface with it, but so far I'm extremely impressed.

© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by web2py - design derived from a theme by the earlybird
The content of this book is released under the Artistic License 2.0 - Modified content cannot be reproduced.