provide_automatic_options as explicit arg
In add_url_rule, break provide_automatic_options out to an explicit kwarg, and add notes to the docstring.
This commit is contained in:
parent
04a3eeee3b
commit
5505827a4b
1 changed files with 9 additions and 5 deletions
14
flask/app.py
14
flask/app.py
|
|
@ -944,7 +944,8 @@ class Flask(_PackageBoundObject):
|
|||
return iter(self._blueprint_order)
|
||||
|
||||
@setupmethod
|
||||
def add_url_rule(self, rule, endpoint=None, view_func=None, **options):
|
||||
def add_url_rule(self, rule, endpoint=None, view_func=None,
|
||||
provide_automatic_options=None, **options):
|
||||
"""Connects a URL rule. Works exactly like the :meth:`route`
|
||||
decorator. If a view_func is provided it will be registered with the
|
||||
endpoint.
|
||||
|
|
@ -984,6 +985,10 @@ class Flask(_PackageBoundObject):
|
|||
endpoint
|
||||
:param view_func: the function to call when serving a request to the
|
||||
provided endpoint
|
||||
:param provide_automatic_options: controls whether ``OPTIONS`` should
|
||||
be provided automatically. If this
|
||||
is not set, will check attributes on
|
||||
the view or list of methods.
|
||||
:param options: the options to be forwarded to the underlying
|
||||
:class:`~werkzeug.routing.Rule` object. A change
|
||||
to Werkzeug is handling of method options. methods
|
||||
|
|
@ -1013,10 +1018,9 @@ class Flask(_PackageBoundObject):
|
|||
|
||||
# starting with Flask 0.8 the view_func object can disable and
|
||||
# force-enable the automatic options handling.
|
||||
provide_automatic_options = options.pop(
|
||||
'provide_automatic_options', getattr(view_func,
|
||||
'provide_automatic_options', None))
|
||||
|
||||
if provide_automatic_options is None:
|
||||
provide_automatic_options = getattr(view_func,
|
||||
'provide_automatic_options', None)
|
||||
|
||||
if provide_automatic_options is None:
|
||||
if 'OPTIONS' not in methods:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue