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

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

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.

Description From Last Updated

F401 'django.http.HttpResponseForbidden' imported but unused

reviewbotreviewbot

F811 redefinition of unused 'test_dispatch' from line 23

reviewbotreviewbot

F841 local variable 'seen' is assigned to but never used

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

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