# HG changeset patch # User Goffi # Date 1387240559 -3600 # Node ID 92d76ab671568ee2516fd39340dde361b4e53dea # Parent 33e0eb212b14ef47e01a02083adfe554e8366383 server+browser side: fixed bridge errback handling diff -r 33e0eb212b14 -r 92d76ab67156 libervia.py --- a/libervia.py Tue Dec 17 01:34:56 2013 +0100 +++ b/libervia.py Tue Dec 17 01:35:59 2013 +0100 @@ -61,7 +61,8 @@ if len(cb) != 2: print ("ERROR: tuple syntax for bridge.call is (callback, errback), aborting") return - self.cb[_id] = cb[0] + if cb[0] is not None: + self.cb[_id] = cb[0] self.eb[_id] = cb[1] else: self.cb[_id] = cb diff -r 33e0eb212b14 -r 92d76ab67156 libervia.tac --- a/libervia.tac Tue Dec 17 01:34:56 2013 +0100 +++ b/libervia.tac Tue Dec 17 01:35:59 2013 +0100 @@ -51,6 +51,9 @@ AVATARS_DIR = "avatars/" CARDS_DIR = "games/cards/tarot" +ERRNUM_BRIDGE_ERRBACK = 0 # FIXME +ERRNUM_LIBERVIA = 0 # FIXME + # Security limit for Libervia (get/set params) SECURITY_LIMIT = 0 @@ -146,7 +149,7 @@ d.callback(args[0]) def _errback(result): - d.errback(Failure(unicode(result))) + d.errback(Failure(jsonrpclib.Fault(ERRNUM_BRIDGE_ERRBACK, unicode(result)))) kwargs["callback"] = _callback kwargs["errback"] = _errback @@ -166,7 +169,7 @@ if not profile: #user is not identified, we return a jsonrpc fault parsed = jsonrpclib.loads(request.content.read()) - fault = jsonrpclib.Fault(0, "Not allowed") #FIXME: define some standard error codes for libervia + fault = jsonrpclib.Fault(ERRNUM_LIBERVIA, "Not allowed") #FIXME: define some standard error codes for libervia return jsonrpc.JSONRPC._cbRender(self, fault, request, parsed.get('id'), parsed.get('jsonrpc')) return jsonrpc.JSONRPC.render(self, request) @@ -547,7 +550,7 @@ profile = ISATSession(_session).profile if not profile: #user is not identified, we return a jsonrpc fault - fault = jsonrpclib.Fault(0, "Not allowed") #FIXME: define some standard error codes for libervia + fault = jsonrpclib.Fault(ERRNUM_LIBERVIA, "Not allowed") #FIXME: define some standard error codes for libervia return jsonrpc.JSONRPC._cbRender(self, fault, request, parsed.get('id'), parsed.get('jsonrpc')) self.request = request return jsonrpc.JSONRPC.render(self, request) @@ -713,7 +716,7 @@ _session = self.request.getSession() profile = ISATSession(_session).profile if self.profiles_waiting.has_key(profile): - raise jsonrpclib.Fault('1','Already waiting') #FIXME: define some standard error codes for libervia + raise jsonrpclib.Fault(1,'Already waiting') #FIXME: define some standard error codes for libervia self.profiles_waiting[profile] = self.request self.sat_host.bridge.connect(profile) return server.NOT_DONE_YET @@ -818,7 +821,7 @@ profile = ISATSession(_session).profile if not profile: #user is not identified, we return a jsonrpc fault - fault = jsonrpclib.Fault(0, "Not allowed") #FIXME: define some standard error codes for libervia + fault = jsonrpclib.Fault(ERRNUM_LIBERVIA, "Not allowed") #FIXME: define some standard error codes for libervia return jsonrpc.JSONRPC._cbRender(self, fault, request, parsed.get('id'), parsed.get('jsonrpc')) self.request = request return jsonrpc.JSONRPC.render(self, request)