joshmarshall/tornadorpc — pull request #4 by koelie (2013-03-13 13:27:36+00:00)
Title: default argument order fix

following up on my msg on the google groups, this is a fix for the order default arguments are set in. Currently they are set in reverse order as the following example shows:

server code:

from tornadorpc.json import JSONRPCHandler
from tornadorpc import start_server
class Handler(JSONRPCHandler):
def test(self, a=1, b=2, c=3, d=4):
return {'a': a, 'b': b, 'c': c, 'd': d}
start_server(Handler, port=8888)

client code:

import jsonrpclib
server = jsonrpclib.Server('http://localhost:8888')
print server.test()
print server.test(a='one')
print server.test(d='four')
print server.test(a='one',b='two',c='three',d='four')

This prints (unicode markers removed for readability):
{'a': 4, 'c': 2, 'b': 3, 'd': 1}
{'a': 'one', 'c': 2, 'b': 3, 'd': 1}
{'a': 4, 'c': 2, 'b': 3, 'd': 'four'}
{'a': 'one', 'c': 'three', 'b': 'two', 'd': 'four'}

note that the defaults are set in reverse order. My patch fixes this.