def local_dispatch(self, env):
        if env.type not in self.classes:
            self.host_specific_send(env.node_id,
            MessageResponse(in_response_to=env.req_id,
                result=MessageResponse.REFUSED,
                error_message="cannot handle type"),
            MESSAGE_RES, None)
        elif me.id not in self.routes[env.type]:
            # use routes, balance, etc
            self.host_specific_send(env.node_id,
            MessageResponse(in_response_to=env.req_id,
                delivered=MessageResponse.REFUSED,
                error_message="do not own route"),
            MESSAGE_RES, None)
        else:
            inst = self.classes[env.type](env.body)
            r = self.local_handlers[env.type]
            sender = ConvoySender(env)
            back = MessageResponse(in_response_to=env.req_id,
                    delivered=MessageResponse.ACCEPTED)

            self.host_specific_send(env.node_id, back,
                    MESSAGE_RES, None)
            try:
                r(sender, inst)
            except Exception, e:
                s = str(e)
                back.result = MessageResponse.EXCEPTION
                back.error_message = s
                raise
            else:
                if sender.responses:
                    back.result = MessageResponse.RESULT
                    back.responses.extend(sender.responses)
                else:
                    back.result = MessageResponse.NULL

            if env.wants_result:
                back.delivered = MessageResponse.FINISHED
                self.host_specific_send(env.node_id, back,
                        MESSAGE_RES, None)
dataset/ETHPy150Open dieseldev/diesel/diesel/convoy/__init__.py/Convoy.local_dispatch/original