diff options
author | Rodrigo Bernardo Pimentel <rbp@isnomore.net> | 2012-04-04 15:13:57 +0200 |
---|---|---|
committer | Rodrigo Bernardo Pimentel <rbp@isnomore.net> | 2012-04-04 15:13:57 +0200 |
commit | 3c5a6db5a0fe7cfeaee04476419ca2b7ada18b1e (patch) | |
tree | 913fafef59f7af3980ba9f2802f3037f9d943d00 | |
parent | ca2cd4c0651b7d6e2e9e999323af96815723e9f5 (diff) | |
download | pystache-3c5a6db5a0fe7cfeaee04476419ca2b7ada18b1e.tar.gz |
Not auto-invoking when there are still dot notation parts to examine. The previous behaviour breaks calls like foo.bar.baz, if foo.bar defines __call__
-rw-r--r-- | pystache/context.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/pystache/context.py b/pystache/context.py index 2ebf549..139806d 100644 --- a/pystache/context.py +++ b/pystache/context.py @@ -48,7 +48,10 @@ def _get_value(item, key): # are considered objects by the test above. if hasattr(item, key): attr = getattr(item, key) - if _is_callable(attr): + # If there are still parts to process (in a dot-notation key), + # we do not automatically invoke the object, even if it's callable. + autocall = len(parts) > 1 + if autocall and _is_callable(attr): value = attr() else: value = attr |