• 
      

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

    Review Request #9127 — Created Aug. 7, 2017 and submitted — Latest diff uploaded

    Information

    Djblets
    release-0.10.x
    03e4c4d...

    Reviewers

    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.