
    Ջgh                     F    d Z ddlmZ ddlmZ ddlmZ dZ G d de      Zy)	a  
    flask_caching.jinja2ext
    ~~~~~~~~~~~~~~~~~~~~~~~

    Jinja2 extension that adds support for caching template fragments.

    Usage::

        {% cache timeout key1[, [key2, ...]] %}
        ...
        {% endcache %}

    By default, the value of "path to template file" + "block start line"
    is used as the cache key. Also, the key name can be set manually.
    Keys are concatenated together into a single string, that can be used
    to avoid the same block evaluating in different templates.

    Set the timeout to ``None`` for no timeout, but with custom keys::

        {% cache None "key" %}
        ...
        {% endcache %}

    Set timeout to ``del`` to delete cached value::

        {% cache 'del' key1 %}
        ...
        {% endcache %}

    Considering we have ``render_form_field`` and ``render_submit`` macros::

        {% cache 60*5 'myform' %}
        <div>
            <form>
            {% render_form_field(form.username) %}
            {% render_submit() %}
            </form>
        </div>
        {% endcache %}

    :copyright: (c) 2010 by Thadeus Burgess.
    :license: BSD, see LICENSE for more details.
    )nodes)	Extension)make_template_fragment_key_template_fragment_cachec                       e Zd ZdhZd Zd Zy)CacheExtensioncachec                    t        |j                        j                  }|j                         g}|j                  j	                  d      r |j                  |j                                n2|j                  t        j                  |j                   |              g }|j                  j	                  d      r;|j                  |j                                |j                  j	                  d      r;|r%|j                  t        j                  |             n$|j                  t        j                  g              |j                  dgd      }t        j                  | j                  d|      g g |      j                  |      S )Ncommazname:endcacheT)drop_needle_cache)nextstreamlinenoparse_expressionskip_ifappendr   ConstfilenameListparse_statements	CallBlockcall_method
set_lineno)selfparserr   argsvary_onbodys         J/var/www/html/venv/lib/python3.12/site-packages/flask_caching/jinja2ext.pyparsezCacheExtension.parse8   s.   fmm$++ '')* ==  )KK//12KKv&7x$@AB mm##G,NN62245 mm##G, KK

7+,KKB(&&'8d&KXt,b"d

*V
	    c                    	 t        | j                  t              }t	        ||      }|dk(  r|j                  |        |       S |j                  |      }| |       }|j                  |||       |S # t        $ r}|d }~ww xY w)N)r   del)getattrenvironmentJINJA_CACHE_ATTR_NAMEAttributeErrorr   deletegetset)	r   timeoutfragment_namer   callerr	   ekeyrvs	            r    r   zCacheExtension._cacheV   s    	D,,.CDE )H eLL8OYYs^:BIIc2w'	  	G	s   A5 5	B>B  BN)__name__
__module____qualname__tagsr!   r    r"   r    r   r   5   s    9D<r"   r   N)	__doc__jinja2r   
jinja2.extr   flask_cachingr   r'   r   r6   r"   r    <module>r;      s(   *X    42 2Y 2r"   