Mercurial > piecrust2
changeset 713:d446029c9478
data: Support both objects and dictionaries in `MergedMapping`.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 26 May 2016 20:44:18 -0700 |
parents | aed8a860c1d0 |
children | e4dcef2d5640 |
files | piecrust/data/base.py |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/data/base.py Thu May 26 20:43:51 2016 -0700 +++ b/piecrust/data/base.py Thu May 26 20:44:18 2016 -0700 @@ -19,10 +19,18 @@ values = [] for d in self._dicts: try: + val = getattr(d, name) + values.append(val) + continue + except AttributeError: + pass + + try: val = d[name] + values.append(val) + continue except KeyError: - continue - values.append(val) + pass if len(values) == 0: raise KeyError("No such item: %s" % self._subp(name))