Skip to content
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

use blueprint specified template folder #1537

Closed
wants to merge 5 commits into from
Closed

use blueprint specified template folder #1537

wants to merge 5 commits into from

Conversation

alanhamlett
Copy link
Contributor

Fixes issue #1361.


if request.blueprint is not None and \
isinstance(template_name_or_list, string_types):
bp = current_app.blueprints[request.blueprint]

This comment was marked as off-topic.

This comment was marked as off-topic.

@svieira
Copy link
Contributor

svieira commented Aug 2, 2015

Unless I am greatly mistaken this will break anyone out there who is using extensions and overriding (not inheriting from) the extension's blueprints. For example, given the following extension setup:

extension/
    __init__.py
    some.py
    extension_details.py
    templates/
        extension/
            base.html
            some-page.html

before this patch, overriding base.html would simply have been a matter of:

the-app/
    __init__.py
    templates/
        the-layout.html
        extension/
            base.html

And making sure that base.html@the-app had the necessary block and import declarations. This would shadow base.html@extension, allowing the app developer to override what the extension was doing without the extension developer having to provide a hook for such an overload

With this patch, I don't think there is a way to override base.html@extension in extension without patching Flask to bring back the old behavior (which will result in a lot of issues if new extensions start depending on this behavior).

@davidism
Copy link
Member

davidism commented Aug 2, 2015

Agree with @svieira, this is the point I was making in my comment on the original issue.

The point of searching the app template folder first is so that an app developer can override templates supplied by a blueprint from an extension.

@ThiefMaster
Copy link
Member

Those commits should be squashed into a single one eventually.

Also, this would be a breaking change depending on the application structure, so I'd rather make it configurable, with the current behavior being the default.

@svieira
Copy link
Contributor

svieira commented Aug 3, 2015

If configurable it would have to be done at the register_blueprint method (since you could have one extension looking for the old behavior and one needed the new behavior).

I created #1548 to talk about some another possibility that might solve several of these issues in one go.

@N0odlez
Copy link

N0odlez commented Dec 26, 2015

Is there any update on when this fix could be merged or implemented in a different manner?

@davidism
Copy link
Member

The referenced issue was closed as wontfix.

@davidism davidism closed this Jun 26, 2016
@pallets pallets locked as resolved and limited conversation to collaborators Mar 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants