Browse Source

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.
pull/1489/head
Jimmy McCarthy 9 years ago
parent
commit
5505827a4b
  1. 14
      flask/app.py

14
flask/app.py

@ -944,7 +944,8 @@ class Flask(_PackageBoundObject):
return iter(self._blueprint_order) return iter(self._blueprint_order)
@setupmethod @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` """Connects a URL rule. Works exactly like the :meth:`route`
decorator. If a view_func is provided it will be registered with the decorator. If a view_func is provided it will be registered with the
endpoint. endpoint.
@ -984,6 +985,10 @@ class Flask(_PackageBoundObject):
endpoint endpoint
:param view_func: the function to call when serving a request to the :param view_func: the function to call when serving a request to the
provided endpoint 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 :param options: the options to be forwarded to the underlying
:class:`~werkzeug.routing.Rule` object. A change :class:`~werkzeug.routing.Rule` object. A change
to Werkzeug is handling of method options. methods 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 # starting with Flask 0.8 the view_func object can disable and
# force-enable the automatic options handling. # force-enable the automatic options handling.
provide_automatic_options = options.pop( if provide_automatic_options is None:
'provide_automatic_options', getattr(view_func, provide_automatic_options = getattr(view_func,
'provide_automatic_options', None)) 'provide_automatic_options', None)
if provide_automatic_options is None: if provide_automatic_options is None:
if 'OPTIONS' not in methods: if 'OPTIONS' not in methods:

Loading…
Cancel
Save