ó
I()Qc           @  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 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   classonlymethod(   t   sixu   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(    (    s2   ../Django//lib/python/django/views/generic/base.pyt   get_context_data   s    (   t   __name__t
   __module__t   __doc__R
   (    (    (    s2   ../Django//lib/python/django/views/generic/base.pyR      s   t   Viewc           B  se   e  Z d  Z 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   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(    (    s2   ../Django//lib/python/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
   initkwargst   cls(    s2   ../Django//lib/python/django/views/generic/base.pyt   view=   s    			t   updatedt   assigned(    (    (   t   http_method_namest	   TypeErrorR   R   R   R   (   R   R   R   R   (    (   R   R   s2   ../Django//lib/python/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(    (    s2   ../Django//lib/python/django/views/generic/base.pyR   N   s    !	c         O  sC   t  j d | j | j d i d d 6|  j d 6ƒt j |  j ƒ  ƒ S(   Nu   Method Not Allowed (%s): %st   extrai•  u   status_codeu   request(   t   loggert   warningR"   t   pathR   R   t   HttpResponseNotAllowedt   _allowed_methods(   R   R   R   R	   (    (    s2   ../Django//lib/python/django/views/generic/base.pyR%   X   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   joinR,   (   R   R   R   R	   t   response(    (    s2   ../Django//lib/python/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(    (    s2   ../Django//lib/python/django/views/generic/base.pyR,   j   s    (   R   R   R   R   R   R   R!   R   R%   R0   R,   (    (    (    s2   ../Django//lib/python/django/views/generic/base.pyR      s   	
!	
				t   TemplateResponseMixinc           B  s2   e  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  s;   | j  d |  j ƒ |  j d |  j d |  j ƒ  d | |  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   context(   t
   setdefaultt   content_typet   response_classR   t   get_template_names(   R   R5   t   response_kwargs(    (    s2   ../Django//lib/python/django/views/generic/base.pyt   render_to_responsev   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   (    (    s2   ../Django//lib/python/django/views/generic/base.pyR9   †   s    N(
   R   R   R   R=   R<   R   R8   R7   R;   R9   (    (    (    s2   ../Django//lib/python/django/views/generic/base.pyR3   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 url conf.
    c         O  s   |  j  |   } |  j | ƒ S(   N(   R
   R;   (   R   R   R   R	   R5   (    (    s2   ../Django//lib/python/django/views/generic/base.pyR   ˜   s    (   R   R   R   R   (    (    (    s2   ../Django//lib/python/django/views/generic/base.pyR>   “   s   t   RedirectViewc           B  s_   e  Z d  Z e Z d Z e 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         K  s\   |  j  rT |  j  | } |  j j j d d ƒ } | rP |  j rP d | | f } n  | Sd Sd 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.
        u   QUERY_STRINGu    u   %s?%sN(   t   urlR   t   METAR   t   query_stringR=   (   R   R	   R@   R   (    (    s2   ../Django//lib/python/django/views/generic/base.pyt   get_redirect_url¥   s    	c         O  sv   |  j  |   } | r; |  j r+ t j | ƒ St j | ƒ Sn7 t j d |  j j d i d d 6|  j d 6ƒt j	 ƒ  Sd  S(   Nu   Gone: %sR'   iš  u   status_codeu   request(
   RC   t	   permanentR   t   HttpResponsePermanentRedirectt   HttpResponseRedirectR(   R)   R   R*   t   HttpResponseGone(   R   R   R   R	   R@   (    (    s2   ../Django//lib/python/django/views/generic/base.pyR   ´   s    	c         O  s   |  j  | | | Ž S(   N(   R   (   R   R   R   R	   (    (    s2   ../Django//lib/python/django/views/generic/base.pyR   Ã   s    c         O  s   |  j  | | | Ž S(   N(   R   (   R   R   R   R	   (    (    s2   ../Django//lib/python/django/views/generic/base.pyt   postÆ   s    c         O  s   |  j  | | | Ž S(   N(   R   (   R   R   R   R	   (    (    s2   ../Django//lib/python/django/views/generic/base.pyR0   É   s    c         O  s   |  j  | | | Ž S(   N(   R   (   R   R   R   R	   (    (    s2   ../Django//lib/python/django/views/generic/base.pyt   deleteÌ   s    c         O  s   |  j  | | | Ž S(   N(   R   (   R   R   R   R	   (    (    s2   ../Django//lib/python/django/views/generic/base.pyt   putÏ   s    N(   R   R   R   t   TrueRD   R=   R@   t   FalseRB   RC   R   R   RH   R0   RI   RJ   (    (    (    s2   ../Django//lib/python/django/views/generic/base.pyR?      s   						(   t
   __future__R    t   loggingt	   functoolsR   t   djangoR   t   django.core.exceptionsR   t   django.template.responseR   t   django.utils.decoratorsR   t   django.utilsR   t	   getLoggerR(   t   objectR   R   R3   R>   R?   (    (    (    s2   ../Django//lib/python/django/views/generic/base.pyt   <module>   s   S%
