/usr/local/lib64/python3.6/site-packages/flask/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/flask/__pycache__/views.cpython-36.pyc (4910B)
3
^TBg< @ sz d dl ZddlmZ ddlmZ ddl mZ edddd d
ddd
gZG dd dZG dd de Z
G dd dee
dZdS ) N )current_app)request)ResponseReturnValuegetpostheadoptionsdeleteputtracepatchc @ sp e Zd ZU dZdZejeje dZ eje
g Zejej e
dddZeeejejejdddZdS ) Viewa Alternative way to use view functions. A subclass has to implement
:meth:`dispatch_request` which is called with the view arguments from
the URL routing system. If :attr:`methods` is provided the methods
do not have to be passed to the :meth:`~flask.Flask.add_url_rule`
method explicitly::
class MyView(View):
methods = ['GET']
def dispatch_request(self, name):
return f"Hello {name}!"
app.add_url_rule('/hello/
', view_func=MyView.as_view('myview'))
When you want to decorate a pluggable view you will have to either do that
when the view function is created (by wrapping the return value of
:meth:`as_view`) or you can use the :attr:`decorators` attribute::
class SecretView(View):
methods = ['GET']
decorators = [superuser_required]
def dispatch_request(self):
...
The decorators stored in the decorators list are applied one after another
when the view function is created. Note that you can *not* use the class
based decorators since those would decorate the view class and not the
generated view function!
N)returnc C s
t dS )zSubclasses have to override this method to implement the
actual view function code. This method is called with all
the arguments from the URL rule.
N)NotImplementedError)self r ,/tmp/pip-build-0s3hx122/flask/flask/views.pydispatch_request> s zView.dispatch_request)name
class_argsclass_kwargsr c sz t jt jtd fdd| jrJ|_| j_x| jD ]}|q:W | _|_| j_| j_| j_| j _ S )a Converts the class into an actual view function that can be used
with the routing system. Internally this generates a function on the
fly which will instantiate the :class:`View` on each request and call
the :meth:`dispatch_request` method on it.
The arguments passed to :meth:`as_view` are forwarded to the
constructor of the class.
)argskwargsr c s j }tj|j| |S )N)
view_classr ensure_syncr )r r r )r r viewr r r R s zView.as_view..view)
tAnyr
decorators__name__
__module__r __doc__methodsprovide_automatic_options)clsr r r Z decoratorr )r r r r as_viewE s
zView.as_view)r r! __qualname__r" r# r OptionalZListstrr$ boolr Callabler r classmethodr r&