- better error message when a lookup is attempted with a template that has no lookup
diff --git a/CHANGES b/CHANGES
index 56fb1fa..8408878 100644
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,7 @@
 - fix so that "cache_timeout" parameter is propigated
 - fix to expression filters so that string conversion (actually unicode) properly 
 occurs before filtering
+- better error message when a lookup is attempted with a template that has no lookup
 
 0.1.0
 
diff --git a/lib/mako/runtime.py b/lib/mako/runtime.py
index 727eb3c..c91f548 100644
--- a/lib/mako/runtime.py
+++ b/lib/mako/runtime.py
@@ -219,6 +219,8 @@
 
 def _lookup_template(context, uri, relativeto):
     lookup = context._with_template.lookup
+    if lookup is None:
+        raise exceptions.TemplateLookupException("Template '%s' has no TemplateLookup associated" % context._with_template.uri)
     uri = lookup.adjust_uri(uri, relativeto)
     try:
         return lookup.get_template(uri)
diff --git a/test/lookup.py b/test/lookup.py
index bb56a70..18a6d1c 100644
--- a/test/lookup.py
+++ b/test/lookup.py
@@ -1,5 +1,5 @@
 from mako.template import Template
-from mako import lookup
+from mako import lookup, exceptions
 from util import flatten_result, result_lines
 import unittest
 
@@ -35,7 +35,15 @@
         ]
 
         assert tl.get_template('/subdir/index.html').module_id == '_subdir_index_html'
-        
+    
+    def test_no_lookup(self):
+        t = Template("hi <%include file='foo.html'/>")
+        try:
+            t.render()
+            assert False
+        except exceptions.TemplateLookupException, e:
+            assert str(e) == "Template 'memory:%s' has no TemplateLookup associated" % hex(id(t))
+            
     def test_uri_adjust(self):
         tl = lookup.TemplateLookup(directories=['/foo/bar'])
         assert tl.filename_to_uri('/foo/bar/etc/lala/index.html') == '/etc/lala/index.html'