ó
`¾Tc        	   @   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: (c) 2011 by Armin Ronacher.
    :license: BSD, see LICENSE for more details.
i   (   t   request(   t   with_metaclasst   gett   postt   headt   optionst   deletet   putt   tracet   patcht   Viewc           B   s2   e  Z d  Z d Z g  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(    (    sQ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/views.pyt   dispatch_requestA   s    c            s   ‡  ‡ ‡ f d †  ‰ |  j  rV | ˆ _ |  j ˆ _ x  |  j  D] } | ˆ ƒ ‰ q= Wn  |  ˆ _ | ˆ _ |  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"   ˆ j  ˆ  ˆ Ž  } | j |  | Ž  S(   N(   t
   view_classR   (   t   argst   kwargsR   (   t
   class_argst   class_kwargst   view(    sQ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/views.pyR   R   s    (   t
   decoratorst   __name__t
   __module__R   t   __doc__t   methods(   t   clst   nameR   R   t	   decorator(    (   R   R   R   sQ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/views.pyt   as_viewH   s    
				N(	   R   R   R   t   NoneR   R   R   t   classmethodR   (    (    (    sQ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/views.pyR
      s
   	t   MethodViewTypec           B   s   e  Z d  „  Z RS(   c         C   s‹   t  j |  | | | ƒ } d | k r‡ t | j p3 g  ƒ } x0 | D]( } | t k r@ | j | j ƒ  ƒ q@ q@ W| r‡ t | ƒ | _ q‡ n  | S(   NR   (   t   typet   __new__t   setR   t   http_method_funcst   addt   uppert   sorted(   R   R   t   basest   dt   rvR   t   key(    (    sQ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/views.pyR!   k   s    (   R   R   R!   (    (    (    sQ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/views.pyR   i   s   t
   MethodViewc           B   s   e  Z d  Z d „  Z RS(   s­  Like a regular class-based view but that dispatches requests to
    particular methods.  For instance if you implement a method called
    :meth:`get` it means you will response to ``'GET'`` requests and
    the :meth:`dispatch_request` implementation will automatically
    forward your request to that.  Also :attr:`options` is set for you
    automatically::

        class CounterAPI(MethodView):

            def get(self):
                return session.get('counter', 0)

            def post(self):
                session['counter'] = session.get('counter', 0) + 1
                return 'OK'

        app.add_url_rule('/counter', view_func=CounterAPI.as_view('counter'))
    c         O   sw   t  |  t j j ƒ  d  ƒ } | d  k rK t j d k rK t  |  d d  ƒ } n  | d  k	 sj t d t j ƒ ‚ | | | Ž  S(   Nt   HEADR   s   Unimplemented method %r(   t   getattrR    t   methodt   lowerR   t   AssertionError(   R   R   R   t   meth(    (    sQ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/views.pyR   Ž   s
    (   R   R   R   R   (    (    (    sQ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/views.pyR+   {   s   N(   R   t   globalsR    t   _compatR   t	   frozensetR#   t   objectR
   R    R   R+   (    (    (    sQ   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/flask/views.pyt   <module>
   s   V