MCPcopy Index your code
hub / github.com/encode/django-rest-framework / dispatch

Method dispatch

rest_framework/views.py:491–518  ·  view source on GitHub ↗

`.dispatch()` is pretty much the same as Django's regular dispatch, but with extra hooks for startup, finalize, and exception handling.

(self, request, *args, **kwargs)

Source from the content-addressed store, hash-verified

489 # accidental removal of this exemption in cases where `dispatch` needs to
490 # be overridden.
491 def dispatch(self, request, *args, **kwargs):
492 """
493 `.dispatch()` is pretty much the same as Django's regular dispatch,
494 but with extra hooks for startup, finalize, and exception handling.
495 """
496 self.args = args
497 self.kwargs = kwargs
498 request = self.initialize_request(request, *args, **kwargs)
499 self.request = request
500 self.headers = self.default_response_headers # deprecate?
501
502 try:
503 self.initial(request, *args, **kwargs)
504
505 # Get the appropriate handler method
506 if request.method.lower() in self.http_method_names:
507 handler = getattr(self, request.method.lower(),
508 self.http_method_not_allowed)
509 else:
510 handler = self.http_method_not_allowed
511
512 response = handler(request, *args, **kwargs)
513
514 except Exception as exc:
515 response = self.handle_exception(exc)
516
517 self.response = self.finalize_response(request, response, *args, **kwargs)
518 return self.response
519
520 def options(self, request, *args, **kwargs):
521 """

Callers 1

viewMethod · 0.45

Calls 5

initialize_requestMethod · 0.95
initialMethod · 0.95
handle_exceptionMethod · 0.95
finalize_responseMethod · 0.95
handlerFunction · 0.85

Tested by

no test coverage detected