o
    <gS
                     @   s   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 dd	Zee
jd
d Zee
jdddd Zee
jdd ZdS )    N)settings)DEFAULT_CACHE_ALIAScaches)FileBasedCache   )ErrorTagsWarningregisterz4You must define a '%s' cache in your CACHES setting.zcaches.E001idc                 K   s   t tjvrtgS g S N)r   r   CACHESE001)app_configskwargs r   L/var/www/html/venv/lib/python3.10/site-packages/django/core/checks/caches.py!check_default_cache_is_configured   s   
r   T)deployc                    s$  g }dD ]}t t|d }|sq|dkr1t }|D ]}t|ttfr%|\}}|t|	  qnt|	 h}tj
D ]R}t| }	t|	tsHq<t|	j	  t fdd|D r^d}
nt fdd|D rld}
nt fdd|D rzd	}
nq<|td
| d|
 d| ddd q<q|S )N)
MEDIA_ROOTSTATIC_ROOTSTATICFILES_DIRSr   c                 3   s    | ]}| kV  qd S r   r   .0path
cache_pathr   r   	<genexpr>*   s    z3check_cache_location_not_exposed.<locals>.<genexpr>matchesc                 3   s    | ]}| j v V  qd S r   parentsr   r   r   r   r   ,       z	is insidec                 3   s    | ]} |j v V  qd S r   r    r   r   r   r   r   .   r"   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   r   r    check_cache_location_not_exposed   sJ   

r<   c                 K   s\   g }t j D ]$\}}t| }t|tsqt|d  s+|	t
d| ddd q|S )NLOCATIONr$   z@' cache LOCATION path is relative. Use an absolute path instead.zcaches.W003r   )r   r   itemsr   r)   r   r-   r.   is_absoluter2   r	   )r   r   r3   r9   configr:   r   r   r   "check_file_based_cache_is_absolute=   s   

rA   )r-   django.confr   django.core.cacher   r   $django.core.cache.backends.filebasedr    r   r   r	   r
   r   r   r<   rA   r   r   r   r   <module>   s    

&