Friday, October 31, 2008

This close to a datastore --> json server on google apps engine

Phew ... a good afternoon's hacking.

I am *this close* to completing a very basic prototype of a json server for google apps engine. The idea is that you visit a URL which contains the query you want to evaluate (hence my previous post) and get back a JSON encoding of the data. Obviously, that's for requests only.

However, what it *means* is that you can then write an AJAX client which can interface directly to a GAE data store. And *that* is a good thing.

Sure, it's about as functional as a car with no steering wheel, but in principle it works. I have achieved the following goals:
* Store some data in the data store
* Retrieve it with a GQL query
* Write a web server which decodes a query from the URL in hex
* Use that to retrieve said data from the query store
* Render the data to a web page in HTML
* Render the a json string to the web page (or json-looking, anyway)

The following goals remain:
* Write a version which emits the json string with appropriate mime type
* Write a javascript client which retrieves the data and renders it in a web page
* Put up some vaguely comprehensible web pages explaining the thing and demonstrating its use
* Make the store/retrieval more general by:
-- Not relying on a specific database structure
-- Going beyond string-only data
-- Do something about INSERT queries

I'm having some fun with this. Anyone who is interested, let me know and I can keep you posted of progress. I think it should be really useful.