Google App Engine Exploration

As usual, I’ve found yet another technology that peaks my interests and I’m exploring it.  This technology is Google App Engine and is powered by Python.  So far, my thoughts on it are ‘Wow, thats cool!’.  Google opened up the flood gates on 5/30/2008 (or 5/29?) for public beta testing and so I immediately signed up (after sitting on the waiting list for a closed beta invite for a week or two) and registered three applications.  I registered three right off the bat simply because it took me so long to find an available name for the one i wanted to ‘play with’, so I registered all three of my alloted application names right away.

My ‘exploration’ project is simply called ‘Zero Point’, as in ‘There really is no point’.  You can view this application here.

So far, it’s a simple sandbox application with a basic Django template.  I created ‘master.html’ and ‘content.html’ templates, ‘content.html’ simply extends ‘master.html’ — so my main page layout is contained in ‘master.html’ but I render ‘content.html’ currently — spiffy, eh?

I also tied in a simple User account system, using the User API available from Google App Engine.  If you access the site, and then proceed to login, I’ll track your page views — super cool, don’t you think?

So, the point of this blog post is … well, as the blog title implies, to show you a code snippet (or, a ‘code fragment’), so let’s get onto that, shall we?

I was trying to figure out how to make dynamic URL’s, so that I could build out ‘something’ (I really don’t have a plan yet, I just figure it’ll use dynamic URLs) and ran into a small problem — Google App Engine uses an ‘app.yaml’ file to configure your request mappings, and “- url: /.*” should match ‘anything’ that isn’t already explicitly mapped to something else first, right?  Well, that’s what I thought, but I kept getting quiet 404’s without knowing why … so, I looked at the application code just a bit more and realized I was passing an explicit path into my WSGIApplication instantiation.  Converting ‘/’ into ‘/.*’ did the trick.  Now, keep in mind, all of Google’s examples (so far that I’ve read, that is) use this static mapping of ‘/’ for the ‘’ and Google App Engine requires you to map your scripts in app.yaml … so, now your stuck with mapping things to more then one place, what’s the deal with that?

I was looking at an example that uses AJAX, and it has an RSS feed built into it (or something like that) and in the main() function they pass multiple URI’s into WSGIApplication() one for ‘/’ and one for ‘/rss’ — this is where I got the idea to pass a Regular Expression into WSGIApplication.  As expected, it worked and now Zero Point can work with dynamic URL’s — problem solved.

[python]def main():
application = webapp.WSGIApplication([(‘/.*’, MainHandler)], debug=True)

That’s the ‘main’ method, which just simply instantiates my MainHandler for any URL that isn’t mapped to another script file — beautiful, eh?

1 comment for “Google App Engine Exploration

  1. rance
    July 13, 2008 at 6:10 pm

    Thanks, I ran into the same problem luckily stumbled upon your code snippet.

Leave a Reply