jinja loaders check now if a file is a file and not a directory instead of using...
authorArmin Ronacher <armin.ronacher@active-4.com>
Sun, 25 Nov 2007 13:35:43 +0000 (14:35 +0100)
committerArmin Ronacher <armin.ronacher@active-4.com>
Sun, 25 Nov 2007 13:35:43 +0000 (14:35 +0100)
--HG--
branch : trunk

jinja/exceptions.py
jinja/loaders.py

index d24dc9240d6d08ee866fd4e7bf189eea73deef84..c900815d51ca47e8e536ec6b550f2e4d8a7e38e1 100644 (file)
@@ -56,7 +56,7 @@ class TestArgumentError(TypeError, TemplateError):
         TypeError.__init__(self, message)
 
 
-class TemplateNotFound(IOError, TemplateError):
+class TemplateNotFound(IOError, LookupError, TemplateError):
     """
     Raised if a template does not exist.
     """
index ffb4789554e8ac1a0cf1cddf09198be83c059ab1..09f7dda3cf9b6e716d3a1b4601994ea312ca74e5 100644 (file)
@@ -414,7 +414,7 @@ class BaseFileSystemLoader(BaseLoader):
 
     def get_source(self, environment, name, parent):
         filename = get_template_filename(self.searchpath, name)
-        if path.exists(filename):
+        if path.isfile(filename):
             f = codecs.open(filename, 'r', environment.template_charset)
             try:
                 return f.read()
@@ -473,7 +473,7 @@ class FileSystemLoader(CachedLoaderMixin, BaseFileSystemLoader):
 
     def check_source_changed(self, environment, name):
         filename = get_template_filename(self.searchpath, name)
-        if path.exists(filename):
+        if path.isfile(filename):
             return path.getmtime(filename)
         return -1
 
@@ -562,7 +562,7 @@ class BasePackageLoader(BaseLoader):
                     self.package_path.split('/') +
                     [p for p in name.split('/') if p != '..'])
                 )
-                if path.exists(filename):
+                if path.isfile(filename):
                     f = file(filename)
                     try:
                         return f.read()