Skip self._parent on dynamic, defer to grandparent for attr lookup (#38827)

* Skip self._parent on dynamic, defer to grandparent for attr lookup

* Revert _inheritable

* Add tests for include inheritance from static blocks

Fixes #38037 #36194
This commit is contained in:
Matt Martz 2018-04-16 16:46:47 -05:00 committed by GitHub
commit 354aa8d602
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 63 additions and 16 deletions

View file

@ -298,13 +298,20 @@ class Block(Base, Become, Conditional, Taggable):
prepend = self._valid_attrs[attr].prepend
try:
value = self._attributes[attr]
if self._parent and (value is None or extend):
# If parent is static, we can grab attrs from the parent
# otherwise, defer to the grandparent
if getattr(self._parent, 'statically_loaded', True):
_parent = self._parent
else:
_parent = self._parent._parent
if _parent and (value is None or extend):
try:
if getattr(self._parent, 'statically_loaded', True):
if hasattr(self._parent, '_get_parent_attribute'):
parent_value = self._parent._get_parent_attribute(attr)
if getattr(_parent, 'statically_loaded', True):
if hasattr(_parent, '_get_parent_attribute'):
parent_value = _parent._get_parent_attribute(attr)
else:
parent_value = self._parent._attributes.get(attr, None)
parent_value = _parent._attributes.get(attr, None)
if extend:
value = self._extend_value(value, parent_value, prepend)
else: