What is the simplest way to implement a remote FIFO queue as a Python GAE application and then push/pull name-value pair dictionaries to and from it?
For example, when an http get is made to the GAE application, the GAE app would return the oldest collection of name-value pairs that were posted to the app which have not been previously pulled from the queue. These name-value pairs would then be re-instantiated as a dictionary on the client side. urllib.urlencode provides a simple mechanism to encode dictionaries as parameters, but what is the similarly simple approach to decode parameters into dictionaries when you http "get" them? When there are no items in the queue, the GAE app should return a null or some other more appropriate identifier the client could respond to.
#A local python script
import urllib
targetURL="http://myapp.appspot.com/queue"
#Push to dictionary to GAE queue
params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
f = urllib.urlopen(targetURL, params)
print f.read()
params = urllib.urlencode({'foo': 1, 'bar': 2})
f = urllib.urlopen(targetURL, params)
print f.read()
#Pull oldest set of name-value pairs from the GAE queue and create a local dictionary from them.
#f = urllib.urlopen(targetURL, ……)
#returnedDictionary = ????
What would the simplest way to implement this short GAE application?
#queue.py a url handler in a GAE application.
# For posts, create an object from the posted name-value pairs and insert it into the queue as the newest item in the queue
# For gets, return the name-value pairs for the oldest object in the queue and remove the object from the queue.
# If there are no items in the queue, return null