#21564: Generic base view http_method_not_allowed method references self.request and should use locally scoped request -------------------------------------+------------------------------------- Reporter: adepue | Owner: nobody Type: Bug | Status: new Component: Generic views | Version: 1.6 Severity: Normal | Resolution: Keywords: | Triage Stage: Ready for Has patch: 1 | checkin Needs tests: 0 | Needs documentation: 0 Easy pickings: 0 | Patch needs improvement: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by timo):
* needs_tests: 1 => 0 * stage: Accepted => Ready for checkin Old description: > The current method in django/views/generic/base.py is: > def http_method_not_allowed(self, request, *args, **kwargs): > logger.warning('Method Not Allowed (%s): %s', request.method, > request.path, > extra={ > 'status_code': 405, > 'request': self.request > } > ) > return http.HttpResponseNotAllowed(self._allowed_methods()) > > The 'extra' dictionary should reference the locally scoped 'request' > object instead of the class scoped member. > > There is a PR open with this fix: > https://github.com/django/django/pull/2035 > > The side effect is that any unit test written that uses the view and > manually calls the dispatch method to validate non-allowed-methods will > crash with attribute not found error for request New description: The current method in django/views/generic/base.py is: {{{ def http_method_not_allowed(self, request, *args, **kwargs): logger.warning('Method Not Allowed (%s): %s', request.method, request.path, extra={ 'status_code': 405, 'request': self.request } ) return http.HttpResponseNotAllowed(self._allowed_methods()) }}} The 'extra' dictionary should reference the locally scoped 'request' object instead of the class scoped member. There is a PR open with this fix: https://github.com/django/django/pull/2035 The side effect is that any unit test written that uses the view and manually calls the dispatch method to validate non-allowed-methods will crash with attribute not found error for request -- -- Ticket URL: <https://code.djangoproject.com/ticket/21564#comment:4> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.fd480ead3e71781ebc1585554a17ceb3%40djangoproject.com. For more options, visit https://groups.google.com/groups/opt_out.