-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support zero-ceremony sub-app mounting (including Blueprints) #1548
Comments
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 |
The |
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 |
I think between #3215, #3709, #3933 for extracting common app/blueprint behavior to a base class, and #593, #3923 nested blueprints, this is addressed satisfactorily for now. I will continue to think about how to refactor the base class more over time. Apps can already be mounted in a few ways. Werkzeug's The one interesting thing would be to be able to generate a new |
#1361, #1498, and #1494 seem to indicate that some people don't see Blueprints as templates for application behavior, but want to treat them as little self-contained applications that are composed onto the main application. Effectively, we would be taking the app composition pattern and building it into the API.
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
andtemplates
(although Methodrender_template
does not use blueprint specifiedtemplate_folder
#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?The text was updated successfully, but these errors were encountered: