Skip to content
Myr

provide_automatic_options as explicit arg

Before adoption: this commit came in with the history the project adopted, so no landing records it.

In add_url_rule, break provide_automatic_options out to an explicit kwarg, and add notes to the docstring.

authored by Jimmy McCarthy · committed by Jimmy McCarthy · parent 04a3eee · Browse files · 1 file+9 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−5 removed

  • other:+9 added−5 removed

1 file+9 added−5 removed

modified:flask/app.py+9 added-5 removed
942 unmodified lines
943 """944 return iter(self._blueprint_order)945946 @setupmethod947 def add_url_rule(self, rule, endpoint=None, view_func=None, **options):947 def add_url_rule(self, rule, endpoint=None, view_func=None,948 provide_automatic_options=None, **options):949 """Connects a URL rule. Works exactly like the :meth:`route`950 decorator. If a view_func is provided it will be registered with the951 endpoint.952
31 unmodified lines
984 itself assumes the name of the view function as985 endpoint986 :param view_func: the function to call when serving a request to the987 provided endpoint988 :param provide_automatic_options: controls whether ``OPTIONS`` should989 be provided automatically. If this990 is not set, will check attributes on991 the view or list of methods.992 :param options: the options to be forwarded to the underlying993 :class:`~werkzeug.routing.Rule` object. A change994 to Werkzeug is handling of method options. methods995 is a list of methods this rule should be limited
21 unmodified lines
1017 required_methods = set(getattr(view_func, 'required_methods', ()))10181019 # starting with Flask 0.8 the view_func object can disable and1020 # force-enable the automatic options handling.1016 provide_automatic_options = options.pop(1017 'provide_automatic_options', getattr(view_func,1018 'provide_automatic_options', None))1021 if provide_automatic_options is None:1022 provide_automatic_options = getattr(view_func,1023 'provide_automatic_options', None)102410201025 if provide_automatic_options is None:1026 if 'OPTIONS' not in methods:1027 provide_automatic_options = True1028 required_methods.add('OPTIONS')
953 unmodified lines