def handle_event(self, event):
        """ When we get an 'event' type from the bridge
        handle it by invoking the handler and if needed
        sending back the result.
        
        """
        result_id, ptr, method, args = event[1]
        obj = None
        result = None
        try:
            obj, handler = bridge.get_handler(ptr, method)
            result = handler(*[v for t, v in args])
        except bridge.BridgeReferenceError as e:
            #: Log the event, don't blow up here
            msg = "Error processing event: {} - {}".format(
                  event, e).encode("utf-8")
            print(msg)
            self.show_error(msg)
        except:
            #: Log the event, blow up in user's face
            msg = "Error processing event: {} - {}".format(
                  event, traceback.format_exc()).encode("utf-8")
            print(msg)
            self.show_error(msg)
            raise
        finally:
            if result_id:
                if hasattr(obj, '__nativeclass__'):
                    sig = getattr(type(obj), method).__returns__
                else:
                    sig = type(result).__name__

                self.send_event(
                    bridge.Command.RESULT,  #: method
                    result_id,
                    bridge.msgpack_encoder(sig, result)  #: args
                )
def handle_event ( self , event ) : result_id , ptr , method , args = event [ 1 ] obj = None result = None try : obj , handler = bridge . get_handler ( ptr , method ) result = handler ( * [ v for t , v in args ] ) except bridge . BridgeReferenceError as e : msg = "Error processing event: {} - {}" . format ( event , e ) . encode ( "utf-8" ) print ( msg ) self . show_error ( msg ) except : msg = "Error processing event: {} - {}" . format ( event , traceback . format_exc ( ) ) . encode ( "utf-8" ) print ( msg ) self . show_error ( msg ) raise finally : if result_id : if hasattr ( obj , '__nativeclass__' ) : sig = getattr ( type ( obj ) , method ) . __returns__ else : sig = type ( result ) . __name__ self . send_event ( bridge . Command . RESULT , result_id , bridge . msgpack_encoder ( sig , result ) )
When we get an 'event' type from the bridge
        handle it by invoking the handler and if needed
        sending back the result.