
vÅÏ^¿
  ã               @   s]   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 ƒ Z	 d S)é    )Ú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   sp   | j  ƒ  } | j d ƒ |  _ t | j d ƒ ƒ |  _ | j d ƒ |  _ | rl t d j d j | ƒ ƒ ƒ ‚ d S)zh
        Initialize the template engine.

        `params` is a dict of configuration settings.
        ÚNAMEZDIRSZAPP_DIRSzUnknown parameters: {}z, N)	ÚcopyÚpopÚnameÚlistÚdirsÚapp_dirsr   ÚformatÚjoin)ÚselfÚparams© r   ú?/tmp/pip-build-8lau8j11/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)zk
        Create and return 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€
        Load and return a template for the given name.

        Raise 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   s/   t  |  j ƒ } |  j r+ | t |  j ƒ 7} | S)zG
        Return a list of directories to search for templates.
        )Útupler   r   r   r   )r   Útemplate_dirsr   r   r   r   9   s    	zBaseEngine.template_dirsc             c   s?   x8 |  j  D]- } y t | | ƒ VWq
 t k
 r6 Yq
 Xq
 Wd S)z´
        Iterate over candidate files for template_name.

        Ignore 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_filenamesD   s
    z"BaseEngine.iter_template_filenamesN)r   Ú
__module__Ú__qualname__r   Úpropertyr   r   r   r   r   r   r   r   r   r   r   	   s   
r   N)
Zdjango.core.exceptionsr   r   Zdjango.template.utilsr   Zdjango.utils._osr   Zdjango.utils.functionalr   r   r   r   r   r   Ú<module>   s   