ó
TRšNc           @   s   d  Z  d d l m Z d d l m Z d d l m Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d e f d     YZ d e f d     YZ d S(   s(  
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 setting TEMPLATE_CONTEXT_PROCESSORS and used by
RequestContext.
i˙˙˙˙(   t   settings(   t	   get_token(   t   lazyc         C   s6   d d l  } | j d t  d d l m } | |   S(   sč   
    DEPRECATED. This context processor is the old location, and has been moved
    to `django.contrib.auth.context_processors`.

    This function still exists for backwards-compatibility; it will be removed
    in Django 1.4.
    i˙˙˙˙Ns   The context processor at `django.core.context_processors.auth` is deprecated; use the path `django.contrib.auth.context_processors.auth` instead.(   t   auth(   t   warningst   warnt   PendingDeprecationWarningt&   django.contrib.auth.context_processorsR   (   t   requestR   t   auth_context_processor(    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyR      s    c            s,     f d   } t  | t  } i |   d 6S(   s    
    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(   Nt   NOTPROVIDED(   R   t   None(   t   token(   R   (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyt   _get_val%   s    t
   csrf_token(   R   t   str(   R   R   (    (   R   sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyt   csrf    s    	c         C   sX   i  } t  j rT |  j j d  t  j k rT t | d <d d l m } | j | d <n  | S(   s0   Returns context variables helpful for debugging.t   REMOTE_ADDRt   debugi˙˙˙˙(   t
   connectiont   sql_queries(	   R    t   DEBUGt   METAt   gett   INTERNAL_IPSt   Truet	   django.dbR   t   queries(   R   t   context_extrasR   (    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyR   2   s    $
c         C   sG   d d l  m } i  } t j | d <| j   | d <| j   | d <| S(   Ni˙˙˙˙(   t   translationt	   LANGUAGESt   LANGUAGE_CODEt   LANGUAGE_BIDI(   t   django.utilsR   R    R   t   get_languaget   get_language_bidi(   R   R   R   (    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyt   i18n;   s    c         C   s   i t  j d 6S(   s?   
    Adds media-related context variables to the context.

    t	   MEDIA_URL(   R    R%   (   R   (    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyt   mediaE   s    c         C   s   i |  d 6S(   NR   (    (   R   (    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyR   L   s    t   PermLookupDictc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s   | | |  _  |  _ d  S(   N(   t   usert   module_name(   t   selfR(   R)   (    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyt   __init__S   s    c         C   s   t  |  j j    S(   N(   R   R(   t   get_all_permissions(   R*   (    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyt   __repr__V   s    c         C   s   |  j  j d |  j | f  S(   Ns   %s.%s(   R(   t   has_permR)   (   R*   t	   perm_name(    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyt   __getitem__Y   s    c         C   s   |  j  j |  j  S(   N(   R(   t   has_module_permsR)   (   R*   (    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyt   __nonzero__\   s    (   t   __name__t
   __module__R+   R-   R0   R2   (    (    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyR'   R   s   			t   PermWrapperc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s   | |  _  d  S(   N(   R(   (   R*   R(   (    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyR+   `   s    c         C   s   t  |  j |  S(   N(   R'   R(   (   R*   R)   (    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyR0   c   s    c         C   s   t  d   d  S(   Ns   PermWrapper is not iterable.(   t	   TypeError(   R*   (    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyt   __iter__f   s    (   R3   R4   R+   R0   R7   (    (    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyR5   _   s   		N(   t   __doc__t   django.confR    t   django.middleware.csrfR   t   django.utils.functionalR   R   R   R   R$   R&   R   t   objectR'   R5   (    (    (    sK   /home/panlixing/Python_Projects/gaeseries/django/core/context_processors.pyt   <module>   s   					
		