in

Corey Roth and Friends Blogs

Group site for developer blogs dealing with (usually) Ionic, .NET, SharePoint, Office 365, Mobile Development, and other Microsoft products, as well as some discussion of general programming related concepts.

Not Necessarily Dot Net

First Impressions of Web2py

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 web2py.py".  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()

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 dev_appserver.py [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 appcfg.py [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].appspot.com/[appname].  That may be what you want.  I need to dig deeper and figure out how to change that behavior, because that is not what I want.  (It may be a matter of just replacing the welcome application with your own).  I'll blog about that as soon as I figure that out (unless someone wanders across this and leaves the answer in the comments). 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).

UPDATE: Massimo Di Pierro was kind enough to inform me that, to make a specific app the "default" one that gets shown as the root, just name it either init or welcome.

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 powerfulhigh-level, 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.

Comments

 

Jens Kristian Jensen said:

Thanks for your review. I went through the same learning recently - including the default app issue, which I found out can be done via init/welcome, URL rewriting (routes.py) or by a URL redirect from init or welcome app. I didn't know the "official" suggestion, so I'm glad to find it from Massimo here.

He's incredibly helpful and it still amazes me what an unpolished gem that web2py is. For many people it is also an undiscovered gem...

Did you actually get to use web2py for a real project and how did it turn out?

November 27, 2009 3:20 PM

Leave a Comment

(required)  
(optional)
(required)  
Add
2019.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems