Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tweaked for supporting jsonrpclib v.0.11 and added a few reporting tw…

…eaks.

git-svn-id: http://tornadorpc.googlecode.com/svn/trunk@6 6a0cc88c-bc38-11de-9a73-11f8458f6c97
  • Loading branch information...
commit ab8a67e2317b8ed5a752e7b79977b58777acb6b2 1 parent de5ad47
catchjosh authored
Showing with 19 additions and 5 deletions.
  1. +17 −4 tornadorpc/base.py
  2. +2 −1  tornadorpc/json.py
View
21 tornadorpc/base.py
@@ -67,11 +67,24 @@ def run(self, handler, request_body):
to the client.
"""
self.handler = handler
- requests = self.parse_request(request_body)
+ try:
+ requests = self.parse_request(request_body)
+ except:
+ self.traceback()
+ return self.faults.parse_error()
if type(requests) is not types.TupleType:
# SHOULD be the result of a fault call,
# according tothe parse_request spec below.
- return requests
+ if type(requests) in types.StringTypes:
+ # Should be the response text of a fault
+ return requests
+ elif 'response' in dir(requests):
+ # Fault types should have a 'response' method
+ return requests.response()
+ else:
+ # No idea, hopefully the handler knows what it
+ # is doing.
+ return requests
responses = []
for request in requests:
response = self.dispatch(request[0], request[1])
@@ -136,7 +149,7 @@ def dispatch(self, method_name, params):
# Bad argument formatting?
return self.faults.invalid_params()
- def traceback(self, method_name, params):
+ def traceback(self, method_name='REQUEST', params=[]):
import traceback
err_lines = traceback.format_exc().splitlines()
err_title = "ERROR IN %s" % method_name
@@ -155,7 +168,7 @@ def traceback(self, method_name, params):
# Log here
return
- def parse_requesr(self, request_body):
+ def parse_request(self, request_body):
"""
Extend this on the implementing protocol. If it
should error out, return the output of the
View
3  tornadorpc/json.py
@@ -52,6 +52,7 @@ def parse_request(self, request_body):
request = jsonrpclib.loads(request_body)
except:
# Bad request formatting. Bad.
+ self.traceback()
return self.faults.parse_error()
self._requests = request
self._batch = False
@@ -80,7 +81,7 @@ def parse_responses(self, responses):
# response entry
continue
rpcid = request['id']
- version = jsonrpclib._version
+ version = jsonrpclib.config.version
if 'jsonrpc' not in request.keys():
version = 1.0
try:
Please sign in to comment.
Something went wrong with that request. Please try again.