def stringReceived(self, line): parser, unmarshaller = jsonrpclib.getparser() deferred = defer.maybeDeferred(parser.feed, line) deferred.addCallback(lambda x: self._cbDispatch(parser, unmarshaller)) deferred.addErrback(self._ebRender) deferred.addCallback(self._cbRender) return deferred
def test_getparser(self): """A parser and marshaller are returned.""" parser, unmarshaller = jsonrpclib.getparser() self.assertTrue(isinstance(parser, jsonrpclib.SimpleParser)) self.assertTrue(isinstance(unmarshaller, jsonrpclib.SimpleUnmarshaller)) self.assertIs(parser, unmarshaller.parser)
def stringReceived(self, line): parser, unmarshaller = jsonrpclib.getparser() deferred = defer.maybeDeferred(parser.feed, line) deferred.addCallback(lambda x: self._cbDispatch( parser, unmarshaller)) deferred.addErrback(self._ebRender) deferred.addCallback(self._cbRender) return deferred
def http_POST(self, request): parser, unmarshaller = jsonrpclib.getparser() deferred = stream.readStream(request.stream, parser.feed) deferred.addCallback(lambda x: self._cbDispatch( request, parser, unmarshaller)) deferred.addErrback(self._ebRender) deferred.addCallback(self._cbRender, request) return deferred
def stringReceived(self, line): parser, unmarshaller = jsonrpclib.getparser() if isinstance(line, six.binary_type): line = line.decode('utf-8') deferred = defer.maybeDeferred(parser.feed, line) req, req_id = self._cbDispatch(parser, unmarshaller) deferred.addCallback(lambda x: req) deferred.addErrback(self._ebRender, req_id=req_id) deferred.addCallback(self._cbRender, req_id=req_id) return deferred