Reputation: 8055
Here's my situation:
Let's say I have 2 Blueprints before_request method:
mod = Blueprint('posts', __name__, url_prefix='/posts')
@mod.before_request
def before_request():
#some code that uses SQLAlchemy here
pass
Now I don't want to duplicate the logic in this method in the second blueprint.
How can I do this?
PS: I'm new to Python so I might be missing something obvious. Thanks.
Upvotes: 9
Views: 4050
Reputation: 11543
use blueprint.before_app_request
which applies to views app-wide, not only views in the same blueprint
Upvotes: 10