document `Flask.register_blueprint` arguments
Before adoption: this commit came in with the history the project adopted, so no landing records it.
closes #1809
authored by David Lord · committed by David Lord · parent e97f6e2 · Browse files · 2 files·+41 added−15 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+41 added−15 removed
- other:+41 added−15 removed
Provenance
- Commit
0f7b3a4- Tree
4c5c2d2- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
e97f6e2
2 files changed+41 added−15 removed
modified:flask/app.py+26 added-7 removed
992 unmodified lines993 ))994 return self.session_interface.make_null_session(self)995 996 @setupmethod997- def register_blueprint(self, blueprint, **options):998- """Registers a blueprint on the application.997+ def register_blueprint(998+ self, blueprint, **options999+ ):1000+ """Register a :class:`~flask.Blueprint` on the application. Keyword1001+ arguments passed to this method will override the defaults set on the1002+ blueprint.1003 1004+ Calls the blueprint's :meth:`~flask.Blueprint.register` method after1005+ recording the blueprint in the application's :attr:`blueprints`.1006+1007+ :param url_prefix: Blueprint routes will be prefixed with this.1008+ :param subdomain: Blueprint routes will match on this subdomain.1009+ :param url_defaults: Blueprint routes will use these default values for1010+ view arguments.1011+ :param options: Additional keyword arguments are passed to1012+ :class:`~flask.blueprints.BlueprintSetupState`. They can be1013+ accessed in :meth:`~flask.Blueprint.record` callbacks.1014+1015 .. versionadded:: 0.71016 """1017 first_registration = False1018+1019 if blueprint.name in self.blueprints:1004- assert self.blueprints[blueprint.name] is blueprint, \1005- 'A blueprint\'s name collision occurred between %r and ' \1006- '%r. Both share the same name "%s". Blueprints that ' \1007- 'are created on the fly need unique names.' % \1008- (blueprint, self.blueprints[blueprint.name], blueprint.name)1020+ assert self.blueprints[blueprint.name] is blueprint, (1021+ 'A name collision occurred between blueprints %r and %r. Both'1022+ ' share the same name "%s". Blueprints that are created on the'1023+ ' fly need unique names.' % (1024+ blueprint, self.blueprints[blueprint.name], blueprint.name1025+ )1026+ )1027 else:1028 self.blueprints[blueprint.name] = blueprint1029 self._blueprint_order.append(blueprint)1030 first_registration = True1031+1032 blueprint.register(self, options, first_registration)1033 1034 def iter_blueprints(self):1035 """Iterates over all blueprints by the order they were registered.1130 unmodified linesmodified:flask/blueprints.py+15 added-8 removed
157 unmodified lines158 """159 return BlueprintSetupState(self, app, options, first_registration)160 161 def register(self, app, options, first_registration=False):162- """Called by :meth:`Flask.register_blueprint` to register a blueprint163- on the application. This can be overridden to customize the register164- behavior. Keyword arguments from165- :func:`~flask.Flask.register_blueprint` are directly forwarded to this166- method in the `options` dictionary.162+ """Called by :meth:`Flask.register_blueprint` to register all views163+ and callbacks registered on the blueprint with the application. Creates164+ a :class:`.BlueprintSetupState` and calls each :meth:`record` callback165+ with it.166+167+ :param app: The application this blueprint is being registered with.168+ :param options: Keyword arguments forwarded from169+ :meth:`~Flask.register_blueprint`.170+ :param first_registration: Whether this is the first time this171+ blueprint has been registered on the application.172 """173 self._got_registered_once = True174 state = self.make_setup_state(app, options, first_registration)175+176 if self.has_static_folder:171- state.add_url_rule(self.static_url_path + '/<path:filename>',172- view_func=self.send_static_file,173- endpoint='static')177+ state.add_url_rule(178+ self.static_url_path + '/<path:filename>',179+ view_func=self.send_static_file, endpoint='static'180+ )181 182 for deferred in self.deferred_functions:183 deferred(state)184 258 unmodified lines