Description
I've seen a lot of issues cropping up related to the use of flask_principal or flask_security with blueprints where, even when skip_static
is set, static files provided by blueprints will block and eventually thow a 500 with an error message along these lines:
sqlalchemy.exc.TimeoutError
sqlalchemy.exc.TimeoutError: QueuePool limit of size 5 overflow 10 reached, connection timed out, timeout 30 (Background on this error at: http://sqlalche.me/e/3o7r)
While letting Flask serving static files is arguably not a good idea in production (though still very much useful in developpement), separating static files per blueprint has been a core feature of Flask for many years, one which I see no reason to ignore in an extension as widespread as this. The current workaround of putting all assets from blueprints in the root static folder goes against the idea of keeping blueprints as independent modules (blueprints can't have their internal static folder point outside of their URL prefix, so while it's easy to have the static directory point to /myapp/myblueprint/static
, it's impossible to set it to /myapp/static/myblueprint
) and isn't possible for extensions that wrap blueprints like flask-admin, since you can't rewrite their url_for
routes.
Flask has some mechanisms that would allow for something like Flask-Principal to identify static folders from blueprints (though I'm not seeing a callback to automatically do that on blueprint registration).