The Scoop

  • Home
  • Projects
  • About The Scoop
  • Fixing Journalism
  • Medill Links
  • Departments
    • API
    • Apple
    • Asides
    • Broadcast
    • Campaign Finance
    • Car Tools
    • Code
    • Data
    • DIY
    • django
    • Fed Data
    • FOIA
    • General
    • IRE
    • Journalism
    • Local Data
    • Mapping
    • Miscellany
    • NonGov Data
    • Online
    • Paper Trail
    • Presentations
    • Public Records
    • Python
    • Rails
    • Ruby
    • SLA
    • Social Network Analysis
    • Sports
    • State Data
    • Teaching
    • Work
    • XML
  • Subscribe via RSS

A Gentle Introduction to Google App Engine

February 23rd, 2010  |  Published in Python

As part of our roll-out of version 3 of the NYT Congress API, I was tasked with coming up with a sample application that uses the API to do something mildly interesting, or at least functional. I had gotten a book on Google App Engine for my birthday and was pretty excited to see that some of the basic philosophies of Django were either incorporated directly into GAE or were easy to adapt to it. So when I started on the sample app, I picked GAE and dove in.

App Engine’s Python runtime, unsurprisingly, sticks pretty close to the language’s core tenets: it uses YAML files for configuration (hey, it’s whitespace!) and can run pretty much an entire app using just 2-3 files. A NYT colleague, Derek Gottfrid, built a sample app for our article search API comprising five files, including the README. Yes, it violates the separation of logic and design that most frameworks try to respect, but it works.

GAE provides the basic building blocks a lot of Web apps need, nearly all optional: a backend in Datastore, a URL Fetch service that is wrapped by Python’s familiar urllib and urllib2 libraries, mail and messaging services and memcache. Webapp is a basic framework for building apps not exactly like Django but not so unfamiliar, either.

The development server will be familiar to anyone who has tinkered with Django, and GAE handles static files via separate servers, which is how it should be. And since it comes with a version of Django built-in, you can bring along some handy utilities, like simplejson, with a single import statement. And as I said earlier, you don’t have to separate display logic into template files, but you can, and the syntax is nearly identical to Django templates.

The sample app takes two random members of the Senate and compares their voting and bill sponsorship records in the 111th Congress. The app’s code is like the app itself: fairly tightly-focused and without a lot of trappings. It’s just service calls to the API and a single template for display. In building it, I didn’t make use of any persistent storage, so I didn’t delve into Datastore, but it looks pretty useful. One of its helpful features is that as you develop your app, it generates indexes used to help return data in the most efficient manner.

If you’re already familiar with Django, making the small step to App Engine isn’t that big of a trip. Have Guido explain things to you first, and then try it out. You can also run a stripped-down version of Django on GAE, and I’m looking to see if there’s a project I can adapt to try it out. In the meantime, if you want to tinker with the sample app, by all means fork it and see what else you can do with the API. And let me know what you come up with!

Leave a Response

Recent Comments

  • Phil Underwood on Django, iCal and vObject
  • Derek Willis on Xpdf on the Mac
  • Danielle on Xpdf on the Mac
  • Christopher on Measuring Vocabulary Richness (or, Trying Out Django on Heroku)
  • malcolm tesla on A GitHub for Data?

Recent Posts

  • What We Don’t Know About Elections
  • RemoteTable Is Your Friend
  • Measuring Vocabulary Richness (or, Trying Out Django on Heroku)
  • In Defense of Building Tools
  • Why Teach SQL?

Linking Out

  • Mapping America — Census Bureau 2005-9 American Community Survey - NYTimes.com
    holy crap
  • Backbone.js and Django | joshbohde.com
  • ProPublica
  • Geoff: GeoJSON Feature Functions for JavaScript
  • Introducing Spanner: From Documents to Linked Data Apps—Clark & Parsia: Thinking Clearly
  • A performance lesson on Django QuerySets | Seek Nuance
  • http://www.post-gazette.com/pg/03001/1108747-209.stm
  • CBC News - Canada - Database: Canadian cables in WikiLeaks
  • Federal prosecutors likely to keep jobs after cases collapse - USATODAY.com
  • Strata Gems: Explore and visualize graphs with Gephi - O'Reilly Radar


©2012 The Scoop
Powered by WordPress using the Gridline Lite theme by Graph Paper Press.