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

Removed a dependency on the Flask app from create_api_blueprint #226

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@croach
Contributor

croach commented Jun 22, 2013

The create_api_blueprint calls _next_blueprint_name which, in turn,
checks all blueprints on the Flask app object to see if any previously
registered blueprints have a matching name and, if so, it returns a
new name with a suffixed index. This creates a dependency on the app
object in the create_api_blueprint method. This can cause problems in
situations where the developer wishes to move the creation of the API
endpoints into a module separate from the one in which the app object
is created. Allowing the user to create blueprints for API endpoints
in a separate module without the need to import the app object is key
in preventing a circular dependency between modules.

Since creating an API blueprint is more of a "power user" function, it
stands to reason that making sure the name of the blueprint does not
overlap other registered blueprints should be a responsibility of the
developer. For this reason, I've moved the call to
_next_blueprint_name out of the create_api_blueprint method and into
the create_api method. In the latter case, things are a bit more
automated and the case for renaming blueprints is a little stronger
there.

Removed a dependency on the Flask app from create_api_blueprint
The create_api_blueprint calls _next_blueprint_name which, in turn,
checks all blueprints on the Flask app object to see if any previously
registered blueprints have a matching name and, if so, it returns a
new name with a suffixed index. This creates a dependency on the app
object in the create_api_blueprint method. This can cause problems in
situations where the developer wishes to move the creation of the API
endpoints into a module separate from the one in which the app object
is created. Allowing the user to create blueprints for API endpoints
in a separate module without the need to import the app object is key
in preventing a circular dependency between modules.

Since creating an API blueprint is more of a "power user" function, it
stands to reason that making sure the name of the blueprint does not
overlap other registered blueprints should be a responsibility of the
developer. For this reason, I've moved the call to
_next_blueprint_name out of the create_api_blueprint method and into
the create_api method. In the latter case, things are a bit more
automated and the case for renaming blueprints is a little stronger
there.
@jfinkels

This comment has been minimized.

Owner

jfinkels commented Jul 25, 2013

This seems reasonable. Please add a test case before I pull it in.

@jfinkels

This comment has been minimized.

Owner

jfinkels commented Feb 2, 2015

I have changed the behavior of init_app and create_api_blueprint; is this still an issue? See also #308.

@jfinkels

This comment has been minimized.

Owner

jfinkels commented Feb 4, 2015

This should be fixed by #308.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment