
 X 	                 @   st   d  d l  m Z d  d l m Z d  d l m Z m Z d  d l m Z m	 Z	 d d   Z
 d d   Z d	 d
   Z d S)    )wraps)CacheMiddleware)add_never_cache_headerspatch_cache_control)available_attrs#decorator_from_middleware_with_argsc              O   s   t  |   d k s" t |  d  r1 t d   n  |  d } | j d d  } | j d d  } | rt t d   n  t t  d | d	 | d |  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.
       r   z>cache_page has a single mandatory positional argument: timeoutcacheN
key_prefixzCcache_page has two optional keyword arguments: cache and key_prefixcache_timeoutcache_alias)lencallable	TypeErrorpopr   r   )argskwargsr   r   r
    r   K/home/ubuntu/projects/ifolica/build/django/django/views/decorators/cache.py
cache_page
   s    "
r   c                 s     f d d   } | S)Nc                s1   t    d t       f d d    } | S)Nassignedc                s#    |  | |  } t  |    | S)N)r   )requestr   kwresponse)r   viewfuncr   r   _cache_controlled)   s    zCcache_control.<locals>._cache_controller.<locals>._cache_controlled)r   r   )r   r   )r   )r   r   _cache_controller(   s    -z(cache_control.<locals>._cache_controllerr   )r   r   r   )r   r   cache_control'   s    r   c                s.   t    d t      f d d    } | S)zX
    Decorator that adds headers to a response so that it will
    never be cached.
    r   c                s      |  | |  } t  |  | S)N)r   )r   r   r   r   )	view_funcr   r   _wrapped_view_func7   s    
z'never_cache.<locals>._wrapped_view_func)r   r   )r   r   r   )r   r   never_cache2   s    *r    N)	functoolsr   Zdjango.middleware.cacher   Zdjango.utils.cacher   r   Zdjango.utils.decoratorsr   r   r   r   r    r   r   r   r   <module>   s   