- [bug] Using <%namespace import="*" module="somemodule"/> now
skips over module elements that are not explcitly callable,
avoiding TypeError when trying to produce partials.
[ticket:207]
diff --git a/CHANGES b/CHANGES
index eaa5b5e..b6c58f3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,11 @@
- [bug] The Babel plugin has been repaired to work on Python 3.
[ticket:187]
+- [bug] Using <%namespace import="*" module="somemodule"/> now
+ skips over module elements that are not explcitly callable,
+ avoiding TypeError when trying to produce partials.
+ [ticket:207]
+
0.8.1
- [bug] Changed setup.py to skip installing markupsafe
if Python version is < 2.6 or is between 3.0 and
diff --git a/mako/runtime.py b/mako/runtime.py
index 2bdbd9d..5c8cfe7 100644
--- a/mako/runtime.py
+++ b/mako/runtime.py
@@ -619,12 +619,12 @@
if self.callables:
for key in self.callables:
yield (key, self.callables[key])
- def get(key):
- callable_ = getattr(self.module, key)
- return compat.partial(callable_, self.context)
- for k in dir(self.module):
- if k[0] != '_':
- yield (k, get(k))
+ for key in dir(self.module):
+ if key[0] != '_':
+ callable_ = getattr(self.module, key)
+ if compat.callable(callable_):
+ yield key, compat.partial(callable_, self.context)
+
def __getattr__(self, key):
if key in self.callables:
diff --git a/test/foo/test_ns.py b/test/foo/test_ns.py
index 7a2425d..282447a 100644
--- a/test/foo/test_ns.py
+++ b/test/foo/test_ns.py
@@ -1,7 +1,10 @@
def foo1(context):
context.write("this is foo1.")
return ''
-
+
def foo2(context, x):
context.write("this is foo2, x is " + x)
- return ''
\ No newline at end of file
+ return ''
+
+
+foo3 = "I'm not a callable"
\ No newline at end of file