ó
ù¢TQc           @   sk   d  d l  m Z d  d l m Z m Z d  d l m Z m Z d  d l m	 Z	 d „  Z
 d „  Z d „  Z d S(	   iÿÿÿÿ(   t   wraps(   t#   decorator_from_middleware_with_argst   available_attrs(   t   patch_cache_controlt   add_never_cache_headers(   t   CacheMiddlewarec          O   sœ  | j  d d ƒ } | j  d d ƒ } | s7 t d ƒ ‚ d „  } t |  ƒ d k rt |  ƒ d k sp t d ƒ ‚ | ƒ  t |  d ƒ r´ t t ƒ d	 |  d d
 | d | ƒ |  d ƒ St |  d ƒ rñ t t ƒ d	 |  d d
 | d | ƒ |  d ƒ St s˜t d ƒ ‚ n’ t |  ƒ d k rxt |  d ƒ rR| ƒ  t t ƒ d
 | d | ƒ |  d ƒ St t ƒ d	 |  d d
 | d | ƒ Sn  | ƒ  t t ƒ d
 | d | ƒ Sd S(   s?  
    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
    sites.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.
    t   cachet
   key_prefixs3   The only keyword arguments are cache and key_prefixc          S   s&   d d  l  }  |  j d t d d ƒd  S(   NiÿÿÿÿsŽ   The cache_page decorator must be called like: cache_page(timeout, [cache=cache name], [key_prefix=key prefix]). All other ways are deprecated.t
   stackleveli   (   t   warningst   warnt   DeprecationWarning(   R	   (    (    s6   ../Django//lib/python/django/views/decorators/cache.pyR
   *   s    	i   i   s&   cache_page accepts at most 2 argumentsi    t   cache_timeoutt   cache_aliassF   cache_page must be passed a view function if called with two argumentsN(   t   popt   Nonet   AssertionErrort   lent   callableR   R   t   False(   t   argst   kwargsR   R   R
   (    (    s6   ../Django//lib/python/django/views/decorators/cache.pyt
   cache_page   s&     	--#&c             s   ‡  f d †  } | S(   Nc            s.   t  ˆ  d t ˆ  ƒ ƒ‡  ‡ f d †  ƒ } | S(   Nt   assignedc            s#   ˆ  |  | | Ž } t  | ˆ  | S(   N(   R   (   t   requestR   t   kwt   response(   t   viewfuncR   (    s6   ../Django//lib/python/django/views/decorators/cache.pyt   _cache_controlledI   s    (   R    R   (   R   R   (   R   (   R   s6   ../Django//lib/python/django/views/decorators/cache.pyt   _cache_controllerH   s    *(    (   R   R   (    (   R   s6   ../Django//lib/python/django/views/decorators/cache.pyt   cache_controlG   s    c            s+   t  ˆ  d t ˆ  ƒ ƒ‡  f d †  ƒ } | S(   sX   
    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   (   t	   view_func(    s6   ../Django//lib/python/django/views/decorators/cache.pyt   _wrapped_view_funcW   s    
(   R    R   (   R   R    (    (   R   s6   ../Django//lib/python/django/views/decorators/cache.pyt   never_cacheR   s    'N(   t	   functoolsR    t   django.utils.decoratorsR   R   t   django.utils.cacheR   R   t   django.middleware.cacheR   R   R   R!   (    (    (    s6   ../Django//lib/python/django/views/decorators/cache.pyt   <module>   s   	@	