Foray into the Google App Engine

I've been hearing a lot (good and bad) about the Google App Engine.

Aside from the fears of ~~Skynet~~ Google ruling the world, I find the idea of the App Engine really fascinating. To not have to worry about the normal scaling issues! To be able to wield the raw power of Google!

Of course it's not like I really need that power for the scale I'm operating on so I guess the best reasons are

  • because it's neat
  • because I need a Python hobby project

So I've decided to write a comment engine that uses the App Engine for the back end.

Here are my goals:

  • Be able to use it for comments across multiple sites
  • Be able to access it from any language that supports HTTP requests and JSON.
  • Be at least slightly difficult to spam.

That last one is going to be tricky.

My plan so far is that each site that uses the comment engine will get a secret key that it uses to send requests. That should (hopefully) prevent people from submitting comments all willy-nilly from a non-authorized site. The sites themselves will also need to have some mechanism at the comment-posting level to make it slightly harder for spammers.

And that's only for posting. I've decided that it doesn't matter retrieves comments.

At this point, I'm just focusing on putting comments in and getting comments back out. Some method for managing (ie deleting) comments and sites will come later.


Hello World!

Following the Getting Started guide got me a very simple 'hello world' app in about 5 minutes (running locally). Actually deploying the thing to Google was as easy as could be.

Friendly URLs

I'd figured out roughly how I wanted the various urls to work but I was having some trouble figuring out how to implement friendly urls. Some googling lead me to this:

~~~~ {.python name="code"} application = webapp.WSGIApplication( [ ( '/', MainPage), ( r'/get/(.*)/(.*)', HandleFoo) ], debug=True) wzxhzdk:0

Remember our regular expression from before?

/get/(.*)/(.*)

This handles any url in the form /get/stuff/morestuff and hands that request off to the HandleFoo class (which is only handling GET requests, hence the get method).

Each item in the regular expression that's surrounded by parentheses gets passed as a parameter to the get method of the class.

So, for the url /get/stuff/morestuff, the get method is going to output

'stuff''morestuff'

And there you have it. Friendly urls with the Google App Engine.

I'm off to figure out how the simplejson library works.