Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add self.options so options can be retrived from within the blueprint #970

Closed
wants to merge 1 commit into from

4 participants

@gillestasse

With this method I can pass options to the blueprint when registering.
They are then available in the blueprint.

@ThiefMaster

Please follow PEP8. I'm also pretty sure that you are not supposed to put your name in a comment like you did (for bigger contributions you'd most likely want to add yourself to AUTHORS but that'd be somewhat strange for a one-line contribution).

Your code should look e.g. like this:

        # Allows to pass options to a blueprint and retrieve them within the blueprint
        self.options_blueprints = options

(I did not look at what value it actually provides. In any case, I don't like the name options_blueprints)

@gillestasse

@ThiefMaster My first pull request ever. Thanks for the comment. What should I do next ?

@untitaker
Collaborator

Do git commit --amend to make the changes and then git push -f.

@mitsuhiko
Owner

Not a fan of this because it probably indicates that something messy would be done with this information. Blueprints that want to operate on this information should be subclassed and intercept what they need.

@mitsuhiko mitsuhiko closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 0 deletions.
  1. +5 −0 flask/app.py
View
5 flask/app.py
@@ -878,6 +878,11 @@ def register_blueprint(self, blueprint, **options):
.. versionadded:: 0.7
"""
first_registration = False
+
+ #Added by Gilles. Allows to pass options to a blue print
+ #And retrieve it within the blueprint
+ self.options_blueprints=options
+
if blueprint.name in self.blueprints:
assert self.blueprints[blueprint.name] is blueprint, \
'A blueprint\'s name collision occurred between %r and ' \
Something went wrong with that request. Please try again.