Skip to content
Myr

More docstrings for blueprints.

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

authored by Armin Ronacher · committed by Armin Ronacher · parent dbb9a2e · Browse files · 4 files+40 added−11 removed
This commit

State

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

Diff stats

4 files+40 added−11 removed

  • other:+40 added−11 removed

4 files+40 added−11 removed

modified:docs/patterns/appfactories.rst+2 added-2 removed
1 unmodified line
23Application Factories4=====================56If you are already using packages and modules for your application7(:ref:`packages`) there are a couple of really nice ways to further improve6If you are already using packages and blueprints for your application7(:ref:`blueprints`) there are a couple of really nice ways to further improve8the experience. A common pattern is creating the application object when9the module is imported. But if you move the creation of this object,10into a function, you can then create multiple instances of this and later.11
64 unmodified lines
modified:docs/api.rst+6 added-3 removed
16 unmodified lines
17 :members:18 :inherited-members:192021Module Objects22--------------21Blueprint Objects22-----------------2324.. autoclass:: Module24.. autoclass:: Blueprint25 :members:26 :inherited-members:2728Incoming Request Data
320 unmodified lines
349 ctx = _request_ctx_stack.top350 if ctx is not None:351 return ctx.session352353.. autoclass:: flask.blueprints.BlueprintSetupState354 :members:355356Signals357-------358359.. when modifying this list, also update the one in signals.rst
56 unmodified lines
modified:docs/quickstart.rst+1 added-2 removed
379 unmodified lines
380 /templates381 /hello.html382383For templates you can use the full power of Jinja2 templates. Head over384to the :ref:`templating` section of the documentation or the official385`Jinja2 Template Documentation384to the the official `Jinja2 Template Documentation385<http://jinja.pocoo.org/2/documentation/templates>`_ for more information.386387Here is an example template:388
361 unmodified lines
modified:flask/blueprints.py+31 added-4 removed
14 unmodified lines
151617class BlueprintSetupState(object):18 """Temporary holder object for registering a blueprint with the19 application.19 application. An instance of this class is created by the20 :meth:`~flask.Blueprint.make_setup_state` method and later passed21 to all register callback functions.22 """2324 def __init__(self, blueprint, app, options, first_registration):25 #: a reference to the current application26 self.app = app2728 #: a reference to the blurprint that created this setup state.29 self.blueprint = blueprint3031 #: a dictionary with all options that were passed to the32 #: :meth:`~flask.Flask.register_blueprint` method.33 self.options = options3435 #: as blueprints can be registered multiple times with the36 #: application and not everything wants to be registered37 #: multiple times on it, this attribute can be used to figure38 #: out if the blueprint was registered in the past already.39 self.first_registration = first_registration4041 subdomain = self.options.get('subdomain')42 if subdomain is None:43 subdomain = self.blueprint.subdomain4445 #: The subdomain that the blueprint should be active for, `None`46 #: otherwise.47 self.subdomain = subdomain4849 url_prefix = self.options.get('url_prefix')50 if url_prefix is None:51 url_prefix = self.blueprint.url_prefix5253 #: The prefix that should be used for all URLs defined on the54 #: blueprint.55 self.url_prefix = url_prefix5657 #: A dictionary with URL defaults that is added to each and every58 #: URL that was defined with the blueprint.59 self.url_defaults = dict(self.blueprint.url_defaults)60 self.url_defaults.update(self.options.get('url_defaults', ()))6162 def add_url_rule(self, rule, endpoint=None, view_func=None, **options):
13 unmodified lines
76 view_func, defaults=defaults, **options)777879class Blueprint(_PackageBoundObject):59 """Represents a blueprint.80 """Represents a blueprint. A blueprint is an object that records81 functions that will be called with the82 :class:`~flask.blueprint.BlueprintSetupState` later to register functions83 or other things on the main application. See :ref:`blueprints` for more84 information.8586 .. versionadded:: 0.787 """88
39 unmodified lines
128 func(state)129 return self.record(update_wrapper(wrapper, func))130131 def make_setup_state(self, app, options, first_registration=False):132 """Creates an instance of :meth:`~flask.blueprints.BlueprintSetupState`133 object that is later passed to the register callback functions.134 Subclasses can override this to return a subclass of the setup state.135 """136 return BlueprintSetupState(self, app, options, first_registration)137138 def register(self, app, options, first_registration=False):139 """Called by :meth:`Flask.register_blueprint` to register a blueprint
142 unmodified lines
282 up from the application.283284 Otherwise works as the :meth:`~flask.Flask.errorhandler` decorator285 of the :class:`~flask.Flask` object.257258 .. versionadded:: 0.7286 """287 def decorator(f):288 self.record_once(lambda s: s.app._register_error_handler(289 self.name, code_or_exception, f))
2 unmodified lines