ó
ži‚Nc           @   sF   d  d l  m Z d a d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿ(   t
   exceptionst   BeakerMissingc           B   s   e  Z d  „  Z RS(   c         K   s   t  j d ƒ ‚ d  S(   Ns:   the Beaker package is required to use cache functionality.(   R    t   RuntimeException(   t   selft   namet   kwargs(    (    s.   /usr/lib/python2.7/dist-packages/mako/cache.pyt	   get_cache   s    (   t   __name__t
   __module__R   (    (    (    s.   /usr/lib/python2.7/dist-packages/mako/cache.pyR      s   t   Cachec           B   sY   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d	 d „ Z RS(
   sf  Represents a data content cache made available to the module
    space of a :class:`.Template` object.
 
    :class:`.Cache` is a wrapper on top of a Beaker CacheManager object.
    This object in turn references any number of "containers", each of
    which defines its own backend (i.e. file, memory, memcached, etc.) 
    independently of the rest.
 
    c         C   s   | |  _  | |  _ i  |  _ d  S(   N(   t   idt	   starttimet   def_regions(   R   R
   R   (    (    s.   /usr/lib/python2.7/dist-packages/mako/cache.pyt   __init__   s    		c         K   sb   | j  d d ƒ } | j  d d ƒ } | j  d d ƒ } |  j | |  j | d |  j d | ƒd S(   sh  Place a value in the cache.
 
        :param key: the value's key.
        :param value: the value
        :param \**kwargs: cache configuration arguments.  The 
         backend is configured using these arguments upon first request.
         Subsequent requests that use the same series of configuration
         values will use that same backend.
 
        t   defnamet
   expiretimet
   createfuncR   N(   t   popt   Nonet
   _get_cachet	   put_valueR   (   R   t   keyt   valueR   R   R   R   (    (    s.   /usr/lib/python2.7/dist-packages/mako/cache.pyt   put   s    c         K   sd   | j  d d ƒ } | j  d d ƒ } | j  d d ƒ } |  j | |  j | d |  j d | d | ƒS(   sM  Retrieve a value from the cache.
 
        :param key: the value's key.
        :param \**kwargs: cache configuration arguments.  The 
         backend is configured using these arguments upon first request.
         Subsequent requests that use the same series of configuration
         values will use that same backend.
 
        R   R   R   R   N(   R   R   R   t	   get_valueR   (   R   R   R   R   R   R   (    (    s.   /usr/lib/python2.7/dist-packages/mako/cache.pyt   get1   s    c         K   sb   | j  d d ƒ } | j  d d ƒ } | j  d d ƒ } |  j | |  j | d |  j d | ƒd S(   sM  Invalidate a value in the cache.
 
        :param key: the value's key.
        :param \**kwargs: cache configuration arguments.  The 
         backend is configured using these arguments upon first request.
         Subsequent requests that use the same series of configuration
         values will use that same backend.
 
        R   R   R   R   N(   R   R   R   t   remove_valueR   (   R   R   R   R   R   R   (    (    s.   /usr/lib/python2.7/dist-packages/mako/cache.pyt
   invalidateB   s    
c         C   s   |  j  d d d ƒd S(   sP   Invalidate the cached content of the "body" method for this template.
 
        t   render_bodyR   N(   R   (   R   (    (    s.   /usr/lib/python2.7/dist-packages/mako/cache.pyt   invalidate_bodyR   s    c         C   s   |  j  d | d d | ƒd S(   sJ   Invalidate the cached content of a particular <%def> within this template.s	   render_%sR   N(   R   (   R   R   (    (    s.   /usr/lib/python2.7/dist-packages/mako/cache.pyt   invalidate_defX   s    c         C   s   |  j  | d | ƒd S(   sM  Invalidate a nested <%def> within this template.
 
        Caching of nested defs is a blunt tool as there is no
        management of scope - nested defs that use cache tags
        need to have names unique of all other nested defs in the 
        template, else their content will be overwritten by 
        each other.
 
        R   N(   R   (   R   R   (    (    s.   /usr/lib/python2.7/dist-packages/mako/cache.pyt   invalidate_closure]   s    c         K   s±   t  sF y  d d l m  } | j ƒ  a  WqF t k
 rB t ƒ  a  qF Xn  | d k r[ d } n  | s… |  j j | d i  f ƒ \ } } n | | f |  j | <t  j |  j d | | S(   Niÿÿÿÿ(   t   cachet	   memcacheds   ext:memcachedt   memoryt   type(	   R    t   beakert   CacheManagert   ImportErrorR   R   R   R   R
   (   R   R   R#   t   kwt   beaker_cache(    (    s.   /usr/lib/python2.7/dist-packages/mako/cache.pyR   j   s    	$N(   R   R   t   __doc__R   R   R   R   R   R   R   R   R   (    (    (    s.   /usr/lib/python2.7/dist-packages/mako/cache.pyR	      s   								N(   t   makoR    R   R    t   objectR   R	   (    (    (    s.   /usr/lib/python2.7/dist-packages/mako/cache.pyt   <module>   s   