diff options
author | Rodrigo Bernardo Pimentel <rbp@isnomore.net> | 2012-04-04 15:32:24 +0200 |
---|---|---|
committer | Rodrigo Bernardo Pimentel <rbp@isnomore.net> | 2012-04-04 15:32:24 +0200 |
commit | 350910b8da94bfc4eca59fe3096cbd286c7a45c6 (patch) | |
tree | b5dc3173f8608c51e02e0c9747db5b67e6cc82e5 /pystache | |
parent | 3c5a6db5a0fe7cfeaee04476419ca2b7ada18b1e (diff) | |
download | pystache-350910b8da94bfc4eca59fe3096cbd286c7a45c6.tar.gz |
Fixing logic mistake when determining auto-invoking. Added tests for this case.
Diffstat (limited to 'pystache')
-rw-r--r-- | pystache/context.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/pystache/context.py b/pystache/context.py index 139806d..4121dc5 100644 --- a/pystache/context.py +++ b/pystache/context.py @@ -29,6 +29,7 @@ def _get_value(item, key): """ parts = key.split('.') key = parts[0] + rest = '.'.join(parts[1:]) value = _NOT_FOUND if isinstance(item, dict): @@ -50,16 +51,14 @@ def _get_value(item, key): attr = getattr(item, key) # 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 + autocall = len(rest) == 0 if autocall and _is_callable(attr): value = attr() else: value = attr - for part in parts[1:]: - if value is _NOT_FOUND: - break - value = _get_value(value, part) + if rest and value is not _NOT_FOUND: + value = _get_value(value, rest) return value |