Skip to content

Conversation

@pgjones
Copy link
Member

@pgjones pgjones commented Feb 24, 2021

This allows blueprints to be nested within blueprints via a new
Blueprint.register_blueprint method. This should provide a use case
that has been desired for the past ~10 years.

This works by setting the endpoint name to be the blueprint names,
from parent to child delimeted by "." and then iterating over the
blueprint names in reverse order in the app (from most specific to
most general). This means that the expectation of nesting a blueprint
within a nested blueprint is met.

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

@greyli greyli linked an issue Feb 25, 2021 that may be closed by this pull request
@Abdur-rahmaanJ
Copy link
Contributor

Building the Shopyo framework which makes use of this idea (not for nested but normal blueprints), i posed the question of infinity.

It is better expressed in ThiefMaster's words: "Wouldn't a proper implementation of "sub-blueprints" pretty much automatically support infinite nesting of blueprints, too, anyway?" How does this PR address the issue?

@pgjones
Copy link
Member Author

pgjones commented Feb 25, 2021

@Abdur-rahmaanJ This supports infinite nesting, subject to resource limitations, so I don't think there is an issue.

@davidism davidism force-pushed the nested branch 3 times, most recently from 2684eea to 7c60412 Compare March 10, 2021 19:14
@pgjones pgjones changed the title WIP: Nested blueprints Nested blueprints Apr 7, 2021
@pgjones pgjones marked this pull request as ready for review April 7, 2021 19:34
@pgjones
Copy link
Member Author

pgjones commented Apr 7, 2021

I'm not sure if any additional documentation is required, as the nesting should work as a user would expect - therefore I think it is best just to note that nesting is possible.

@pgjones pgjones force-pushed the nested branch 2 times, most recently from 68125b8 to 8e21346 Compare April 7, 2021 19:41
@pgjones pgjones added this to the 2.0.0 milestone Apr 10, 2021
This allows blueprints to be nested within blueprints via a new
Blueprint.register_blueprint method. This should provide a use case
that has been desired for the past ~10 years.

This works by setting the endpoint name to be the blueprint names,
from parent to child delimeted by "." and then iterating over the
blueprint names in reverse order in the app (from most specific to
most general). This means that the expectation of nesting a blueprint
within a nested blueprint is met.
@davidism
Copy link
Member

I added a few more lines of documentation mentioning that URL prefixes are applied like /parent/child/route, parent before request etc. functions apply to the child, and child error handlers are preferred over parent.

@davidism davidism merged commit 64213fc into pallets:master Apr 14, 2021
@pgjones pgjones deleted the nested branch April 14, 2021 16:34
@pgjones
Copy link
Member Author

pgjones commented Apr 14, 2021

🎉

@jackwardell
Copy link
Contributor

so exciting, great work 👏

@hXtreme
Copy link

hXtreme commented Apr 14, 2021

This is the day I've been waiting for!🎉

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support zero-ceremony sub-app mounting (including Blueprints) Nestable blueprints

5 participants