ó
Ñ7ec           @   sÖ   d  d l  Z  d  d l m Z d  d l m Z d  d l m Z d Z d e f d „  ƒ  YZ d e	 f d	 „  ƒ  YZ
 d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d d „ Z d S(   iÿÿÿÿN(   t   contextmanager(   t   copy(   t   RemovedInDjango20Warnings'   django.template.context_processors.csrft   ContextPopExceptionc           B   s   e  Z d  Z RS(   s,   pop() has been called more times than push()(   t   __name__t
   __module__t   __doc__(    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR      s   t   ContextDictc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         O   s6   t  t |  ƒ j | | Ž  | j j |  ƒ | |  _ d  S(   N(   t   superR   t   __init__t   dictst   appendt   context(   t   selfR   t   argst   kwargs(    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR	      s    c         C   s   |  S(   N(    (   R   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt	   __enter__   s    c         O   s   |  j  j ƒ  d  S(   N(   R   t   pop(   R   R   R   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   __exit__   s    (   R   R   R	   R   R   (    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR      s   		t   BaseContextc           B   s¹   e  Z d d  „ Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d d „ Z d d „ Z d d „ Z d „  Z d „  Z RS(   c         C   s   |  j  | ƒ d  S(   N(   t   _reset_dicts(   R   t   dict_(    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR	      s    c         C   sJ   i t  d 6t d 6d  d 6} | g |  _ | d  k	 rF |  j j | ƒ n  d  S(   Nt   Truet   Falset   None(   R   R   R   R
   R   (   R   t   valuet   builtins(    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR   "   s    c         C   s&   t  t t |  ƒ ƒ } |  j | _ | S(   N(   R   R   R   R
   (   R   t	   duplicate(    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   __copy__(   s    c         C   s   t  |  j ƒ S(   N(   t   reprR
   (   R   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   __repr__-   s    c         c   s#   x t  |  j ƒ D] } | Vq Wd  S(   N(   t   reversedR
   (   R   t   d(    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   __iter__0   s    c         O   sW   g  } x> | D]6 } t  | t ƒ r6 | | j d 7} q | j | ƒ q Wt |  | | Ž S(   Ni   (   t
   isinstanceR   R
   R   R   (   R   R   R   R
   R    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   push4   s    c         C   s+   t  |  j ƒ d k r t ‚ n  |  j j ƒ  S(   Ni   (   t   lenR
   R   R   (   R   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR   =   s    	c         C   s   | |  j  d | <d S(   s%   Set a variable in the current contextiÿÿÿÿN(   R
   (   R   t   keyR   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   __setitem__B   s    c         C   sQ   |  j  d } x3 t |  j  ƒ D]" } | | j ƒ  k r | } Pq q W| | | <d S(   s|   
        Set a variable in one of the higher contexts if it exists there,
        otherwise in the current context.
        iÿÿÿÿN(   R
   R   t   keys(   R   R%   R   R   R    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt
   set_upwardF   s    c         C   s>   x+ t  |  j ƒ D] } | | k r | | Sq Wt | ƒ ‚ d S(   sH   Get a variable's value, starting at the current context and going upwardN(   R   R
   t   KeyError(   R   R%   R    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   __getitem__R   s    c         C   s   |  j  d | =d S(   s*   Delete a variable from the current contextiÿÿÿÿN(   R
   (   R   R%   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   __delitem__Y   s    c         C   s$   t  j d |  j j t ƒ | |  k S(   Ns9   %s.has_key() is deprecated in favor of the 'in' operator.(   t   warningst   warnt	   __class__R   R   (   R   R%   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   has_key]   s    c         C   s(   x! |  j  D] } | | k r
 t Sq
 Wt S(   N(   R
   R   R   (   R   R%   R    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   __contains__d   s    c         C   s2   x+ t  |  j ƒ D] } | | k r | | Sq W| S(   N(   R   R
   (   R   R%   t	   otherwiseR    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   getj   s    c         C   s.   y |  | SWn t  k
 r) | |  | <n X| S(   N(   R)   (   R   R%   t   default(    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt
   setdefaultp   s
    c         C   s   t  |  ƒ } | j | ƒ | S(   s|   
        Returns a new context with the same properties, but with only the
        values given in 'values' stored.
        (   R   R   (   R   t   valuest   new_context(    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   neww   s    c         C   s+   i  } x |  j  D] } | j | ƒ q W| S(   s6   
        Returns self.dicts as one dictionary
        (   R
   t   update(   R   t   flatR    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   flatten€   s    c         C   s)   t  | t ƒ r% |  j ƒ  | j ƒ  k St S(   sO   
        Compares two contexts by comparing theirs 'dicts' attributes.
        (   R"   R   R:   R   (   R   t   other(    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   __eq__‰   s    N(   R   R   R   R	   R   R   R   R!   R#   R   R&   R(   R*   R+   R/   R0   R2   R4   R7   R:   R<   (    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR      s$   															t   Contextc           B   sD   e  Z d  Z d e d d d „ Z e d „  ƒ Z d „  Z d „  Z	 RS(   s&   A stack container for variable contextc         C   sS   | |  _  | |  _ | |  _ d |  _ t ƒ  |  _ d  |  _ t t	 |  ƒ j
 | ƒ d  S(   Nt   unknown(   t
   autoescapet   use_l10nt   use_tzt   template_namet   RenderContextt   render_contextR   t   templateR   R=   R	   (   R   R   R?   R@   RA   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR	   ˜   s    					c         c   sA   |  j  d  k	 r t d ƒ ‚ n  | |  _  z	 d  VWd  d  |  _  Xd  S(   Ns&   Context is already bound to a template(   RE   R   t   RuntimeError(   R   RE   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   bind_template£   s    		c         C   s+   t  t |  ƒ j ƒ  } t |  j ƒ | _ | S(   N(   R   R=   R   R   RD   (   R   R   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR   ­   s    c         C   sP   t  | d ƒ s t d ƒ ‚ n  t | t ƒ rC | j d j ƒ  } n  t |  | ƒ S(   s=   Pushes other_dict to the stack of dictionaries in the ContextR*   s6   other_dict must be a mapping (dictionary-like) object.i   (   t   hasattrt	   TypeErrorR"   R   R
   R   R   (   R   t
   other_dict(    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR8   ²   s
    N(
   R   R   R   R   R   R	   R    RG   R   R8   (    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR=   –   s
   
	RC   c           B   sM   e  Z d  Z d Z d „  Z d „  Z d d „ Z d „  Z e	 e
 d „ ƒ Z RS(   sÈ  
    A stack container for storing Template state.

    RenderContext simplifies the implementation of template Nodes by providing a
    safe place to store state between invocations of a node's `render` method.

    The RenderContext also provides scoping rules that are more sensible for
    'template local' variables. The render context stack is pushed before each
    template is rendered, creating a fresh scope with nothing in it. Name
    resolution fails if a variable is not found at the top of the RequestContext
    stack. Thus, variables are local to a specific template and don't affect the
    rendering of other templates as they would if they were stored in the normal
    template context.
    c         c   s!   x |  j  d D] } | Vq Wd  S(   Niÿÿÿÿ(   R
   (   R   R    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR!   Ì   s    c         C   s   | |  j  d k S(   Niÿÿÿÿ(   R
   (   R   R%   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR0   Ð   s    c         C   s   |  j  d j | | ƒ S(   Niÿÿÿÿ(   R
   R2   (   R   R%   R1   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR2   Ó   s    c         C   s   |  j  d | S(   Niÿÿÿÿ(   R
   (   R   R%   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR*   Ö   s    c         c   sR   |  j  } | |  _  | r% |  j ƒ  n  z	 d  VWd  | |  _  | rM |  j ƒ  n  Xd  S(   N(   RE   R#   R   (   R   RE   t   isolated_contextt   initial(    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt
   push_stateÙ   s    				N(   R   R   R   R   RE   R!   R0   R2   R*   R    R   RM   (    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyRC   »   s   			t   RequestContextc           B   sA   e  Z d  Z d d d d e d „ Z e d „  ƒ Z d d „ Z RS(   sù   
    This subclass of template.Context automatically populates itself using
    the processors defined in the engine's configuration.
    Additional processors can be specified as a list of callables
    using the "processors" keyword argument.
    c         C   s‚   t  t |  ƒ j | d | d | d | ƒ| |  _ | d  k rC d n	 t | ƒ |  _ t |  j ƒ |  _	 |  j
 i  ƒ |  j
 i  ƒ d  S(   NR@   RA   R?   (    (   R   RN   R	   t   requestR   t   tuplet   _processorsR$   R
   t   _processors_indexR8   (   R   RO   R   t
   processorsR@   RA   R?   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR	   î   s    	!c         c   s¡   |  j  d  k	 r t d ƒ ‚ n  | |  _  | j j |  j } i  } x$ | D] } | j | |  j ƒ ƒ qG W| |  j |  j	 <z	 d  VWd  d  |  _  i  |  j |  j	 <Xd  S(   Ns&   Context is already bound to a template(
   RE   R   RF   t   enginet   template_context_processorsRQ   R8   RO   R
   RR   (   R   RE   RS   t   updatest	   processor(    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyRG   ü   s    		
		c         C   s4   t  t |  ƒ j | ƒ } t | d ƒ r0 | ` n  | S(   NRR   (   R   RN   R7   RH   RR   (   R   R5   R6   (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyR7     s    	N(	   R   R   R   R   R   R	   R    RG   R7   (    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyRN   ç   s   c         K   s‚   |  d k	 r5 t |  t ƒ r5 t d |  j j ƒ ‚ n  | d k rS t |  |  }  n+ |  } t | |  }  | r~ |  j | ƒ n  |  S(   sT   
    Create a suitable Context from a plain dict and optionally an HttpRequest.
    s&   context must be a dict rather than %s.N(	   R   R"   t   dictRI   R.   R   R=   RN   R#   (   R   RO   R   t   original_context(    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   make_context  s    (   s'   django.template.context_processors.csrf(   R,   t
   contextlibR    R   t   django.utils.deprecationR   t   _builtin_context_processorst	   ExceptionR   RX   R   t   objectR   R=   RC   RN   R   RZ   (    (    (    sA   /usr/local/lib/python2.7/dist-packages/django/template/context.pyt   <module>   s   x%,3