
vÅÏ^g	  ã               @   s    d  Z  d d l Z d d l m Z d d l m Z d d l m Z m Z d d „  Z	 d d	 „  Z
 d
 d „  Z d d „  Z d d „  Z d d „  Z d d „  Z d S)aR  
A set of request processors that return dictionaries to be merged into a
template context. Each function takes the request object as its only parameter
and returns a dictionary to add to the context.

These are referenced from the 'context_processors' option of the configuration
of a DjangoTemplates backend and used by RequestContext.
é    N)Úsettings)Ú	get_token)ÚSimpleLazyObjectÚlazyc                s"   ‡  f d d †  } d t  | ƒ i S)z 
    Context processor that provides a CSRF token, or the string 'NOTPROVIDED' if
    it has not been provided by either a view decorator or the middleware
    c                 s$   t  ˆ  ƒ }  |  d  k r d S|  Sd  S)NZNOTPROVIDED)r   )Útoken)Úrequest© úD/tmp/pip-build-8lau8j11/django/django/template/context_processors.pyÚ_get_val   s    zcsrf.<locals>._get_valZ
csrf_token)r   )r   r
   r   )r   r	   Úcsrf   s    
r   c                sg   i  } t  j rc |  j j d ƒ t  j k rc d | d <d d l m ‰  t ‡  f d d †  t ƒ | d <| S)	z9
    Return context variables helpful for debugging.
    ZREMOTE_ADDRTÚdebugr   )Úconnectionsc                  s)   t  t j j ‡  f d d †  ˆ  Dƒ ƒ ƒ S)Nc             3   s   |  ] } ˆ  | j  Vq d  S)N)Zqueries)Ú.0Úx)r   r   r	   ú	<genexpr>.   s    z*debug.<locals>.<lambda>.<locals>.<genexpr>)ÚlistÚ	itertoolsÚchainÚfrom_iterabler   )r   r   r	   Ú<lambda>.   s    zdebug.<locals>.<lambda>Zsql_queries)	r   ÚDEBUGZMETAÚgetZINTERNAL_IPSZ	django.dbr   r   r   )r   Zcontext_extrasr   )r   r	   r   #   s    $
r   c             C   s5   d d l  m } d t j d | j ƒ  d | j ƒ  i S)Nr   )ÚtranslationÚ	LANGUAGESZLANGUAGE_CODEZLANGUAGE_BIDI)Údjango.utilsr   r   r   Zget_languageZget_language_bidi)r   r   r   r   r	   Úi18n4   s    	r   c             C   s    d d l  m } d | j ƒ  i S)Nr   )ÚtimezoneZ	TIME_ZONE)r   r   Zget_current_timezone_name)r   r   r   r   r	   Útz=   s    r   c             C   s   d t  j i S)z>
    Add static-related context variables to the context.
    Ú
STATIC_URL)r   r   )r   r   r   r	   ÚstaticB   s    r   c             C   s   d t  j i S)z=
    Add media-related context variables to the context.
    Ú	MEDIA_URL)r   r    )r   r   r   r	   ÚmediaI   s    r!   c             C   s
   d |  i S)Nr   r   )r   r   r   r	   r   P   s    r   )Ú__doc__r   Zdjango.confr   Zdjango.middleware.csrfr   Zdjango.utils.functionalr   r   r   r   r   r   r   r!   r   r   r   r   r	   Ú<module>   s   	