As a follow up to another question I asked, I have a basic question about the easiest way to get a webapp2 python server to provide json data that is too large (about 100 kb) to send as a Channel API message to a client .
The webapp2 server generates several data files over several minutes based on a client request, and I am thinking that I would like the Channel API to send messages with the url to the client when the data is ready, and the client (a GWT app) could perform a http GET request to get the data. Each data file is unique to the client and therefore the server will have to have a request handler that will give the appropriate data file for the client.
Can you write a request handler that can provide the correct data file directly from another request handler for that particular client when the request is called? Or Do I need to store the data using Cloud SQL or the Data Store first until the client asks for it? Here is some incomplete sample code of what I would like to do:
class MainPage(webapp2.RequestHandler):
def get(self):
## This opens the GWT app
class Service_handler(webapp2.RequestHandler):
def get(self, parameters):
## This is called by the GWT app and generates the data to be
## sent to the client.
## A channel API message is sent to the client with the url
## for each data file generated.
class kml_handler(webapp2.RequestHandler):
def get(self, client_id):
## I would like to return the correct data here when it is
## called by the client. Do I need to store the data in
## Cloud SQL or the Data Store and then retrieve it
## or can this handler take the results directly from the
## Service_handler as soon as it is generated?
app = webapp2.WSGIApplication([
webapp2.Route(r'/', handler=MainPage),
webapp2.Route(r'/Service/', handler=Service_handler),
webapp2.Route(r'/_ah/channel/<connected>/', handler = connection_handler),
webapp2.Route(r'/kml/<client_id>', handler = kml_handler)
],
debug=True)
You can write files to the blobstore and serve those files from the blobstore.
Here is an example: https://developers.google.com/appengine/docs/python/blobstore/overview#Complete_Sample_App