§
    ¤”j  ã                   ó¤   — d Z ddlmZ ddlmZmZ ddlmZmZm	Z	m
Z
mZ ddlmZ  G d„ de¦  «        Z G d„ d	e¦  «        Z G d
„ dee¦  «        ZdS )aÙ  
Cache middleware. If enabled, each Django-powered page will be cached based on
URL. The canonical way to enable cache middleware is to set
``UpdateCacheMiddleware`` as your first piece of middleware, and
``FetchFromCacheMiddleware`` as the last::

    MIDDLEWARE = [
        'django.middleware.cache.UpdateCacheMiddleware',
        ...
        'django.middleware.cache.FetchFromCacheMiddleware'
    ]

This is counter-intuitive, but correct: ``UpdateCacheMiddleware`` needs to run
last during the response phase, which processes middleware bottom-up;
``FetchFromCacheMiddleware`` needs to run last during the request phase, which
processes middleware top-down.

The single-class ``CacheMiddleware`` can be used for some simple sites.
However, if any other piece of middleware needs to affect the cache key, you'll
need to use the two-part ``UpdateCacheMiddleware`` and
``FetchFromCacheMiddleware``. This'll most often happen when you're using
Django's ``LocaleMiddleware``.

More details about how the caching works:

* Only GET or HEAD-requests with status code 200 are cached.

* The number of seconds each page is stored for is set by the "max-age" section
  of the response's "Cache-Control" header, falling back to the
  CACHE_MIDDLEWARE_SECONDS setting if the section was not found.

* This middleware expects that a HEAD request is answered with the same response
  headers exactly like the corresponding GET request.

* When a hit occurs, a shallow copy of the original response object is returned
  from process_request.

* Pages will be cached based on the contents of the request headers listed in
  the response's "Vary" header.

* This middleware also sets ETag, Last-Modified, Expires and Cache-Control
  headers on the response object.

é    )Úsettings)ÚDEFAULT_CACHE_ALIASÚcaches)Úget_cache_keyÚget_max_ageÚhas_vary_headerÚlearn_cache_keyÚpatch_response_headers)ÚMiddlewareMixinc                   óD   ‡ — e Zd ZdZˆ fd„Zed„ ¦   «         Zd„ Zd„ Zˆ xZ	S )ÚUpdateCacheMiddlewarea6  
    Response-phase cache middleware that updates the cache if the response is
    cacheable.

    Must be used as part of the two-part update/fetch cache middleware.
    UpdateCacheMiddleware must be the first piece of middleware in MIDDLEWARE
    so that it'll get called last during the response phase.
    c                 ó¾   •— t          ¦   «                              |¦  «         t          j        | _        d | _        t          j        | _        t          j        | _	        d S ©N)
ÚsuperÚ__init__r   ÚCACHE_MIDDLEWARE_SECONDSÚcache_timeoutÚpage_timeoutÚCACHE_MIDDLEWARE_KEY_PREFIXÚ
key_prefixÚCACHE_MIDDLEWARE_ALIASÚcache_alias©ÚselfÚget_responseÚ	__class__s     €úf/var/www/finuniver-perm.ru/html/portfolio/venv/lib/python3.11/site-packages/django/middleware/cache.pyr   zUpdateCacheMiddleware.__init__D   sI   ø€ Ý‰Œ×Ò˜Ñ&Ô&Ð&Ý%Ô>ˆÔØ ˆÔÝ"Ô>ˆŒÝ#Ô:ˆÔÐÐó    c                 ó&   — t           | j                 S r   ©r   r   ©r   s    r   ÚcachezUpdateCacheMiddleware.cacheK   ó   € å�dÔ&Ô'Ð'r   c                 ó0   — t          |d¦  «        o|j        S )NÚ_cache_update_cache)Úhasattrr%   )r   ÚrequestÚresponses      r   Ú_should_update_cachez*UpdateCacheMiddleware._should_update_cacheO   s   € Ý�wÐ 5Ñ6Ô6ÐV¸7Ô;VÐVr   c                 óT  ‡ ‡‡— ‰                       ||¦  «        s|S |j        s	|j        dvr|S |j        s|j        rt          |d¦  «        r|S d|                     dd¦  «        v r|S ‰ j        Š‰€!t          |¦  «        Š‰€‰ j	        Šn‰dk    r|S t          |‰¦  «         ‰r„|j        dk    ryt          ||‰‰ j        ‰ j        ¬	¦  «        Št          |d
¦  «        r/t          |j        ¦  «        r|                     ˆˆ ˆfd„¦  «         n‰ j                             ‰|‰¦  «         |S )zSet the cache, if needed.)éÈ   i0  ÚCookieÚprivatezCache-Control© Nr   r+   ©r"   Úrenderc                 ó<   •— ‰j                              ‰| ‰¦  «        S r   )r"   Úset)ÚrÚ	cache_keyr   Útimeouts    €€€r   ú<lambda>z8UpdateCacheMiddleware.process_response.<locals>.<lambda>{   s   ø€ ˜dœjŸnšn¨Y¸¸7ÑCÔC€ r   )r)   Ú	streamingÚstatus_codeÚCOOKIESÚcookiesr   Úgetr   r   r   r
   r	   r   r"   r&   Úcallabler0   Úadd_post_render_callbackr2   )r   r'   r(   r4   r5   s   `  @@r   Úprocess_responsez&UpdateCacheMiddleware.process_responseR   s‡  øøø€ à×(Ò(¨°(Ñ;Ô;ð 	àˆOàÔð 	 Ô!5¸ZÐ!GÐ!GØˆOð
 ”ð	àÔ ð	õ   ¨(Ñ3Ô3ð	ð
 ˆOð ˜Ÿš _°bÑ9Ô9Ð9Ð9ØˆOð Ô#ˆØˆ?õ " (Ñ+Ô+ˆGØˆØÔ,��Ø˜A’�à�Ý˜x¨Ñ1Ô1Ð1Øð 		=�xÔ+¨sÒ2Ð2Ý'Ø˜ 7¨D¬OÀ4Ä:ðñ ô ˆIõ �x Ñ*Ô*ð =­x¸¼Ñ/HÔ/Hð =Ø×1Ò1ØCÐCÐCÐCÐCÐCñô ð ð ð ”
—’˜y¨(°GÑ<Ô<Ð<Øˆr   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr"   r)   r>   Ú__classcell__©r   s   @r   r   r   :   s~   ø€ € € € € ðð ð;ð ;ð ;ð ;ð ;ð ð(ð (ñ „Xð(ðWð Wð Wð-ð -ð -ð -ð -ð -ð -r   r   c                   ó>   ‡ — e Zd ZdZˆ fd„Zed„ ¦   «         Zd„ Zˆ xZS )ÚFetchFromCacheMiddlewarea!  
    Request-phase cache middleware that fetches a page from the cache.

    Must be used as part of the two-part update/fetch cache middleware.
    FetchFromCacheMiddleware must be the last piece of middleware in MIDDLEWARE
    so that it'll get called last during the request phase.
    c                 óŽ   •— t          ¦   «                              |¦  «         t          j        | _        t          j        | _        d S r   )r   r   r   r   r   r   r   r   s     €r   r   z!FetchFromCacheMiddleware.__init__‹   s6   ø€ Ý‰Œ×Ò˜Ñ&Ô&Ð&Ý"Ô>ˆŒÝ#Ô:ˆÔÐÐr   c                 ó&   — t           | j                 S r   r    r!   s    r   r"   zFetchFromCacheMiddleware.cache�   r#   r   c                 óZ  — |j         dvr	d|_        dS t          || j        d| j        ¬¦  «        }|€	d|_        dS | j                             |¦  «        }|€B|j         dk    r7t          || j        d| j        ¬¦  «        }| j                             |¦  «        }|€	d|_        dS d|_        |S )zn
        Check whether the page is already cached and return the cached
        version if available.
        )ÚGETÚHEADFNrK   r/   TrL   )Úmethodr%   r   r   r"   r;   )r   r'   r4   r(   s       r   Úprocess_requestz(FetchFromCacheMiddleware.process_request”   sÊ   € ð
 Œ> Ð0Ð0Ø*/ˆGÔ'Ø�4õ " '¨4¬?¸EÈÌÐTÑTÔTˆ	ØÐØ*.ˆGÔ'Ø�4Ø”:—>’> )Ñ,Ô,ˆàÐ ¤°&Ò 8Ð 8Ý%Ø˜œ¨&¸¼
ðñ ô ˆIð ”z—~’~ iÑ0Ô0ˆHàÐØ*.ˆGÔ'Ø�4ð ',ˆÔ#Øˆr   )	r?   r@   rA   rB   r   rC   r"   rN   rD   rE   s   @r   rG   rG   ‚   sl   ø€ € € € € ðð ð;ð ;ð ;ð ;ð ;ð
 ð(ð (ñ „Xð(ðð ð ð ð ð ð r   rG   c                   ó$   ‡ — e Zd ZdZdˆ fd„	Zˆ xZS )ÚCacheMiddlewarezÌ
    Cache middleware that provides basic behavior for many simple sites.

    Also used as the hook point for the cache decorator, which is generated
    using the decorator-from-middleware utility.
    Nc                 ó  •— t          ¦   «                              |¦  «         	 |d         }|€d}|| _        n# t          $ r Y nw xY w	 |d         }|€t          }|| _        n# t          $ r Y nw xY w|�|| _        || _        d S )Nr   Ú r   )r   r   r   ÚKeyErrorr   r   r   r   )r   r   r   r   Úkwargsr   r   r   s          €r   r   zCacheMiddleware.__init__»   sÁ   ø€ Ý‰Œ×Ò˜Ñ&Ô&Ð&ð	Ø Ô-ˆJØÐ!Ø�
Ø(ˆDŒOˆOøÝð 	ð 	ð 	ØˆDð	øøøð	Ø  Ô/ˆKØÐ"Ý1�Ø*ˆDÔÐøÝð 	ð 	ð 	ØˆDð	øøøð Ð$Ø!.ˆDÔØ(ˆÔÐÐs!   ¤8 ¸
AÁAÁ	A" Á"
A/Á.A/)NN)r?   r@   rA   rB   r   rD   rE   s   @r   rP   rP   ³   sG   ø€ € € € € ðð ð)ð )ð )ð )ð )ð )ð )ð )ð )ð )r   rP   N)rB   Údjango.confr   Údjango.core.cacher   r   Údjango.utils.cacher   r   r   r	   r
   Údjango.utils.deprecationr   r   rG   rP   r.   r   r   ú<module>rY      s,  ðð+ð +ðZ !Ð  Ð  Ð  Ð  Ð  Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9ðð ð ð ð ð ð ð ð ð ð ð ð ð ð 5Ð 4Ð 4Ð 4Ð 4Ð 4ðEð Eð Eð Eð E˜Oñ Eô Eð EðP.ð .ð .ð .ð .˜ñ .ô .ð .ðb )ð  )ð  )ð  )ð  )Ð+Ð-Eñ  )ô  )ð  )ð  )ð  )r   