Google App Engine with Python Client Library
written by Thura Z
at Monday, 21 April 2008
Here is the new version of Python code library with Google App Engine, released by Jeff Scudder, Google Data APIs Team. Google App Engine can able to integrate with Google Apps, and the new library has support for Google App Engine and the Contacts API. The details are from here.
The 1.0.12.1 release of the gdata-python-client has a couple of nifty new features which I thought are worth mentioning. First, is a new module which allows the Python library to be used on Google App Engine. Since the App Engine runs a sandboxed Python interpreter, HTTP calls must be made using one of the App Engine's APIs: urlfetch. After some refactoring of the library's code, I was able to write a drop-in replacement for making HTTP requests, so that the gdata.service module can be used on Google App Engine. To use urlfetch instead of the library's default (httplib), you would use the following:
import gdata.service
import gdata.urlfetch
# Use urlfetch instead of httplib
gdata.service.http_request_handler = gdata.urlfetch
This refactoring has the added benefit of making it easier to swap out the HTTP transport layer from under the gdata.service module. I'm planning to take advantage of this for a new mock_service module to use in unit tests, and the door is open if people want to help with that or other ideas (I've been meaning to support httplib2, and will one of these days).
Updated (April 10th, 2008) to reference release 1.0.12.1 instead of 1.0.12. The new release fixes an issue with importing ElementTree.