|
|
|
@ -994,22 +994,41 @@ class Flask(_PackageBoundObject):
|
|
|
|
|
return self.session_interface.make_null_session(self) |
|
|
|
|
|
|
|
|
|
@setupmethod |
|
|
|
|
def register_blueprint(self, blueprint, **options): |
|
|
|
|
"""Registers a blueprint on the application. |
|
|
|
|
def register_blueprint( |
|
|
|
|
self, blueprint, **options |
|
|
|
|
): |
|
|
|
|
"""Register a :class:`~flask.Blueprint` on the application. Keyword |
|
|
|
|
arguments passed to this method will override the defaults set on the |
|
|
|
|
blueprint. |
|
|
|
|
|
|
|
|
|
Calls the blueprint's :meth:`~flask.Blueprint.register` method after |
|
|
|
|
recording the blueprint in the application's :attr:`blueprints`. |
|
|
|
|
|
|
|
|
|
:param url_prefix: Blueprint routes will be prefixed with this. |
|
|
|
|
:param subdomain: Blueprint routes will match on this subdomain. |
|
|
|
|
:param url_defaults: Blueprint routes will use these default values for |
|
|
|
|
view arguments. |
|
|
|
|
:param options: Additional keyword arguments are passed to |
|
|
|
|
:class:`~flask.blueprints.BlueprintSetupState`. They can be |
|
|
|
|
accessed in :meth:`~flask.Blueprint.record` callbacks. |
|
|
|
|
|
|
|
|
|
.. versionadded:: 0.7 |
|
|
|
|
""" |
|
|
|
|
first_registration = False |
|
|
|
|
|
|
|
|
|
if blueprint.name in self.blueprints: |
|
|
|
|
assert self.blueprints[blueprint.name] is blueprint, \ |
|
|
|
|
'A blueprint\'s name collision occurred between %r and ' \ |
|
|
|
|
'%r. Both share the same name "%s". Blueprints that ' \ |
|
|
|
|
'are created on the fly need unique names.' % \ |
|
|
|
|
(blueprint, self.blueprints[blueprint.name], blueprint.name) |
|
|
|
|
assert self.blueprints[blueprint.name] is blueprint, ( |
|
|
|
|
'A name collision occurred between blueprints %r and %r. Both' |
|
|
|
|
' share the same name "%s". Blueprints that are created on the' |
|
|
|
|
' fly need unique names.' % ( |
|
|
|
|
blueprint, self.blueprints[blueprint.name], blueprint.name |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
else: |
|
|
|
|
self.blueprints[blueprint.name] = blueprint |
|
|
|
|
self._blueprint_order.append(blueprint) |
|
|
|
|
first_registration = True |
|
|
|
|
|
|
|
|
|
blueprint.register(self, options, first_registration) |
|
|
|
|
|
|
|
|
|
def iter_blueprints(self): |
|
|
|
|