

def __call__(self, request, response, api_version=None, **kwargs):
    'Call the wrapped function over HTTP pulling information as needed'
    api_version = (int(api_version) if (api_version is not None) else api_version)
    if (not self.catch_exceptions):
        exception_types = ()
    else:
        exception_types = self.api.http.exception_handlers(api_version)
        exception_types = (tuple(exception_types.keys()) if exception_types else ())
    try:
        self.set_response_defaults(response, request)
        lacks_requirement = self.check_requirements(request, response)
        if lacks_requirement:
            response.data = self.outputs(lacks_requirement, **self._arguments(self._params_for_outputs, request, response))
            return
        input_parameters = self.gather_parameters(request, response, api_version, **kwargs)
        errors = self.validate(input_parameters)
        if errors:
            return self.render_errors(errors, request, response)
        self.render_content(self.call_function(**input_parameters), request, response, **kwargs)
    except falcon.HTTPNotFound:
        return self.api.http.not_found(request, response, **kwargs)
    except exception_types as exception:
        handler = None
        if (type(exception) in exception_types):
            handler = self.api.http.exception_handlers(api_version)[type(exception)]
        else:
            for (exception_type, exception_handler) in tuple(self.api.http.exception_handlers(api_version).items())[::(- 1)]:
                if isinstance(exception, exception_type):
                    handler = exception_handler
        handler(request=request, response=response, exception=exception, **kwargs)

dataset/ETHPy150Open timothycrosley/hug/hug/interface.py HTTP.__call__/original