o 3a )@sdZddlZddlZddlZddlZddlZddlmZddlZddl m Z ddl m Z ddl mZddlmZmZdZd Zd ZGd d d eZGd ddeZGdddZGdddZeZdS)z Settings and configuration for Django. Read values from the module specified by the DJANGO_SETTINGS_MODULE environment variable, and then from django.conf.global_settings; see the global_settings.py for a list of all possible variables. N)Path)global_settings)ImproperlyConfigured)RemovedInDjango40Warning) LazyObjectemptyDJANGO_SETTINGS_MODULEzZThe PASSWORD_RESET_TIMEOUT_DAYS setting is deprecated. Use PASSWORD_RESET_TIMEOUT instead.zThe DEFAULT_HASHING_ALGORITHM transitional setting is deprecated. Support for it and tokens, cookies, sessions, and signatures that use SHA-1 hashing algorithm will be removed in Django 4.0.c@s eZdZdZddZddZdS)SettingsReferencez String subclass which references a current settings value. It's treated as the value in memory but serializes to a settings.NAME attribute reference. cCs t||SN)str__new__selfvalue setting_namer6/usr/lib/python3/dist-packages/django/conf/__init__.pyr )s zSettingsReference.__new__cCs ||_dSr )rr rrr__init__, zSettingsReference.__init__N)__name__ __module__ __qualname____doc__r rrrrrr $s r csveZdZdZdddZddZddZfd d Zfd d Ze fd dZ e ddZ e ddZe ddZZS) LazySettingsz 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. NcCs>tjt}|s|rd|nd}td|tft||_dS)z Load the settings module pointed to by the environment variable. This is used the first time settings are needed, if the user hasn't configured settings manually. z setting %ssettingszRequested %s, but settings are not configured. You must either define the environment variable %s or call settings.configure() before accessing settings.N)osenvirongetENVIRONMENT_VARIABLErSettings_wrapped)rnamesettings_moduledescrrr_setup6s zLazySettings._setupcCs|jturdSdd|jjiS)Nzz$r")r rSETTINGS_MODULErrrr__repr__Gs zLazySettings.__repr__cCs^|jtur ||t|j|}|dvr|dur||}n |dkr(|s(td||j|<|S)z MEDIA_URL STATIC_URLN SECRET_KEYz)The SECRET_KEY setting must not be empty.)r rr$getattr_add_script_prefixr__dict__)rr!valrrr __getattr__Os      zLazySettings.__getattr__cs4|dkr |jn|j|dt||dS)z Set the value of setting. Clear all cached values if _wrapped changes (@override_settings does this) or clear single values when set. r N)r-clearpopsuper __setattr__rr!r __class__rrr3_s zLazySettings.__setattr__cst||j|ddS)z3Delete a setting and clear it from cache if needed.N)r2 __delattr__r-r1rr!r5rrr7js zLazySettings.__delattr__cKsV|jtur tdt|}|D]\}}|std|t|||q||_dS)z 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__)). zSettings already configured.zSetting %r must be uppercase.N)r r RuntimeErrorUserSettingsHolderitemsisupper TypeErrorsetattr)rdefault_settingsoptionsholderr!rrrr configureos   zLazySettings.configurecCs(|dr|Sddlm}d||fS)z Add SCRIPT_NAME prefix to relative paths. Useful when the app is being served at a subpath and manually prefixing subpath to STATIC_URL and MEDIA_URL in settings is inconvenient. )zhttp://zhttps:///r)get_script_prefixz%s%s) startswith django.urlsrD)rrDrrrr,~s  zLazySettings._add_script_prefixcCs |jtuS)z9Return True if the settings have already been configured.)r rr&rrr configureds zLazySettings.configuredcCsFt}|d\}}}}|tjtjstj t t dd| dS)N) stacklevelPASSWORD_RESET_TIMEOUT_DAYS) traceback extract_stackrErpathdirnamedjango__file__warningswarn*PASSWORD_RESET_TIMEOUT_DAYS_DEPRECATED_MSGrr/)rstackfilename_rrrrKs z(LazySettings.PASSWORD_RESET_TIMEOUT_DAYSr )rrrrr$r'r/r3r7rrB staticmethodr,propertyrGrK __classcell__rrr5rr0s     rc@s$eZdZddZddZddZdS)rcCs`ttD]}|rt||tt|q||_t|j}d}t|_ t|D](}|rOt||}||vrCt |t t fsCt d|t||||j |q'|drq|dr^t dt|d|jdddttt|dr|tttttd r|jrtd }|j|jd }|r|std |j|jtjd <t dSdSdS)N)INSTALLED_APPS TEMPLATE_DIRS LOCALE_PATHSz*The %s setting must be a list or a tuple. rKPASSWORD_RESET_TIMEOUTzJPASSWORD_RESET_TIMEOUT_DAYS/PASSWORD_RESET_TIMEOUT are mutually exclusive.<DEFAULT_HASHING_ALGORITHMtzsetz/usr/share/zoneinforCzIncorrect timezone setting: %sTZ)!dirrr<r>r+r% importlib import_moduleset_explicit_settings isinstancelisttupleradd is_overriddenrKrRrSrTr(DEFAULT_HASHING_ALGORITHM_DEPRECATED_MSGhasattrtime TIME_ZONErjoinpathsplitexists ValueErrorrrrb)rr"settingmodtuple_settings setting_value zoneinfo_rootzone_info_filerrrrsF               zSettings.__init__cCs ||jvSr )rh)rrvrrrrmrzSettings.is_overriddencCsd|jj|jdS)Nz<%(cls)s "%(settings_module)s">)clsr")r6rr%r&rrrr'szSettings.__repr__N)rrrrrmr'rrrrrs3 rcsXeZdZdZdZddZddZfddZfd d Zd d Z d dZ ddZ Z S)r:z$Holder for user configured settings.NcCst|jd<||_dS)z Requests for configuration variables not in this class are satisfied from the module specified in default_settings (if possible). _deletedN)rgr-r?)rr?rrrrs  zUserSettingsHolder.__init__cCs"|r ||jvr tt|j|Sr )r<r}AttributeErrorr+r?r8rrrr/s zUserSettingsHolder.__getattr__cs^|j||dkrt|d|dddttt|dkr&tttt ||dS)NrKr^r_r`ra) r}discardr>rRrSrTrrnr2r3r4r5rrr3s   zUserSettingsHolder.__setattr__cs*|j|t||rt|dSdSr )r}rlror2r7r8r5rrr7s  zUserSettingsHolder.__delattr__cs&tfddgjtjDS)Nc3s|] }|jvr|VqdSr )r}).0sr&rr s z-UserSettingsHolder.__dir__..)sortedr-rdr?r&rr&r__dir__s zUserSettingsHolder.__dir__cCs6||jv}||jv}t|jddd|}|p|p|S)NrmcSsdS)NFr)rrrrsz2UserSettingsHolder.is_overridden..)r}r-r+r?)rrvdeleted set_locallyset_on_defaultrrrrms   z UserSettingsHolder.is_overriddencCsdd|jjiS)Nz <%(cls)s>r|)r6rr&rrrr' szUserSettingsHolder.__repr__) rrrrr%rr/r3r7rrmr'rZrrr5rr:s  r:)rrerrprLrRpathlibrrP django.confrdjango.core.exceptionsrdjango.utils.deprecationrdjango.utils.functionalrrrrTrnr r rrr:rrrrrs,     p> 3