ó
÷¢TQc           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m	 Z	 d d l
 m Z 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 e ƒ  Z d „  Z d S(   sù   
Settings and configuration for Django.

Values will be read from the module specified by the DJANGO_SETTINGS_MODULE environment
variable, and then from django.conf.global_settings; see the global settings file for
a list of all possible variables.
iÿÿÿÿN(   t   global_settings(   t   ImproperlyConfigured(   t
   LazyObjectt   empty(   t	   importlib(   t   sixt   DJANGO_SETTINGS_MODULEt   LazySettingsc           B   sG   e  Z d  Z d d „ Z d „  Z d „  Z e d „ Z e	 d „  ƒ Z
 RS(   sì   
    A lazy proxy for either global Django settings or a custom settings object.
    The user can manually configure settings prior to using them. Otherwise,
    Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
    c         C   s}   y  t  j t } | s t ‚ n  Wn= t k
 r_ | r@ d | n d } t d | t f ƒ ‚ n Xt | ƒ |  _ |  j ƒ  d S(   sÜ   
        Load the settings module pointed to by the environment variable. This
        is used the first time we need any settings at all, if the user has not
        previously configured the settings manually.
        s
   setting %st   settingss™   Requested %s, but settings are not configured. You must either define the environment variable %s or call settings.configure() before accessing settings.N(   t   ost   environt   ENVIRONMENT_VARIABLEt   KeyErrorR   t   Settingst   _wrappedt   _configure_logging(   t   selft   namet   settings_modulet   desc(    (    s-   ../Django//lib/python/django/conf/__init__.pyt   _setup   s    c         C   s/   |  j  t k r |  j | ƒ n  t |  j  | ƒ S(   N(   R   R   R   t   getattr(   R   R   (    (    s-   ../Django//lib/python/django/conf/__init__.pyt   __getattr__3   s    c         C   sÊ   t  j sA y! t j t ƒ t j d t ƒ WqA t k
 r= qA Xn  |  j	 rÆ d d l
 m } |  j	 j d d ƒ \ } } t j | ƒ } t | | ƒ } | | ƒ |  j rÆ t |  j ƒ | |  j ƒ qÆ n  d S(   sI   
        Setup logging from LOGGING_CONFIG and LOGGING settings.
        t   defaultiÿÿÿÿ(   t   DEFAULT_LOGGINGt   .i   N(   t   syst   warnoptionst   loggingt   captureWarningst   Truet   warningst   simplefiltert   DeprecationWarningt   AttributeErrort   LOGGING_CONFIGt   django.utils.logR   t   rsplitR   t   import_moduleR   t   LOGGINGt   compat_patch_logging_config(   R   R   t   logging_config_patht   logging_config_func_namet   logging_config_modulet   logging_config_func(    (    s-   ../Django//lib/python/django/conf/__init__.pyR   8   s    		
	c         K   sn   |  j  t k	 r t d ƒ ‚ n  t | ƒ } x* | j ƒ  D] \ } } t | | | ƒ q7 W| |  _  |  j ƒ  d S(   sÜ   
        Called to manually configure the settings. The 'default_settings'
        parameter sets where to retrieve any unspecified values from (its
        argument must support attribute access (__getattr__)).
        s   Settings already configured.N(   R   R   t   RuntimeErrort   UserSettingsHoldert   itemst   setattrR   (   R   t   default_settingst   optionst   holderR   t   value(    (    s-   ../Django//lib/python/django/conf/__init__.pyt	   configureV   s    	c         C   s   |  j  t k	 S(   sL   
        Returns True if the settings have already been configured.
        (   R   R   (   R   (    (    s-   ../Django//lib/python/django/conf/__init__.pyt
   configuredd   s    N(   t   __name__t
   __module__t   __doc__t   NoneR   R   R   R    R5   t   propertyR6   (    (    (    s-   ../Django//lib/python/django/conf/__init__.pyR      s   		t   BaseSettingsc           B   s   e  Z d  Z d „  Z RS(   sK   
    Common logic for settings whether set by a module or by the user.
    c         C   sy   | d k r5 | r5 | j  d ƒ r5 t d | ƒ ‚ n- | d k rb t | t j ƒ rb t d ƒ ‚ n  t j |  | | ƒ d  S(   Nt	   MEDIA_URLt
   STATIC_URLt   /s    If set, %s must end with a slasht   ALLOWED_INCLUDE_ROOTSsG   The ALLOWED_INCLUDE_ROOTS setting must be set to a tuple, not a string.(   R=   R>   (   t   endswithR   t
   isinstanceR   t   string_typest
   ValueErrort   objectt   __setattr__(   R   R   R4   (    (    s-   ../Django//lib/python/django/conf/__init__.pyRF   p   s
    "(   R7   R8   R9   RF   (    (    (    s-   ../Django//lib/python/django/conf/__init__.pyR<   l   s   R   c           B   s   e  Z d  „  Z RS(   c         C   sÏ  xB t  t ƒ D]4 } | | j ƒ  k r t |  | t t | ƒ ƒ q q W| |  _ y t j |  j ƒ } Wn, t k
 r’ } t d |  j | f ƒ ‚ n Xd } x† t  | ƒ D]x } | | j ƒ  k r¦ t | | ƒ } | | k rt	 | t
 j ƒ rt j d | t ƒ | f } n  t |  | | ƒ q¦ q¦ W|  j s:t d ƒ ‚ n  t t d ƒ rË|  j rËd } t j j | ƒ r®t j j t j j | |  j j d ƒ Œ ƒ r®t d	 |  j ƒ ‚ n  |  j t j d
 <t j ƒ  n  d  S(   Ns7   Could not import settings '%s' (Is it on sys.path?): %st   INSTALLED_APPSt   TEMPLATE_DIRSs_   The %s setting must be a tuple. Please fix your settings, as auto-correction is now deprecated.s)   The SECRET_KEY setting must not be empty.t   tzsets   /usr/share/zoneinfoR?   s   Incorrect timezone setting: %st   TZ(   RG   RH   (   t   dirR    t   upperR0   R   t   SETTINGS_MODULER   R&   t   ImportErrorRB   R   RC   R   t   warnt   PendingDeprecationWarningt
   SECRET_KEYR   t   hasattrt   timet	   TIME_ZONER	   t   patht   existst   joint   splitRD   R
   RI   (   R   R   t   settingt   modt   et   tuple_settingst   setting_valuet   zoneinfo_root(    (    s-   ../Django//lib/python/django/conf/__init__.pyt   __init__z   s8     			.(   R7   R8   R_   (    (    (    s-   ../Django//lib/python/django/conf/__init__.pyR   y   s   R.   c           B   sA   e  Z d  Z d Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   s.   
    Holder for user configured settings.
    c         C   s   t  ƒ  |  j d <| |  _ d S(   s›   
        Requests for configuration variables not in this class are satisfied
        from the module specified in default_settings (if possible).
        t   _deletedN(   t   sett   __dict__R1   (   R   R1   (    (    s-   ../Django//lib/python/django/conf/__init__.pyR_   ¯   s    c         C   s(   | |  j  k r t ‚ n  t |  j | ƒ S(   N(   R`   R"   R   R1   (   R   R   (    (    s-   ../Django//lib/python/django/conf/__init__.pyR   ·   s    	c         C   s)   |  j  j | ƒ t t |  ƒ j | | ƒ S(   N(   R`   t   discardt   superR.   RF   (   R   R   R4   (    (    s-   ../Django//lib/python/django/conf/__init__.pyRF   ¼   s    c         C   s&   |  j  j | ƒ t t |  ƒ j | ƒ S(   N(   R`   t   addRd   R.   t   __delattr__(   R   R   (    (    s-   ../Django//lib/python/django/conf/__init__.pyRf   À   s    c         C   s   t  |  j ƒ t |  j ƒ S(   N(   t   listRb   RK   R1   (   R   (    (    s-   ../Django//lib/python/django/conf/__init__.pyt   __dir__Ä   s    N(
   R7   R8   R9   R:   RM   R_   R   RF   Rf   Rh   (    (    (    s-   ../Django//lib/python/django/conf/__init__.pyR.   §   s   				c         C   s   d |  j  d i  ƒ j  d i g  d 6ƒ k r™ t j d t ƒ d } |  j d i  ƒ } x | | k ro | d } qV Wi d d 6| | <| g |  d d d <n  d	 S(
   sã   
    Backwards-compatibility shim for #16288 fix. Takes initial value of
    ``LOGGING`` setting and patches it in-place (issuing deprecation warning)
    if "mail_admins" logging handler is configured but has no filters.

    t   filterst   handlerst   mail_adminssÊ   You have no filters defined on the 'mail_admins' logging handler: adding implicit debug-false-only filter. See http://docs.djangoproject.com/en/dev/releases/1.4/#request-exceptions-are-now-always-loggedt   require_debug_falset   _s"   django.utils.log.RequireDebugFalses   ()N(   t   getR   RO   R!   t
   setdefault(   t   logging_configt   filter_nameRi   (    (    s-   ../Django//lib/python/django/conf/__init__.pyR(   Ë   s    		(   R9   R   R	   R   RS   R   t   django.confR    t   django.core.exceptionsR   t   django.utils.functionalR   R   t   django.utilsR   R   R   R   RE   R<   R   R.   R   R(   (    (    (    s-   ../Django//lib/python/django/conf/__init__.pyt   <module>   s"   T. 	