<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def dispatch(self, request):
 """Takes a request and dispatches its data to a jsonrpc method. :param request: a werkzeug request with json data :type request: werkzeug.wrappers.Request :return: json output of the corresponding method :rtype: str .. versionadded:: 0.1.0 """

        def _wrapped():
            messages = self._get_request_messages(request)
            results = [self._dispatch_and_handle_errors(message) for message in messages]
            non_notification_results = [x for x in results if x is not None]
            if len(non_notification_results) == 0:
                return None
            elif len(messages) == 1:
                return non_notification_results[0]
            else:
                return non_notification_results

        result, _ = self._handle_exceptions(_wrapped)
        if result is not None:
            return self._encode_complete_result(result)