ó
®â0_c           @  s  d  d l  m Z d  d l Z d  d l m Z d  d l m Z d  d l m Z d  d l	 m
 Z
 d  d l m Z m Z d  d l m Z d  d	 l m Z e j d
 ƒ Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e e e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   unicode_literalsN(   t   update_wrapper(   t   http(   t   ImproperlyConfigured(   t   TemplateResponse(   t   NoReverseMatcht   reverse(   t   six(   t   classonlymethodu   django.requestt   ContextMixinc           B  s   e  Z d  Z d „  Z RS(   u}   
    A default context mixin that passes the keyword arguments received by
    get_context_data as the template context.
    c         K  s   d | k r |  | d <n  | S(   Nu   view(    (   t   selft   kwargs(    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyt   get_context_data   s    (   t   __name__t
   __module__t   __doc__R   (    (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyR	      s   t   Viewc           B  sh   e  Z d  Z d d d d d d d d g Z d	 „  Z e d
 „  ƒ Z d „  Z d „  Z d „  Z	 d „  Z
 RS(   u}   
    Intentionally simple parent class for all views. Only implements
    dispatch-by-method and simple sanity checking.
    u   getu   postu   putu   patchu   deleteu   headu   optionsu   tracec         K  s4   x- t  j | ƒ D] \ } } t |  | | ƒ q Wd S(   u|   
        Constructor. Called in the URLconf; can contain helpful extra
        keyword arguments, and other things.
        N(   R   t	   iteritemst   setattr(   R
   R   t   keyt   value(    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyt   __init__$   s    c           s¸   xd ˆ D]\ } | ˆ  j  k r8 t d | ˆ  j f ƒ ‚ n  t ˆ  | ƒ s t d ˆ  j | f ƒ ‚ q q W‡  ‡ f d †  } ˆ  | _ ˆ | _ t | ˆ  d d ƒt | ˆ  j d d ƒ| S(   uB   
        Main entry point for a request-response process.
        uU   You tried to pass in the %s method name as a keyword argument to %s(). Don't do that.um   %s() received an invalid keyword %r. as_view only accepts arguments that are already attributes of the class.c           sh   ˆ  ˆ   } t  | d ƒ r: t  | d ƒ r: | j | _ n  |  | _ | | _ | | _ | j |  | | Ž S(   Nu   getu   head(   t   hasattrt   gett   headt   requestt   argsR   t   dispatch(   R   R   R   R
   (   t   clst
   initkwargs(    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyt   view=   s    			t   updatedt   assigned(    (    (   t   http_method_namest	   TypeErrorR   R   t
   view_classt   view_initkwargsR   R   (   R   R   R   R   (    (   R   R   s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyt   as_view.   s    		c         O  sR   | j  j ƒ  |  j k r9 t |  | j  j ƒ  |  j ƒ } n	 |  j } | | | | Ž S(   N(   t   methodt   lowerR!   t   getattrt   http_method_not_allowed(   R
   R   R   R   t   handler(    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyR   P   s    !	c         O  s@   t  j d | j | j d i d d 6| d 6ƒt j |  j ƒ  ƒ S(   Nu   Method Not Allowed (%s): %st   extrai•  u   status_codeu   request(   t   loggert   warningR&   t   pathR   t   HttpResponseNotAllowedt   _allowed_methods(   R
   R   R   R   (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyR)   Z   s    c         O  s3   t  j ƒ  } d j |  j ƒ  ƒ | d <d | d <| S(   uK   
        Handles responding to requests for the OPTIONS HTTP verb.
        u   , u   Allowu   0u   Content-Length(   R   t   HttpResponset   joinR0   (   R
   R   R   R   t   response(    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyt   optionsa   s    
c         C  s/   g  |  j  D]! } t |  | ƒ r
 | j ƒ  ^ q
 S(   N(   R!   R   t   upper(   R
   t   m(    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyR0   j   s    (   R   R   R   R!   R   R   R%   R   R)   R4   R0   (    (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyR      s   	
"	
			t   TemplateResponseMixinc           B  s8   e  Z d  Z d Z d Z e Z d Z d „  Z	 d „  Z
 RS(   u8   
    A mixin that can be used to render a template.
    c      
   K  sD   | j  d |  j ƒ |  j d |  j d |  j ƒ  d | d |  j |  S(   uþ   
        Returns a response, using the `response_class` for this
        view, with a template rendered with the given context.

        If any keyword arguments are provided, they will be
        passed to the constructor of the response class.
        u   content_typeR   t   templatet   contextt   using(   t
   setdefaultt   content_typet   response_classR   t   get_template_namest   template_engine(   R
   R9   t   response_kwargs(    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyt   render_to_responsew   s    		c         C  s,   |  j  d k r t d ƒ ‚ n
 |  j  g Sd S(   u¡   
        Returns a list of template names to be used for the request. Must return
        a list. May not be called if render_to_response is overridden.
        ut   TemplateResponseMixin requires either a definition of 'template_name' or an implementation of 'get_template_names()'N(   t   template_namet   NoneR   (   R
   (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyR>   ˆ   s    N(   R   R   R   RC   RB   R?   R   R=   R<   RA   R>   (    (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyR7   n   s   	t   TemplateViewc           B  s   e  Z d  Z d „  Z RS(   u…   
    A view that renders a template.  This view will also pass into the context
    any keyword arguments passed by the URLconf.
    c         O  s   |  j  |   } |  j | ƒ S(   N(   R   RA   (   R
   R   R   R   R9   (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyR   š   s    (   R   R   R   R   (    (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyRD   •   s   t   RedirectViewc           B  sn   e  Z d  Z e Z d	 Z d	 Z e Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(
   u=   
    A view that provides a redirect on any GET request.
    c         O  s›   |  j  r |  j  | } nD |  j rY y t |  j d | d | ƒ} Wq] t k
 rU d SXn d S|  j j j d d ƒ } | r— |  j r— d | | f } n  | S(   u±   
        Return the URL redirect to. Keyword arguments from the
        URL pattern match generating the redirect request
        are provided as kwargs to this method.
        R   R   u   QUERY_STRINGu    u   %s?%sN(	   t   urlt   pattern_nameR   R   RC   R   t   METAR   t   query_string(   R
   R   R   RF   (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyt   get_redirect_url¨   s    		c         O  ss   |  j  | | Ž  } | r> |  j r. t j | ƒ St j | ƒ Sn1 t j d | j d i d d 6| d 6ƒt j ƒ  Sd  S(   Nu   Gone: %sR+   iš  u   status_codeu   request(	   RJ   t	   permanentR   t   HttpResponsePermanentRedirectt   HttpResponseRedirectR,   R-   R.   t   HttpResponseGone(   R
   R   R   R   RF   (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyR   ½   s    	c         O  s   |  j  | | | Ž S(   N(   R   (   R
   R   R   R   (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyR   Ë   s    c         O  s   |  j  | | | Ž S(   N(   R   (   R
   R   R   R   (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyt   postÎ   s    c         O  s   |  j  | | | Ž S(   N(   R   (   R
   R   R   R   (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyR4   Ñ   s    c         O  s   |  j  | | | Ž S(   N(   R   (   R
   R   R   R   (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyt   deleteÔ   s    c         O  s   |  j  | | | Ž S(   N(   R   (   R
   R   R   R   (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyt   put×   s    c         O  s   |  j  | | | Ž S(   N(   R   (   R
   R   R   R   (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyt   patchÚ   s    N(   R   R   R   t   FalseRK   RC   RF   RG   RI   RJ   R   R   RO   R4   RP   RQ   RR   (    (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyRE   Ÿ   s   							(   t
   __future__R    t   loggingt	   functoolsR   t   djangoR   t   django.core.exceptionsR   t   django.template.responseR   t   django.urlsR   R   t   django.utilsR   t   django.utils.decoratorsR   t	   getLoggerR,   t   objectR	   R   R7   RD   RE   (    (    (    s;   /tmp/pip-unpacked-wheel-BAJOf3/django/views/generic/base.pyt   <module>   s   R'
