Skip to content
Myr

Merge pull request #2371 from davidism/register_blueprint-doc

Before adoption: this commit came in with the history the project adopted, so no landing records it.

document `Flask.register_blueprint` arguments

authored by David Lord · committed by GitHub · parents e97f6e2, fe1bf3c · Browse files · 2 files+39 added−14 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+39 added−14 removed

  • other:+39 added−14 removed

2 files+39 added−14 removed

modified:flask/app.py+24 added-6 removed
993 unmodified lines
994 return self.session_interface.make_null_session(self)995996 @setupmethod997 def register_blueprint(self, blueprint, **options):998 """Registers a blueprint on the application.998 """Register a :class:`~flask.Blueprint` on the application. Keyword999 arguments passed to this method will override the defaults set on the1000 blueprint.10011002 Calls the blueprint's :meth:`~flask.Blueprint.register` method after1003 recording the blueprint in the application's :attr:`blueprints`.10041005 :param blueprint: The blueprint to register.1006 :param url_prefix: Blueprint routes will be prefixed with this.1007 :param subdomain: Blueprint routes will match on this subdomain.1008 :param url_defaults: Blueprint routes will use these default values for1009 view arguments.1010 :param options: Additional keyword arguments are passed to1011 :class:`~flask.blueprints.BlueprintSetupState`. They can be1012 accessed in :meth:`~flask.Blueprint.record` callbacks.10131014 .. versionadded:: 0.71015 """1016 first_registration = False10171018 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)1019 assert self.blueprints[blueprint.name] is blueprint, (1020 'A name collision occurred between blueprints %r and %r. Both'1021 ' share the same name "%s". Blueprints that are created on the'1022 ' fly need unique names.' % (1023 blueprint, self.blueprints[blueprint.name], blueprint.name1024 )1025 )1026 else:1027 self.blueprints[blueprint.name] = blueprint1028 self._blueprint_order.append(blueprint)1029 first_registration = True10301031 blueprint.register(self, options, first_registration)10321033 def iter_blueprints(self):1034 """Iterates over all blueprints by the order they were registered.
1130 unmodified lines
modified:flask/blueprints.py+15 added-8 removed
157 unmodified lines
158 """159 return BlueprintSetupState(self, app, options, first_registration)160161 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.166167 :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)175176 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 )181182 for deferred in self.deferred_functions:183 deferred(state)184
258 unmodified lines