In the last post I discussed and provided code for a Basic Python Web Service Framework for the Google App Engine. This post continues on that work and provides an example of a simple service built in that framework which interacts with the Google App Engine’s data store.
The service is a caching service. It allows users to store a string value referenced by key; a hash table using the Google App Engine’s data store. The operations allowed on this service are get a value by a key, set a key value pair, and delete a key value pair. Two additional operations are get the key value object as Xml, and get the key value object as JSON. Together all these operations provide an example of each of the CRUD operations on the data store. Further, each one is wrapped in a transaction, so there are examples on how to code for transactions as well. The one thing that is missing is an operation that performs a query using GQL.
Link to the source for the CacheService
Link to the live web service on the Google App Engine
I have built a simple JavaScript application to call the service. This is why the operations to get the key value object as Xml and as JSON are included in the service. It was a fun experiment to try and call the web service from JavaScript using Ajax. I think it provides a nice simple interface for users to experiment with the service.
CRON Job
I have implemented a Google App Engine Cron job to delete entries after a defined period of time in order to add expiration to the service. All it does is perform a GQL query looking for entries that are older than week, via the update_date property, and deletes them. You can see the logic for it within the expire method on the CacheService. Should note that method is not exposed as a service call and for the cron job it is getting called directly.
Sunday, May 10, 2009
Python Web Service and the Google App Engine Data Store
Posted by
K Jacobson
at
5:22 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment