diff libervia.tac @ 296:92d76ab67156

server+browser side: fixed bridge errback handling
author Goffi <goffi@goffi.org>
date Tue, 17 Dec 2013 01:35:59 +0100
parents 33e0eb212b14
children 19bcd39c77f6
line wrap: on
line diff
--- 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)