
    Vh                     d    d dl m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ddZd	 Zd
 Zd Zy)    )wraps)iscoroutinefunction)CacheMiddleware)add_never_cache_headerspatch_cache_control)#decorator_from_middleware_with_argsN)cache
key_prefixc                2     t        t              | ||      S )a9  
    Decorator for views that tries getting the page from the cache and
    populates the cache if the page isn't in the cache yet.

    The cache is keyed by the URL and some data from the headers.
    Additionally there is the key prefix that is used to distinguish different
    cache areas in a multi-site setup. You could use the
    get_current_site().domain, for example, as that is unique across a Django
    project.

    Additionally, all headers from the response's Vary header will be taken
    into account on caching -- just like the middleware does.
    )page_timeoutcache_aliasr
   )r   r   )timeoutr	   r
   s      M/home/dcms/DCMS/lib/python3.12/site-packages/django/views/decorators/cache.py
cache_pager   
   s#     @.?     c                 8    t        | d      st        | d      y )NMETAzf didn't receive an HttpRequest. If you are decorating a classmethod, be sure to use @method_decorator.)hasattr	TypeError)requestdecorator_names     r   _check_requestr      s0    7F# J J
 	
 $r   c                        fd}|S )Nc                 X     t               r fd}n fd} t               |      S )Nc                 l   K   t        | d        | g|i | d {   }t        |fi  |S 7 wNcache_controlr   r   r   argskwresponsekwargsviewfuncs       r   _view_wrapperz?cache_control.<locals>._cache_controller.<locals>._view_wrapper,   s@     w8!)'!?D!?B!??#H77 @s   424c                 P    t        | d        | g|i |}t        |fi  |S r   r   r   s       r   r%   z?cache_control.<locals>._cache_controller.<locals>._view_wrapper4   s3    w8#G9d9b9#H77r   r   r   )r$   r%   r#   s   ` r   _cache_controllerz(cache_control.<locals>._cache_controller)   s(    x(   uX}--r    )r#   r(   s   ` r   r   r   (   s    .& r   c                 R     t               r fd}n fd} t               |      S )zT
    Decorator that adds headers to a response so that it will never be cached.
    c                 j   K   t        | d        | g|i | d {   }t        |       |S 7 wNnever_cacher   r   r   r    r#   r"   	view_funcs       r   r%   z"never_cache.<locals>._view_wrapperF   s;     7M2&w@@@@H#H-O As   313c                 N    t        | d        | g|i |}t        |       |S r,   r.   r/   s       r   r%   z"never_cache.<locals>._view_wrapperN   s.    7M2 :4:6:H#H-Or   r'   )r0   r%   s   ` r   r-   r-   ?   s+    
 9%		 5M**r   )	functoolsr   asgiref.syncr   django.middleware.cacher   django.utils.cacher   r   django.utils.decoratorsr   r   r   r   r-   r)   r   r   <module>r7      s/     , 3 K G "&$ *
.+r   