Exemplo n.º 1
0
def test_marshalling():
    actual = (Outer()).setup(101);
    encoded = (quark.toJSON(actual, quark.reflect.Class.get(_getClass(actual)))).toString();
    _println(encoded);
    expected = Outer();
    quark.fromJSON(quark.reflect.Class.get(_getClass(expected)), expected, _JSONObject.parse(encoded));
    _println(_toString((expected).outer_int));
    _println((expected).outer_string);
    _println(repr((expected).outer_float));
    _println(repr((((expected).outer_inner_list)[1]).inner_float));
Exemplo n.º 2
0
    def onHTTPResponse(self, rq, response):
        info = None;
        ((self).timeout).cancel();
        if (((response).getCode()) != (200)):
            info = ((((self).rpc).toString()) + (u" failed: Server returned error ")) + (_toString((response).getCode()))
            ((self).retval).finish(info);
            ((self).rpc).fail(info);
            return

        body = (response).getBody();
        obj = _JSONObject.parse(body);
        classname = ((obj).getObjectItem(u"$class")).getString();
        if ((classname) == (None)):
            info = (((self).rpc).toString()) + (u" failed: Server returned unrecognizable content")
            ((self).retval).finish(info);
            ((self).rpc).fail(info);
            return
        else:
            quark.fromJSON(((self).rpc).returned, (self).retval, obj);
            ((self).retval).finish(None);
            ((self).rpc).succeed(u"Success in the future...");