From 0a1090890f8425a69e5b004aceb04fd7527b8e35 Mon Sep 17 00:00:00 2001 From: Henry Chladil Date: Sun, 8 Oct 2017 03:52:44 +1000 Subject: [PATCH] Add additional information in the url_rule docs (#2467) If a user is making use of the errorhandler(405) decorator, and they wish to include an Allow header (as per HTTP spec), they may be confused to find that url_rule is None. This doc change aims to clarify that because the request was never successfully matched, it was never bound to a URL rule and to access the valid methods, they must examine routing_exception. --- flask/wrappers.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flask/wrappers.py b/flask/wrappers.py index 8c559c0e..807059d0 100644 --- a/flask/wrappers.py +++ b/flask/wrappers.py @@ -119,6 +119,10 @@ class Request(RequestBase, JSONMixin): #: The internal URL rule that matched the request. This can be #: useful to inspect which methods are allowed for the URL from #: a before/after handler (``request.url_rule.methods``) etc. + #: Though if the request's method was invalid for the URL rule, + #: the valid list is available in ``routing_exception.valid_methods`` + #: instead (an attribute of the Werkzeug exception :exc:`~werkzeug.exceptions.MethodNotAllowed`) + #: because the request was never internally bound. #: #: .. versionadded:: 0.6 url_rule = None