diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-08-03 13:41:15 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-08-03 13:41:15 -0400 |
| commit | 3bd802b9504d9d6f81cb35801cc61267f1f9697c (patch) | |
| tree | 6bad3fb801a7a5ba261b2d868283977113f069da | |
| parent | faf3a4d7bdde373a73c74fe70af87de841de800e (diff) | |
| download | external_python_mako-3bd802b9504d9d6f81cb35801cc61267f1f9697c.tar.gz external_python_mako-3bd802b9504d9d6f81cb35801cc61267f1f9697c.tar.bz2 external_python_mako-3bd802b9504d9d6f81cb35801cc61267f1f9697c.zip | |
- [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]
| -rw-r--r-- | CHANGES | 5 | ||||
| -rw-r--r-- | mako/runtime.py | 12 | ||||
| -rw-r--r-- | test/foo/test_ns.py | 7 |
3 files changed, 16 insertions, 8 deletions
@@ -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 @@ class ModuleNamespace(Namespace): 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 |
