
    h$                         S SK Jr  S SKJr  Sr " S S\5      r " S S\5      r " S S	5      r " S
 S\5      r	 " S S\5      r
 " S S\	5      rSS jrg)    )contextmanager)copy)z'django.template.context_processors.csrfc                       \ rS rSrSrSrg)ContextPopException   z,pop() has been called more times than push() N)__name__
__module____qualname____firstlineno____doc____static_attributes__r       I/var/www/html/env/lib/python3.13/site-packages/django/template/context.pyr   r      s    2r   r   c                   4   ^  \ rS rSrU 4S jrS rS rSrU =r$ )ContextDict   c                 h   > [         TU ]  " U0 UD6  UR                  R                  U 5        Xl        g N)super__init__dictsappendcontext)selfr   argskwargs	__class__s       r   r   ContextDict.__init__   s,    $)&)T"r   c                     U $ r   r   r   s    r   	__enter__ContextDict.__enter__   s    r   c                 8    U R                   R                  5         g r   )r   pop)r   r   r   s      r   __exit__ContextDict.__exit__   s    r   )r   )	r	   r
   r   r   r   r"   r&   r   __classcell__r   s   @r   r   r      s     r   r   c                      ^  \ rS rSrSS jrSS jrU 4S jrS rS rS r	S r
S	 rS
 rS rS rS rSS jrSS jrSS jrS rS rSrU =r$ )BaseContext   c                 &    U R                  U5        g r   )_reset_dicts)r   dict_s     r   r   BaseContext.__init__   s    % r   c                     SSS S.nU/U l         [        U[        5      (       a#  U =R                   UR                   SS  -  sl         g Ub  U R                   R                  U5        g g )NTF)TrueFalseNone   )r   
isinstancer+   r   )r   valuebuiltinss      r   r.   BaseContext._reset_dicts   sY     5$?Z
e[))JJ%++ab/)JJJe$ r   c                 V   > [        [        5       5      nU R                  S S  Ul        U$ r   )r   r   r   r   	duplicater   s     r   __copy__BaseContext.__copy__'   s#    M	**Q-	r   c                 ,    [        U R                  5      $ r   )reprr   r!   s    r   __repr__BaseContext.__repr__,   s    DJJr   c                 ,    [        U R                  5      $ r   reversedr   r!   s    r   __iter__BaseContext.__iter__/   s    

##r   c                     / nU H<  n[        U[        5      (       a  X4R                  SS  -  nM+  UR                  U5        M>     [	        U /UQ70 UD6$ Nr5   )r6   r+   r   r   r   )r   r   r   r   ds        r   pushBaseContext.push2   sR    A![))$Q	 
 42%2622r   c                 t    [        U R                  5      S:X  a  [        eU R                  R                  5       $ rI   )lenr   r   r%   r!   s    r   r%   BaseContext.pop;   s)    tzz?a%%zz~~r   c                 &    X R                   S   U'   g)z%Set a variable in the current contextNr   )r   keyr7   s      r   __setitem__BaseContext.__setitem__@   s    #

2sr   c                 t    U R                   S   n[        U R                   5       H  nX;   d  M
  Un  O   X#U'   g)zd
Set a variable in one of the higher contexts if it exists there,
otherwise in the current context.
rQ   N)r   rE   )r   rS   r7   r   rJ   s        r   
set_upwardBaseContext.set_upwardD   s:    
 **R.$**%Ax & r   c                 f    [        U R                  5       H  nX;   d  M
  X!   s  $    [        U5      e)zHGet a variable's value, starting at the current context and going upward)rE   r   KeyError)r   rS   rJ   s      r   __getitem__BaseContext.__getitem__P   s-    $**%Axv & smr   c                 $    U R                   S   U	 g)z*Delete a variable from the current contextrQ   NrR   r   rS   s     r   __delitem__BaseContext.__delitem__W   s    JJrN3r   c                 B   ^ [        U4S jU R                   5       5      $ )Nc              3   .   >#    U  H
  nTU;   v   M     g 7fr   r   ).0rJ   rS   s     r   	<genexpr>+BaseContext.__contains__.<locals>.<genexpr>\   s     0Z3!8Zs   )anyr   r^   s    `r   __contains__BaseContext.__contains__[   s    0TZZ000r   c                 T    [        U R                  5       H  nX;   d  M
  X1   s  $    U$ r   rD   )r   rS   	otherwiserJ   s       r   getBaseContext.get^   s)    $**%Axv & r   c                 6     X   $ ! [          a    X U'    U$ f = fr   )rZ   )r   rS   defaults      r   
setdefaultBaseContext.setdefaultd   s*    	 9 	 I	 s    c                 >    [        U 5      nUR                  U5        U$ )zc
Return a new context with the same properties, but with only the
values given in 'values' stored.
)r   r.   )r   valuesnew_contexts      r   newBaseContext.newk   s!    
 4j  (r   c                 R    0 nU R                    H  nUR                  U5        M     U$ )z&
Return self.dicts as one dictionary.
)r   update)r   flatrJ   s      r   flattenBaseContext.flattent   s'     AKKN r   c                 z    [        U[        5      (       d  [        $ U R                  5       UR                  5       :H  $ )z>
Compare two contexts by comparing theirs 'dicts' attributes.
)r6   r+   NotImplementedry   )r   others     r   __eq__BaseContext.__eq__}   s.     %--!!||~00r   rR   r   )r	   r
   r   r   r   r.   r=   rA   rF   rK   r%   rT   rW   r[   r_   rg   rk   ro   rt   ry   r~   r   r(   r)   s   @r   r+   r+      s]    !%
 $3 
$
 11 1r   r+   c                   R   ^  \ rS rSrSrSU 4S jjr\S 5       rU 4S jrS r	Sr
U =r$ )	Context   z&A stack container for variable contextc                    > X l         X0l        X@l        SU l        [	        5       U l        S U l        [        TU ]!  U5        g )Nunknown)	
autoescapeuse_l10nuse_tztemplate_nameRenderContextrender_contexttemplater   r   )r   r/   r   r   r   r   s        r   r   Context.__init__   s:    $ &+o r   c              #   x   #    U R                   b  [        S5      eXl          S v   S U l         g ! S U l         f = f7f)N&Context is already bound to a template)r   RuntimeError)r   r   s     r   bind_templateContext.bind_template   s6     ==$GHH 	! DMDDMs   :. :	7:c                 X   > [         TU ]  5       n[        U R                  5      Ul        U$ r   )r   r=   r   r   r;   s     r   r=   Context.__copy__   s)    G$&	#'(;(;#<	 r   c                     [        US5      (       d  [        S5      e[        U[        5      (       a  UR                  SS R                  5       n[        X5      $ )z;Push other_dict to the stack of dictionaries in the Contextr[   z6other_dict must be a mapping (dictionary-like) object.r5   N)hasattr	TypeErrorr6   r+   r   r%   r   )r   
other_dicts     r   rw   Context.update   sN    z=11TUUj+..#))!"-113J4,,r   )r   r   r   r   r   r   )NTNN)r	   r
   r   r   r   r   r   r   r=   rw   r   r(   r)   s   @r   r   r      s.    ,	  ! !
- -r   r   c                   L    \ rS rSrSrSrS rS rS
S jrS r	\
SS j5       rS	rg)r      a  
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.
Nc              #   >   #    U R                   S    S h  vN   g  N7fNrQ   rR   r!   s    r   rF   RenderContext.__iter__   s     ::b>!!s   c                 $    XR                   S   ;   $ r   rR   r^   s     r   rg   RenderContext.__contains__   s    jjn$$r   c                 >    U R                   S   R                  X5      $ r   )r   rk   )r   rS   rj   s      r   rk   RenderContext.get   s    zz"~!!#11r   c                 &    U R                   S   U   $ r   rR   r^   s     r   r[   RenderContext.__getitem__   s    zz"~c""r   c              #      #    U R                   nXl         U(       a  U R                  5          S v   X0l         U(       a  U R                  5         g g ! X0l         U(       a  U R                  5         f f = f7fr   )r   rK   r%   )r   r   isolated_contextinitials       r   
push_stateRenderContext.push_state   sV     -- IIK	#M
   $M
  s   *A3A A3 A00A3)r   r   )T)r	   r
   r   r   r   r   rF   rg   rk   r[   r   r   r   r   r   r   r   r      s6     H"%2# 
 
r   r   c                   Z   ^  \ rS rSrSr     SU 4S jjr\S 5       rSU 4S jjrSr	U =r
$ )	RequestContext   z
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                    > [         TU ]  X$XVS9  Xl        Uc  SO
[        U5      U l        [        U R                  5      U l        U R                  0 5        U R                  0 5        g )N)r   r   r   r   )	r   r   requesttuple_processorsrN   r   _processors_indexrw   )r   r   r/   
processorsr   r   r   r   s          r   r   RequestContext.__init__   sZ     	&X!+!32z9J!$TZZ 	B 	Br   c              #     #    U R                   b  [        S5      eXl         UR                  R                  U R                  -   n0 nU H'  nU" U R
                  5      n UR                  U5        M)     X0R                  U R                  '    S v   S U l         0 U R                  U R                  '   g ! [         a  n[        SUR                   S35      UeS nAff = f! S U l         0 U R                  U R                  '   f = f7f)Nr   zContext processor z didn't return a dictionary.)r   r   enginetemplate_context_processorsr   r   rw   r   r   r   r   )r   r   r   updates	processorr   es          r   r   RequestContext.bind_template   s     ==$GHH __@@4CSCSS
#I-Gw' $ .5

4))*	4 DM13DJJt--.  ()?)?(@ A" "  !DM13DJJt--.sB   ADB1/DC !D1
C;CCD"C??Dc                 L   > [         TU ]  U5      n[        US5      (       a  U?U$ )Nr   )r   rt   r   r   )r   rr   rs   r   s      r   rt   RequestContext.new  s-    gk&) ; 344-r   )r   r   r   r   )NNNNTr   )r	   r
   r   r   r   r   r   r   rt   r   r(   r)   s   @r   r   r      s<     * 4 46 r   r   Nc                     U b7  [        U [        5      (       d"  [        SU R                  R                  -  5      eUc  [        U 40 UD6n U $ U n[        U40 UD6n U(       a  U R                  U5        U $ )zL
Create a suitable Context from a plain dict and optionally an HttpRequest.
z&context must be a dict rather than %s.)r6   dictr   r   r	   r   r   rK   )r   r   r   original_contexts       r   make_contextr     s     :gt#<#<4w7H7H7Q7QQ
 	
 ',V, N	 # 3F3LL)*Nr   r   )
contextlibr   r   _builtin_context_processors	Exceptionr   r   r   r+   r   r   r   r   r   r   r   <module>r      se    %  K 	) 	
$ i1 i1X#-k #-L)K )X?W ?Dr   