
    k"gS
                         d dl Z d dlmZ d dlmZmZ d dlmZ ddlm	Z	m
Z
mZmZ  e	dez  d	      Z ee
j
                        d
        Z ee
j
                  d      d        Z ee
j
                        d        Zy)    N)settings)DEFAULT_CACHE_ALIAScaches)FileBasedCache   )ErrorTagsWarningregisterz4You must define a '%s' cache in your CACHES setting.zcaches.E001idc                 @    t         t        j                  vrt        gS g S N)r   r   CACHESE001)app_configskwargss     R/var/www/html/djangosite/lib/python3.12/site-packages/django/core/checks/caches.py!check_default_cache_is_configuredr      s    (//1vI    T)deployc                    g }dD ]g  }t        t        |d       }|s|dk(  r_t               }|D ]O  }t        |t        t
        f      r|\  }}|j                  t        j                  |      j                                Q n$t        j                  |      j                         h}t        j                  D ]  }t        |   }	t        |	t              st        j                  |	j                        j                         t        fd|D              rd}
n/t        fd|D              rd}
nt        fd|D              rd}
n|j                  t!        d	| d
|
 d| dd              j |S )N)
MEDIA_ROOTSTATIC_ROOTSTATICFILES_DIRSr   c              3   (   K   | ]	  }|k(    y wr    .0path
cache_paths     r   	<genexpr>z3check_cache_location_not_exposed.<locals>.<genexpr>*   s     8$4:%8s   matchesc              3   :   K   | ]  }|j                   v   y wr   parentsr   s     r   r"   z3check_cache_location_not_exposed.<locals>.<genexpr>,   s     BDTZ///B   z	is insidec              3   :   K   | ]  }|j                   v   y wr   r%   r   s     r   r"   z3check_cache_location_not_exposed.<locals>.<genexpr>.   s     BDZ4<</Br'   containsYour 'zf' cache configuration might expose your cache or lead to corruption of your data because its LOCATION  .zcaches.W002r   )getattrr   set
isinstancelisttupleaddpathlibPathresolver   r   r   _diranyappendr
   )r   r   errorsnamesettingpathsstaticfiles_dir_aliascacherelationr!   s              @r    check_cache_location_not_exposedrB      s^   FA  (D$/%%EE#* Coe}=)8&A		',,7??ABC
 \\'*2245E__ 	E5MEe^4 ejj199;J8%88$BEBB&BEBB%MMUG $Oj$q* %		 B Mr   c                    g }t         j                  j                         D ]f  \  }}t        |   }t	        |t
              s t        j                  |d         j                         rG|j                  t        d| dd             h |S )NLOCATIONr*   z@' cache LOCATION path is relative. Use an absolute path instead.zcaches.W003r   )r   r   itemsr   r/   r   r3   r4   is_absoluter8   r
   )r   r   r9   r?   configr@   s         r   "check_file_based_cache_is_absoluterH   =   s    F!..0 vu%0||F:./;;=MMUG $- .$ Mr   )r3   django.confr   django.core.cacher   r   $django.core.cache.backends.filebasedr    r   r	   r
   r   r   r   rB   rH   r   r   r   <module>rM      s       9 ? , ,:=PP 
$++  
$++d## $#L 
$++ r   