MCPcopy
hub / github.com/pallets/flask / record_once

Method record_once

src/flask/sansio/blueprints.py:233–244  ·  view source on GitHub ↗

Works like :meth:`record` but wraps the function in another function that will ensure the function is only called once. If the blueprint is registered a second time on the application, the function passed is not called.

(self, func: DeferredSetupFunction)

Source from the content-addressed store, hash-verified

231
232 @setupmethod
233 def record_once(self, func: DeferredSetupFunction) -> None:
234 """Works like :meth:`record` but wraps the function in another
235 function that will ensure the function is only called once. If the
236 blueprint is registered a second time on the application, the
237 function passed is not called.
238 """
239
240 def wrapper(state: BlueprintSetupState) -> None:
241 if state.first_registration:
242 func(state)
243
244 self.record(update_wrapper(wrapper, func))
245
246 def make_setup_state(
247 self, app: App, options: dict[str, t.Any], first_registration: bool = False

Callers 10

add_app_template_testMethod · 0.95
before_app_requestMethod · 0.95
after_app_requestMethod · 0.95
teardown_app_requestMethod · 0.95
app_context_processorMethod · 0.95
decoratorMethod · 0.95
app_url_defaultsMethod · 0.95

Calls 1

recordMethod · 0.95

Tested by

no test coverage detected