|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /lib64/python2.7/site-packages/flask/ |
Upload File : |
�
-/�_c @ s� d Z d d l m Z d d l m Z e d d d d d d d
d g � Z d e f d
� � YZ d e f d � � YZ
d e e
e � f d � � YZ d S( s�
flask.views
~~~~~~~~~~~
This module provides class-based views inspired by the ones in Django.
:copyright: 2010 Pallets
:license: BSD-3-Clause
i ( t with_metaclass( t requestt gett postt headt optionst deletet putt tracet patcht Viewc B s8 e Z d Z d Z d Z d Z d � Z e d � � Z RS( s� 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 'Hello %s!' % name
app.add_url_rule('/hello/<name>', 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!
c C s
t � � d S( s� Subclasses 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( t NotImplementedError( t self( ( s, /tmp/pip-install-sTXtzD/flask/flask/views.pyt dispatch_requestE s c s� � � � f d � � | j rV | � _ | j � _ x | j D] } | � � � q= Wn | � _ | � _ | j � _ | j � _ | j � _ | j � _ � S( s� 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.
c s"