What sort of an API would we need to properly support app composition for such purposes, since that would solve all of these use cases (404 / 405 error handlers at the "Blueprint" level, only able to see its own templates, etc.)?
The minimum API is Flask#mount_app(app_or_blueprint) - but that still leaves a few questions:
url_for?url_for?static and templates (although #1361 suggests that such uses would want the static and template folders to be distinct).What do _you_ need from Blueprints? What else would you _expect_ Flask#mout_app to do?
Possibly also related to #593 (nestable blueprints).
this is a _hard__ problem ^^
The parent should be able to route to sub-apps using url_for. (The feature almost seems _built for_ sub-apps anyway)
The sub-apps do not need to route to a parent app or sibling. The point of a sub-app (in my use case) is to create fully modular apps that I can re-use in other applications.
I would be ec-static if templates and static files would try all expected template or static locations, starting from most specific (sub-app's directory), and ending with least specific (parent app's). Though, I could see how a developer would want the parent templates to override the sub templates, or vice versa. Could this be configurable?
Also, would Flask#mount_app be able to mount other Werkzeug apps?
@spight - I'm not sure how one would mount a Werkzeug app differently than any other raw WSGI application. That said, I don't see why we couldn't also allow mounting arbitrary WSGI apps, but they wouldn't be routable to (unless you provided a url_map for it).
The url_for function is really just a wrapper around the current app's url_adapter.build method. If a parent app has a reference to a child app, its very easy to write one's own url_for_subapp function.
In my case the child app would need to be able to redirect the main app. For instance when redirecting to home. What I use blueprints for is to having the app structure split up into different parts. These different parts do tend to interact with eachother sometimes, although not often.
It is very useful to have a common url prefix and a different template folder and static folder.
Indeed it is annoying to workaround the fact you cannot mount sub-blueprints.
I would really love Blueprint level error handlers, in particular. if a url routes into the Blueprint's suffix then the Blueprint handles the errors if the user implements them otherwise error handling falls-back to the parent of the Blueprint.
Before I read up on why I couldn't do the above I always thought of Blueprints as "flask sub-app" esp. because of the fact that Blueprints have the same blueprint.route() api as a flask app.
Most helpful comment
Indeed it is annoying to workaround the fact you cannot mount sub-blueprints.