Ñò
Ë¥WJc           @   s–   d  Z  d d k Z d d k Z d d k Z d d k l Z d d k l Z y d d k Z Wn e	 j
 o d d k
 Z n Xd e f d „  ƒ  YZ d S(   sJ   a reimplementation of the mako template loader
that supports dotted names
iÿÿÿÿN(   t   Template(   t   asboolt   DottedTemplateLookupc           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s  Mako template lookup emulation that supports
    zipped applications and dotted filenames.

    This is an emulation of the Mako template lookup that will handle
    get_template and support dotted names in Python path notation
    to support zipped eggs.

    This is necessary because Mako asserts that your project will always
    be installed in a zip-unsafe manner with all files somewhere on the
    hard drive.
    
    This is not the case when you want your application to be deployed
    in a single zip file (zip-safe). If you want to deploy in a zip
    file _and_ use the dotted template name notation then this class
    is necessary because it emulates files on the filesystem for the
    underlying Mako engine while they are in fact in your zip file.

    c         C   sO   | |  _  | |  _ | |  _ | |  _ t ƒ  |  _ t ƒ  |  _ t i ƒ  |  _	 d  S(   N(
   t   input_encodingt   output_encodingt   importst   default_filterst   dictt   template_cachet   template_filenames_cachet	   threadingt   Lockt   _mutex(   t   selfR   R   R   R   (    (    sr   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.1-py2.6.egg/tg/dottednamesupport.pyt   __init__%   s    				c         C   sa   d | j oJ t  i d i i d | d d ƒ } |  i i | ƒ p | |  i | <q] n | } | S(   sð   Adjust the given uri relative to a filename.

        This method is used by mako for filesystem based reasons.
        In dotted lookup land we don't adjust uri so we just return
        the value we are given without any change.

        t   .s   pylons.app_globalst   template_namet   template_extensions   .mak(   t   tgt   configt   dotted_filename_findert   get_dotted_filenameR	   t   has_key(   R   t   urit
   relativetot   result(    (    sr   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.1-py2.6.egg/tg/dottednamesupport.pyt
   adjust_uri4   s    	c         C   s°   | i  d j o | St i i | i  ƒ p0 |  i i | i  d ƒ t i d | i  ƒ ‚ nR | i	 i
 t i | i  ƒ t i j  o' |  i i | i  d ƒ |  i | i  ƒ S| Sd S(   sf  private method used to verify if a template has changed
        since the last time it has been put in cache...

        This method being based on the mtime of a real file this should
        never be called on a zipped deployed application.

        This method is a ~copy/paste of the original caching system from
        the Mako lookup loader.

        s   Cant locate template '%s'N(   t   filenamet   Nonet   ost   patht   existsR   t   popt
   exceptionst   TemplateLookupExceptiont   modulet   _modified_timet   statt   ST_MTIMEt   _DottedTemplateLookup__load(   R   t   template(    (    sr   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.1-py2.6.egg/tg/dottednamesupport.pyt   __checkP   s    c         C   sÉ   |  i  i ƒ  z§ y |  i | SWn t j
 o n Xy^ t t | ƒ i ƒ  d | d |  i d |  i d |  i	 d |  i
 d |  ƒ|  i | <|  i | SWn |  i i | d ƒ ‚  n XWd |  i  i ƒ  Xd S(   sQ   real loader function. copy paste from the mako template
        loader.

        R   R   R   R   R   t   lookupN(   R   t   acquireR   t   KeyErrorR    t   opent   readR   R   R   R   R    R   t   release(   R   R   (    (    sr   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.1-py2.6.egg/tg/dottednamesupport.pyt   __loadp   s&    				c         C   sd   |  i  i | ƒ p |  i | ƒ n t t i i d d ƒ ƒ o |  i |  i  | ƒ S|  i  | Sd S(   sq   this is the emulated method that must return a template
        instance based on a given template name

        s   templating.mako.reloadfromdiskt   falseN(   R   R   R'   R   R   R   t   gett   _DottedTemplateLookup__check(   R   R   (    (    sr   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.1-py2.6.egg/tg/dottednamesupport.pyt   get_template–   s
    (   t   __name__t
   __module__t   __doc__R   R   R3   R'   R4   (    (    (    sr   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.1-py2.6.egg/tg/dottednamesupport.pyR      s   			 	&(   R7   R   R%   R   t   mako.templateR    t   paste.deploy.convertersR   R
   t   ImportErrort   dummy_threadingt   objectR   (    (    (    sr   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/TurboGears2-2.0.1-py2.6.egg/tg/dottednamesupport.pyt   <module>   s   