diff piecrust/data/base.py @ 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 32c7c2d219d2
children 1d5f02778723
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))