Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/dogpile/cache/plugins/__pycache__/mako_cache.cpython-39.pyc
Ðазад
a t�h� � @ s$ d Z ddlmZ G dd� de�ZdS )a Mako Integration ---------------- dogpile.cache includes a `Mako <http://www.makotemplates.org>`_ plugin that replaces `Beaker <http://beaker.groovie.org>`_ as the cache backend. Setup a Mako template lookup using the "dogpile.cache" cache implementation and a region dictionary:: from dogpile.cache import make_region from mako.lookup import TemplateLookup my_regions = { "local":make_region().configure( "dogpile.cache.dbm", expiration_time=360, arguments={"filename":"file.dbm"} ), "memcached":make_region().configure( "dogpile.cache.pylibmc", expiration_time=3600, arguments={"url":["127.0.0.1"]} ) } mako_lookup = TemplateLookup( directories=["/myapp/templates"], cache_impl="dogpile.cache", cache_args={ 'regions':my_regions } ) To use the above configuration in a template, use the ``cached=True`` argument on any Mako tag which accepts it, in conjunction with the name of the desired region as the ``cache_region`` argument:: <%def name="mysection()" cached="True" cache_region="memcached"> some content that's cached </%def> � )� CacheImplc sP e Zd ZdZ� fdd�Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z � ZS )� MakoPluginz2A Mako ``CacheImpl`` which talks to dogpile.cache.c sD t t| ��|� z| jjjd | _W n ty> td��Y n0 d S )N�regionszs'cache_regions' argument is required on the Mako Lookup or Template object for usage with the dogpile.cache plugin.)�superr �__init__�cache�templateZ cache_argsr �KeyError)�selfr �� __class__� ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/dogpile/cache/plugins/mako_cache.pyr 4 s �zMakoPlugin.__init__c K sX z|d }W n t y& t d��Y n0 z| j| W S t yR t d| ��Y n0 d S )N�regionzt'cache_region' argument must be specified with 'cache=True'within templates for usage with the dogpile.cache plugin.zNo such region '%s')r r )r �kwr r r r �_get_region? s � zMakoPlugin._get_regionc K s( |� dd �}| jf i |��j|||d�S �N�timeout)�expiration_time)�popr � get_or_create)r �key�creation_functionr r r r r �get_and_replaceL s �zMakoPlugin.get_and_replacec K s | j ||fi |��S �N)r )r r r r r r r r R s zMakoPlugin.get_or_createc K s | j f i |���||� d S r )r �put)r r �valuer r r r r U s zMakoPlugin.putc K s&