ó
    ½Rj  ã                   ó�   • S r SSKJr  SSKJrJr  SSKJrJrJ	r	J
r
Jr  SSKJr   " S S\5      r " S S	\5      r " S
 S\\5      rg)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                   óH   ^ • \ rS rSrSrU 4S jr\S 5       rS rS r	Sr
U =r$ )ÚUpdateCacheMiddlewareé:   a  
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U ]  U5        [        R                  U l        S U l        [        R                  U l        [        R                  U l	        g ©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     €ÚCD:\diplom_project\venv\Lib\site-packages\django/middleware/cache.pyr   ÚUpdateCacheMiddleware.__init__D   sA   ø€ Ü‰Ñ˜Ô&Ü%×>Ñ>ˆÔØ ˆÔÜ"×>Ñ>ˆŒÜ#×:Ñ:ˆÕó    c                 ó(   • [         U R                     $ r   ©r   r   ©r   s    r   ÚcacheÚUpdateCacheMiddleware.cacheK   ó   € ä�d×&Ñ&Ñ'Ð'r    c                 ó@   • [        US5      =(       a    UR                  $ )NÚ_cache_update_cache)Úhasattrr(   )r   ÚrequestÚresponses      r   Ú_should_update_cacheÚ*UpdateCacheMiddleware._should_update_cacheO   s   € Ü�wÐ 5Ó6×V¸7×;VÑ;VÐVr    c                 óÈ  ^ ^^• T R                  X5      (       d  U$ UR                  (       d  UR                  S;  a  U$ UR                  (       d$  UR                  (       a  [        US5      (       a  U$ SUR                  SS5      ;   a  U$ T R                  mTc#  [        U5      mTc  T R                  mOTS:X  a  U$ [        UT5        T(       a‘  UR                  S:X  a�  [        XTT R                  T R                  S9m[        US	5      (       a3  [        UR                   5      (       a  UR#                  UU U4S
 j5        U$ T R                  R%                  TUT5        U$ )zSet the cache, if needed.)éÈ   i0  ÚCookieÚprivatezCache-Control© r   r/   ©r$   Úrenderc                 ó>   >• TR                   R                  TU T5      $ r   )r$   Úset)ÚrÚ	cache_keyr   Útimeouts    €€€r   Ú<lambda>Ú8UpdateCacheMiddleware.process_response.<locals>.<lambda>{   s   ø€ ˜dŸj™jŸn™n¨Y¸¸7ÔCr    )r,   Ú	streamingÚstatus_codeÚCOOKIESÚcookiesr   Úgetr   r   r   r
   r	   r   r$   r)   Úcallabler4   Úadd_post_render_callbackr6   )r   r*   r+   r8   r9   s   `  @@r   Úprocess_responseÚ&UpdateCacheMiddleware.process_responseR   s1  ú€ à×(Ñ(¨×;Ñ;àˆOà×× ×!5Ñ!5¸ZÓ!GØˆOð
 ——Ø× × Ü ¨(×3Ñ3àˆOð ˜Ÿ™ _°bÓ9Ó9ØˆOð ×#Ñ#ˆØ‰?ô " (Ó+ˆGØ‰Ø×,Ñ,‘Ø˜A“à�Ü˜x¨Ô1Þ�x×+Ñ+¨sÓ2Ü'Ø 7¨D¯O©OÀ4Ç:Á:ñˆIô �x ×*Ñ*¬x¸¿¹×/HÑ/HØ×1Ñ1ÞCôð
 ˆð —
‘
—‘˜y¨(°GÔ<Øˆr    ©r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Úpropertyr$   r,   rC   Ú__static_attributes__Ú__classcell__©r   s   @r   r   r   :   s1   ø† ñõ;ð ñ(ó ð(òW÷-ð -r    r   c                   óB   ^ • \ rS rSrSrU 4S jr\S 5       rS rSr	U =r
$ )ÚFetchFromCacheMiddlewareé‚   a  
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                 óx   >• [         TU ]  U5        [        R                  U l        [        R
                  U l        g r   )r   r   r   r   r   r   r   r   s     €r   r   Ú!FetchFromCacheMiddleware.__init__‹   s+   ø€ Ü‰Ñ˜Ô&Ü"×>Ñ>ˆŒÜ#×:Ñ:ˆÕr    c                 ó(   • [         U R                     $ r   r"   r#   s    r   r$   ÚFetchFromCacheMiddleware.cache�   r&   r    c                 ó~  • UR                   S;  a  SUl        g[        XR                  SU R                  S9nUc  SUl        gU R                  R                  U5      nUcJ  UR                   S:X  a:  [        XR                  SU R                  S9nU R                  R                  U5      nUc  SUl        gSUl        U$ )zV
Check whether the page is already cached and return the cached
version if available.
)ÚGETÚHEADFNrW   r3   TrX   )Úmethodr(   r   r   r$   r@   )r   r*   r8   r+   s       r   Úprocess_requestÚ(FetchFromCacheMiddleware.process_request”   s´   € ð
 �>‰> Ó0Ø*/ˆGÔ'Øô " '¯?©?¸EÈÏÉÑTˆ	ØÑØ*.ˆGÔ'ØØ—:‘:—>‘> )Ó,ˆàÑ §¡°&Ó 8Ü%ØŸ™¨&¸¿
¹
ñˆIð —z‘z—~‘~ iÓ0ˆHàÑØ*.ˆGÔ'Øð ',ˆÔ#Øˆr    )r   r   )rF   rG   rH   rI   rJ   r   rK   r$   rZ   rL   rM   rN   s   @r   rP   rP   ‚   s+   ø† ñõ;ð
 ñ(ó ð(÷ð r    rP   c                   ó0   ^ • \ rS rSrSrSU 4S jjrSrU =r$ )ÚCacheMiddlewareé³   z¼
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.
c                 óÎ   >• [         TU ]  U5         US   nUc  SnXPl         US   nUc  [        nX`l        Ub  X l        X0l        g ! [         a     N1f = f! [         a     N,f = f)Nr   Ú r   )r   r   r   ÚKeyErrorr   r   r   r   )r   r   r   r   Úkwargsr   r   r   s          €r   r   ÚCacheMiddleware.__init__»   sŠ   ø€ Ü‰Ñ˜Ô&ð	Ø Ñ-ˆJØÑ!Ø�
Ø(ŒOð	Ø  Ñ/ˆKØÑ"Ü1�Ø*Ôð Ñ$Ø!.ÔØ(Õøô ó 	Ùð	ûô ó 	Ùð	ús"   ’A £A Á
AÁAÁ
A$Á#A$rE   )NN)rF   rG   rH   rI   rJ   r   rL   rM   rN   s   @r   r]   r]   ³   s   ø† ñ÷)õ )r    r]   N)rJ   Údjango.confr   Údjango.core.cacher   r   Údjango.utils.cacher   r   r   r	   r
   Údjango.utils.deprecationr   r   rP   r]   r2   r    r   Ú<module>rh      sN   ðñ+õZ !ß 9÷õ õ 5ôE˜Oô EôP.˜ô .ôb )Ð+Ð-Eõ  )r    