Skip to content
Myr

Merge pull request #387 from FND/docs

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

authored by Ron DuPlain · committed by Ron DuPlain · parents b786eac, 2792dcf · Browse files · 3 files+7 added−7 removed
This commit

State

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

Trailers

  • documentation: minor stylistic adjustments

Diff stats

3 files+7 added−7 removed

  • other:+7 added−7 removed

3 files+7 added−7 removed

modified:docs/patterns/appdispatch.rst+1 added-1 removed
56 unmodified lines
57---------------------5859Sometimes you might want to use multiple instances of the same application60with different configurations. Assuming the application is created inside61a function and you can call that function to instanciate it, that is61a function and you can call that function to instantiate it, that is62really easy to implement. In order to develop your application to support63creating new instances in functions have a look at the64:ref:`app-factories` pattern.65
105 unmodified lines
modified:docs/views.rst+1 added-1 removed
72 unmodified lines
73enough to explain the basic principle. When you have a class based view74the question comes up what `self` points to. The way this works is that75whenever the request is dispatched a new instance of the class is created76and the :meth:`~flask.views.View.dispatch_request` method is called with77the parameters from the URL rule. The class itself is instanciated with77the parameters from the URL rule. The class itself is instantiated with78the parameters passed to the :meth:`~flask.views.View.as_view` function.79For instance you can write a class like this::8081 class RenderTemplateView(View):
156 unmodified lines
modified:flask/views.py+5 added-5 removed
68 unmodified lines
69 raise NotImplementedError()7071 @classmethod72 def as_view(cls, name, *class_args, **class_kwargs):73 """Converts the class into an actual view function that can be74 used with the routing system. What it does internally is generating75 a function on the fly that will instanciate the :class:`View`76 on each request and call the :meth:`dispatch_request` method on it.73 """Converts the class into an actual view function that can be used74 with the routing system. Internally this generates a function on the75 fly which will instantiate the :class:`View` on each request and call76 the :meth:`dispatch_request` method on it.7778 The arguments passed to :meth:`as_view` are forwarded to the79 constructor of the class.80 """
8 unmodified lines
89 view = decorator(view)9091 # we attach the view class to the view function for two reasons:92 # first of all it allows us to easily figure out what class based93 # view this thing came from, secondly it's also used for instanciating93 # view this thing came from, secondly it's also used for instantiating94 # the view class so you can actually replace it with something else95 # for testing purposes and debugging.96 view.view_class = cls97 view.__name__ = name
53 unmodified lines