When Google App Engine was released I attended Google’s sprint in New York City excited at the possibility of being able to host python applications without having to deal with the hassles of maintaining a server. I spent the week after the sprint rewriting a Plyons project so that I could host it on App Engine.
The rewrite left me extremely frustrated:
- I had designed the application with a relational database in mind, and couldn’t stop myself from thinking about the data in a relational way. After the rewrite, the database layer of my project was both ugly and inefficient.
- Beaker (the session and cache middleware that ships with Pylons) was extremely buggy when interacting with GAE. (I would log into my application from Firefox, open up same application with Safari, and it would show me as logged in even though Safari didn’t have any cookies set)
- Since the pylons project rolled its own user management / authentication system, I wasn’t taking advantage of Google App Engine’s ability to interact with Google Accounts.
This was almost a year ago. I didn’t look at Google App Engine again until a train ride a few weeks ago. I was in the process of tutoring a friend for the LSAT exam and I wanted him to memorize a few terms for the exam. I urged him to make a set of flash cards so that he could regularly quiz himself. I searched online for a website that would allow me to easily create and share flashcards. I found a few, but none that saved a revision history of the edits made to a card.
My goal was to create an application that allows users to log in and create and edit flash cards. I had another requirement: I did not want to spend more than two hours on the project. Unfortunately, from past experience I know that writing code for a user management system with passwords and email confirmation can take a week in itself.
I figured that this would be a good time to try and use Google App Engine to see how easy it would be to integrate an application with Google Accounts. It turned out to be much simpler than I had originally expected. There are only three function calls that you have to know about when integrating Google Apps within your app:
- When your app wants to log a user in: users.create_login_url(“/”) where the string passed in is the URL that you want Google to redirect the user to after they login.
- To check to see which user (if any) us logged in, your app can use the users.get_current_user() command.
- When your app want log a user out: users.create_logout_link(“/”) where the string passed in is the URL that you want Google to redirect the user to after they logout.
And that is it! In five minutes I had a user management / authentication system for my application (with CAPTCHA, confirmation email, and forgot password functionality that is available with every Google account). With the user management part of the application taken care of, the rest of the application was extremely simple and straight forward to create.
For me, the biggest win in using Google App Engine is not the ability to send my application into the cloud (and thus not have to worry about scaling and system adminitration). Rather, I love not having to build a user management system every time I create a new application.
The code for the flash card application lives at Github.
The application itself runs here.
Leave a Reply