First, please don't shoot me if this has already been asked - I have looked around but to no avail.
I have a python file (named rpc.py) containing many functions serving AJAX requests. For example:
def test(self, vars):
return vars['id']
def test2(self, vars):
return vars['id']+1
And it is called with a URL like:
rpc.py?fnc=test2&id=4
I want to call the function that matches the 'fnc' query parameter and pass the whole query string into 'vars'.
So something like the following "pseudocode" is what I am after:
vars = cgi.FieldStorage()
print "Content-Type: text/html\n\n"
print eval('vars["fnc"].value(vars)')
Any ideas?