flask
flask copied to clipboard
Blueprint before_app_first_request vs record_once usage discrepancy
I'm working on upgrading from Flask 2.2.x to 2.3.x and I use the .before_app_first_request decorator in one of my blueprints. Following the deprecation warning, I replaced .before_app_first_request with .record_once and it was not a drop-in replacement. Not sure if this an issue in code implementation or unclear documentation.
from flask import Blueprint, Flask, current_app
blueprint = Blueprint('my_blueprint', __name__)
@blueprint.before_app_first_request
def my_test_function():
current_app.logger.info('testing')
app = Flask(__name__)
app.register_blueprint(blueprint)
app.run()
replace .before_app_first_request with .record_once and it will no longer run
Environment:
- Python version: 3.10.11
- Flask version: 2.2.2