Skip to content
Myr

Merge pull request #1338 from cvrebert/middleware-docs

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

Improve docs of signatures of before/after/teardown callback funcs

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parents 4dc3c16, fe6bcff · Browse files · 1 file+17 added−3 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+17 added−3 removed

  • other:+17 added−3 removed

1 file+17 added−3 removed

modified:flask/app.py+17 added-3 removed
1241 unmodified lines
1242 self.jinja_env.globals[name or f.__name__] = f12431244 @setupmethod1245 def before_request(self, f):1246 """Registers a function to run before each request."""1246 """Registers a function to run before each request.12471248 The function will be called without any arguments.1249 If the function returns a non-None value, it's handled as1250 if it was the return value from the view and further1251 request handling is stopped.1252 """1253 self.before_request_funcs.setdefault(None, []).append(f)1254 return f12551256 @setupmethod1257 def before_first_request(self, f):1258 """Registers a function to be run before the first request to this1259 instance of the application.12601261 The function will be called without any arguments and its return1262 value is ignored.12631264 .. versionadded:: 0.81265 """1266 self.before_first_request_funcs.append(f)1267 return f
38 unmodified lines
13061307 When a teardown function was called because of a exception it will1308 be passed an error object.13091310 The return values of teardown functions are ignored.13111312 .. admonition:: Debug Note13131314 In debug mode Flask will not tear down a request on an exception1315 immediately. Instead it will keep it alive so that the interactive
26 unmodified lines
13421343 When a teardown function was called because of an exception it will1344 be passed an error object.13451346 The return values of teardown functions are ignored.13471348 .. versionadded:: 0.91349 """1350 self.teardown_appcontext_funcs.append(f)1351 return f
370 unmodified lines
1722 raise error17231724 def preprocess_request(self):1725 """Called before the actual request dispatching and will1713 call every as :meth:`before_request` decorated function.1714 If any of these function returns a value it's handled as1726 call each :meth:`before_request` decorated function, passing no1727 arguments.1728 If any of these functions returns a value, it's handled as1729 if it was the return value from the view and further1730 request handling is stopped.17311732 This also triggers the :meth:`url_value_processor` functions before
191 unmodified lines