def __call__(self, environ, start_response):
    request = Request(environ)
    if request.method != "POST":
      raise exceptions.MethodNotAllowed

    if not request.content_type.startswith('application/json'):
      raise exceptions.BadRequest
    try:
      data = json.loads(request.data)
    except __HOLE__, e:
      resdata = {'jsonrpc':'2.0',
                 'id':None,
                 'error':{'code':PARSE_ERROR,
                          'message':errors[PARSE_ERROR]}}

    else:
      if isinstance(data, dict):
        resdata = self.process(data)
      elif isinstance(data, list):
        if len([x for x in data if not isinstance(x, dict)]):
          resdata = {'jsonrpc':'2.0',
                     'id':None,
                     'error':{'code':INVALID_REQUEST,
                              'message':errors[INVALID_REQUEST]}}
        else:
          resdata = [d for d in (self.process(d) for d in data) 
                     if d is not None]
            

    response = Response(content_type="application/json")

    if resdata:
      response.headers["Cache-Control"] = "no-cache"
      response.headers["Pragma"] = "no-cache"
      response.headers["Expires"] = "-1"
      response.data = json.dumps(resdata)
    return response(environ, start_response)
dataset/ETHPy150Open IanLewis/kay/kay/ext/jsonrpc2/__init__.py/JsonRpcApplication.__call__