Browse Source

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.
pull/2484/merge
Henry Chladil 7 years ago committed by Adrian
parent
commit
0a1090890f
  1. 4
      flask/wrappers.py

4
flask/wrappers.py

@ -119,6 +119,10 @@ class Request(RequestBase, JSONMixin):
#: The internal URL rule that matched the request. This can be #: The internal URL rule that matched the request. This can be
#: useful to inspect which methods are allowed for the URL from #: useful to inspect which methods are allowed for the URL from
#: a before/after handler (``request.url_rule.methods``) etc. #: 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 #: .. versionadded:: 0.6
url_rule = None url_rule = None

Loading…
Cancel
Save