class RPCHandler(webapp2.RequestHandler):
def __init__(self):
webapp2.RequestHandler.__init__(self)
self.methods = ConceptsRPCMethods()
def get(self):
func = None
action = self.request.get('action')
if action:
if action[0] == '_':
self.error(403) # access denied
return
else:
func = getattr(self.methods, action, None)
if not func:
self.error(404) # file not found
return
else :
args = ()
while True:
key = 'arg%d' % len(args)
val = self.request.get(key)
if val:
args = (json.loads(val),)
else:
break
result = func(*args)
self.response.out.write(json.dumps(result))
I will explain my program more. The problem is when the user clicks on a tree structure, this sends an action (using an XMLHTTPRequest object) to my code using callback function on whether to expand the tree one more level or display information on the page.
So, the above code should receive the required action from the callback function which sends 3 pieces of information (Get method, function, async) so that the ConceptRPCMethods() could handle the requested order.
YAHOO.util.Connect.asyncRequest('GET', '/rpc?' + query, callback);
I guess I need to make the python code receive 3 parameters but I don't know where to add it or how???
Thanks a lot