ó
Þ*µPc           @   s‚   d  d l  m Z d  d l m Z m Z m Z d  d l m Z d e f d „  ƒ  YZ	 d e f d „  ƒ  YZ
 d e
 f d	 „  ƒ  YZ d
 S(   iÿÿÿÿ(   t   HttpResponse(   t   loadert   Contextt   RequestContext(   t   sixt   ContentNotRenderedErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s1   ../Django//lib/python/django/template/response.pyR      s   t   SimpleTemplateResponsec           B   s¡   e  Z d  d d g Z d d d d d „ Z d „  Z d „  Z d „  Z e d „  ƒ Z	 d „  Z
 d	 „  Z e d
 „  ƒ Z d „  Z e d „  ƒ Z e j d „  ƒ Z RS(   t   template_namet   context_datat   _post_render_callbacksc         C   sG   | |  _  | |  _ g  |  _ t t |  ƒ j d | | | ƒ t |  _ d  S(   Nt    (   R	   R
   R   t   superR   t   __init__t   Falset   _is_rendered(   t   selft   templatet   contextt   content_typet   statust   mimetype(    (    s1   ../Django//lib/python/django/template/response.pyR      s    			c         C   s[   t  t |  ƒ j ƒ  } |  j s- t d ƒ ‚ n  x' |  j D] } | | k r7 | | =q7 q7 W| S(   sç   Pickling support function.

        Ensures that the object can't be pickled before it has been
        rendered, and that the pickled state only includes rendered
        data, not the data used to construct the response.
        s?   The response content must be rendered before it can be pickled.(   R   R   t   __getstate__R   R   t   rendering_attrs(   R   t   obj_dictt   attr(    (    s1   ../Django//lib/python/django/template/response.pyR   $   s    	c         C   sI   t  | t t f ƒ r" t j | ƒ St  | t j ƒ rA t j | ƒ S| Sd S(   s<   Accepts a template object, path-to-template or list of pathsN(   t
   isinstancet   listt   tupleR   t   select_templateR   t   string_typest   get_template(   R   R   (    (    s1   ../Django//lib/python/django/template/response.pyt   resolve_template5   s
    c         C   s!   t  | t ƒ r | St | ƒ Sd S(   so   Converts context data into a full Context object
        (assuming it isn't already a Context object).
        N(   R   R   (   R   R   (    (    s1   ../Django//lib/python/django/template/response.pyt   resolve_context>   s    c         C   s7   |  j  |  j ƒ } |  j |  j ƒ } | j | ƒ } | S(   sA  Returns the freshly rendered content for the template and context
        described by the TemplateResponse.

        This *does not* set the final content of the response. To set the
        response content, you must either call render(), or set the
        content explicitly using the value of this property.
        (   R!   R	   R"   R
   t   render(   R   R   R   t   content(    (    s1   ../Django//lib/python/django/template/response.pyt   rendered_contentG   s    	c         C   s*   |  j  r | |  ƒ n |  j j | ƒ d S(   s‰   Adds a new post-rendering callback.

        If the response has already been rendered,
        invoke the callback immediately.
        N(   R   R   t   append(   R   t   callback(    (    s1   ../Django//lib/python/django/template/response.pyt   add_post_render_callbackU   s    	c         C   sW   |  } |  j  sS |  j |  _ x5 |  j D]' } | | ƒ } | d k	 r% | } q% q% Wn  | S(   s´   Renders (thereby finalizing) the content of the response.

        If the content has already been rendered, this is a no-op.

        Returns the baked response instance.
        N(   R   R%   R$   R   t   None(   R   t   retvalt   post_callbackt	   newretval(    (    s1   ../Django//lib/python/django/template/response.pyR#   `   s    	c         C   s   |  j  S(   N(   R   (   R   (    (    s1   ../Django//lib/python/django/template/response.pyt   is_renderedp   s    c         C   s+   |  j  s t d ƒ ‚ n  t t |  ƒ j ƒ  S(   NsE   The response content must be rendered before it can be iterated over.(   R   R   R   R   t   __iter__(   R   (    (    s1   ../Django//lib/python/django/template/response.pyR.   t   s    	c         C   s(   |  j  s t d ƒ ‚ n  t t |  ƒ j S(   Ns@   The response content must be rendered before it can be accessed.(   R   R   R   R   R$   (   R   (    (    s1   ../Django//lib/python/django/template/response.pyR$   z   s    	c         C   s    t  j j |  | ƒ t |  _ d S(   s*   Sets the content for the response
        N(   R    R$   t   fsett   TrueR   (   R   t   value(    (    s1   ../Django//lib/python/django/template/response.pyR$      s    N(   R   R   R   R)   R   R   R!   R"   t   propertyR%   R(   R#   R-   R.   R$   t   setter(    (    (    s1   ../Django//lib/python/django/template/response.pyR   
   s   									t   TemplateResponsec           B   s<   e  Z e j d  d g Z d d d d d d „ Z d „  Z RS(   t   _requestt   _current_appc         C   s8   | |  _  | |  _ t t |  ƒ j | | | | | ƒ d  S(   N(   R5   R6   R   R4   R   (   R   t   requestR   R   R   R   R   t   current_app(    (    s1   ../Django//lib/python/django/template/response.pyR      s    		c         C   s,   t  | t ƒ r | St |  j | d |  j ƒS(   su   Convert context data into a full RequestContext object
        (assuming it isn't already a Context object).
        R8   (   R   R   R   R5   R6   (   R   R   (    (    s1   ../Django//lib/python/django/template/response.pyR"   ™   s    N(   R   R   R   R   R)   R   R"   (    (    (    s1   ../Django//lib/python/django/template/response.pyR4   ‰   s
   N(   t   django.httpR    t   django.templateR   R   R   t   django.utilsR   t	   ExceptionR   R   R4   (    (    (    s1   ../Django//lib/python/django/template/response.pyt   <module>   s
   