3
g	                 @   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krtgS g S )N)r   r   CACHESE001)app_configskwargs r   W/var/www/tester-filtro-web/env/lib/python3.6/site-packages/django/core/checks/caches.py!check_default_cache_is_configured   s    
r   T)Zdeployc                s4  g }x(dD ]}t t|d }|s$q|dkrlt }xH|D ].}t|ttfrR|\}}|jtj|j	  q8W ntj|j	 h}xtj
D ]}t| }	t|	tsqtj|	jj	  t fdd|D rd}
n:t fdd|D rd}
nt fd	d|D rd
}
nq|jtd| d|
 d| ddd qW qW |S )N
MEDIA_ROOTSTATIC_ROOTSTATICFILES_DIRSc             3   s   | ]}| kV  qd S )Nr   ).0path)
cache_pathr   r   	<genexpr>*   s    z3check_cache_location_not_exposed.<locals>.<genexpr>matchesc             3   s   | ]}| j kV  qd S )N)parents)r   r   )r   r   r   r   ,   s    z	is insidec             3   s   | ]} |j kV  qd S )N)r   )r   r   )r   r   r   r   .   s    containszYour 'zf' cache configuration might expose your cache or lead to corruption of your data because its LOCATION  .zcaches.W002)r   )r   r   r   )getattrr   set
isinstancelisttupleaddpathlibPathresolver   r   r   Z_diranyappendr	   )r   r   errorsnameZsettingpathsZstaticfiles_dir_aliascacheZrelationr   )r   r    check_cache_location_not_exposed   s8    

r0   c             K   s`   g }xVt jj D ]H\}}t| }t|ts,qtj|d j s|j	t
d| ddd qW |S )NZLOCATIONzYour 'z@' cache LOCATION path is relative. Use an absolute path instead.zcaches.W003)r   )r   r   itemsr   r!   r   r%   r&   is_absoluter)   r	   )r   r   r*   r.   configr/   r   r   r   "check_file_based_cache_is_absolute;   s    

r4   )r%   Zdjango.confr   Zdjango.core.cacher   r   Z$django.core.cache.backends.filebasedr    r   r   r	   r
   r   r   r0   r4   r   r   r   r   <module>   s   %