Add a class-based view mixin for checking if HTTP methods are allowed.

Review Request #9127 - Created Aug. 7, 2017 and submitted

Christian Hammond
Djblets
release-0.10.x
03e4c4d...
djblets

Django's base View class for class-based views performs a check before
dispatching to make sure that the HTTP method in question is allowed,
returning a HTTP 405 if not. While useful, this is too late for more
complex views that are performing other (potentially method-specific)
logic before reaching View.dispatch.

This change introduces CheckRequestMethodViewMixin, which can be
placed at the beginning of the inheritance list to handle the checking
early. It will perform the same checks that View.dispatch performs,
but can be done before any other mixin dispatch methods are invoked.

Unit tests pass.

Made use of this in another change and verified the dispatch handlers
never got called for unsupported HTTP methods.

  • 0
  • 0
  • 3
  • 0
  • 3
Description From Last Updated
Christian Hammond
David Trowbridge
Christian Hammond
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-0.10.x (a25e8de)
Loading...