When using Pyjamas, in my default.py, I use functions of the form:
@service.jsonrpc
def get_function(params):
# do some action based on params
return ['planet', 3]
but when calling from Spine (which uses json2.js) I need to add additional
parameter and return value handling code.
@service.jsonrpc
def get_agent_assessments():
import gluon.contrib.simplejson
params = gluon.contrib.simplejson.loads(request.body.read())
# do some action based on params
ret = ['planet', 3]
return gluon.contrib.simplejson.dumps(ret)
I like the clean code of version #1. Can I achieve a cleaner version of #2?