summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-03-05 18:55:08 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2010-03-05 18:55:08 +0000
commit7c526147cf55d9b4656e59ee4db83cccfb4b861d (patch)
tree33d29535f4c1578a58643ee2556b8ff9da9736af
parent89eae3cc302909811cd269bde7a9a80ac17ab747 (diff)
downloadmako-7c526147cf55d9b4656e59ee4db83cccfb4b861d.tar.gz
- TemplateLookup raises TopLevelLookupException for
a given path that is a directory, not a filename, instead of passing through to the template to generate IOError. [ticket:73]
-rw-r--r--CHANGES5
-rw-r--r--mako/lookup.py2
-rw-r--r--test/test_lookup.py7
3 files changed, 13 insertions, 1 deletions
diff --git a/CHANGES b/CHANGES
index eb38534..7f7d0a9 100644
--- a/CHANGES
+++ b/CHANGES
@@ -50,6 +50,11 @@
drive etc.) and no URI - the URI is converted
to a forward-slash path and module_directory
is treated as a windows path. [ticket:128]
+
+- TemplateLookup raises TopLevelLookupException for
+ a given path that is a directory, not a filename,
+ instead of passing through to the template to
+ generate IOError. [ticket:73]
0.2.6
diff --git a/mako/lookup.py b/mako/lookup.py
index 0398c5e..8514a8a 100644
--- a/mako/lookup.py
+++ b/mako/lookup.py
@@ -107,7 +107,7 @@ class TemplateLookup(TemplateCollection):
u = re.sub(r'^\/+', '', uri)
for dir in self.directories:
srcfile = posixpath.normpath(posixpath.join(dir, u))
- if os.path.exists(srcfile):
+ if os.path.isfile(srcfile):
return self._load(srcfile, uri)
else:
raise exceptions.TopLevelLookupException(
diff --git a/test/test_lookup.py b/test/test_lookup.py
index 4d6644d..5e6cb24 100644
--- a/test/test_lookup.py
+++ b/test/test_lookup.py
@@ -29,6 +29,13 @@ class LookupTest(unittest.TestCase):
"this is include 2"
]
+
+ def test_directory_lookup(self):
+ """test that hitting an existent directory still raises LookupError."""
+
+ self.assertRaises(exceptions.TopLevelLookupException,
+ tl.get_template, "/subdir"
+ )
def test_no_lookup(self):
t = Template("hi <%include file='foo.html'/>")