î
ªÍ XN  ã               @   sp   d  d l  m Z d  d l m Z m Z d  d l m Z d  d l m Z d  d l	 m
 Z
 Gd d „  d e ƒ Z d S)	é    )Úabsolute_import)ÚImproperlyConfiguredÚSuspiciousFileOperation)Úget_app_template_dirs)Ú	safe_join)Úcached_propertyc               @   sd   e  Z d  Z d d „  Z e d d „  ƒ Z d d „  Z d d „  Z e d	 d
 „  ƒ Z	 d d „  Z
 d S)Ú
BaseEnginec             C   sy   | j  ƒ  } | j d ƒ |  _ t | j d ƒ ƒ |  _ t | j d ƒ ƒ |  _ | ru t d j d j	 | ƒ ƒ ƒ ‚ n  d S)zj
        Initializes the template engine.

        Receives the configuration settings as a dict.
        ÚNAMEZDIRSZAPP_DIRSzUnknown parameters: {}z, N)
ÚcopyÚpopÚnameÚlistÚdirsÚboolÚapp_dirsr   ÚformatÚjoin)ÚselfÚparams© r   úK/home/ubuntu/projects/ifolica/build/django/django/template/backends/base.pyÚ__init__   s    zBaseEngine.__init__c             C   s   t  d j |  j j ƒ ƒ ‚ d  S)NzA{} doesn't support loading templates from installed applications.)r   r   Ú	__class__Ú__name__)r   r   r   r   Úapp_dirname   s    zBaseEngine.app_dirnamec             C   s   t  d ƒ ‚ d S)zm
        Creates and returns a template for the given source code.

        This method is optional.
        z>subclasses of BaseEngine should provide a from_string() methodN)ÚNotImplementedError)r   Ztemplate_coder   r   r   Úfrom_string%   s    zBaseEngine.from_stringc             C   s   t  d ƒ ‚ d S)zƒ
        Loads and returns a template for the given name.

        Raises TemplateDoesNotExist if no such template exists.
        z=subclasses of BaseEngine must provide a get_template() methodN)r   )r   Útemplate_namer   r   r   Úget_template/   s    zBaseEngine.get_templatec             C   s2   t  |  j ƒ } |  j r. | t |  j ƒ 7} n  | S)zH
        Returns a list of directories to search for templates.
        )Útupler   r   r   r   )r   Útemplate_dirsr   r   r   r    <   s    	zBaseEngine.template_dirsc             c   s?   x8 |  j  D]- } y t | | ƒ VWq
 t k
 r6 Yq
 Xq
 Wd S)z¶
        Iterates over candidate files for template_name.

        Ignores files that don't lie inside configured template dirs to avoid
        directory traversal attacks.
        N)r    r   r   )r   r   Ztemplate_dirr   r   r   Úiter_template_filenamesG   s
    z"BaseEngine.iter_template_filenamesN)r   Ú
__module__Ú__qualname__r   Úpropertyr   r   r   r   r    r!   r   r   r   r   r      s   
r   N)Ú
__future__r   Zdjango.core.exceptionsr   r   Zdjango.template.utilsr   Zdjango.utils._osr   Zdjango.utils.functionalr   Úobjectr   r   r   r   r   Ú<module>   s
   