def test_types(self): assert type(u'') == String assert type('') == String assert not type('') == Object assert not type([]) == Object assert type([]) == Array assert type('') == Any assert Any.kind('') == String assert Any.decode('str') == String assert Any.kind({}) == Object assert Any.kind(None) == Nil
def __call__(self, *args, **kwargs): params = kwargs if len(kwargs) else args if Any.kind(params) == Object and self.__version != '2.0': raise ValueError('Unsupported arg type for JSON-RPC 1.0 ' \ '(the default version for this client, ' \ 'pass version="2.0" to use keyword arguments)') response = self.client.post(self.__service_url, dumps({ "jsonrpc": self.__version, "method": self.__service_name, 'params': params, 'id': str(uuid.uuid1()), }), content_type="application/json-rpc") y = loads(response.content) if y.get("error", None): try: from django.conf import settings if settings.DEBUG: print '%s error %r' % (self.__service_name, y) except: pass return y