@ -278,22 +278,22 @@ class Block(Base, Become, Conditional, Taggable):
for dep in dep_chain :
for dep in dep_chain :
dep . set_loader ( loader )
dep . set_loader ( loader )
def _get_attr_environment ( self ) :
return self . _get_parent_attribute ( ' environment ' , extend = True , prepend = True )
def _get_parent_attribute ( self , attr , extend = False , prepend = False ) :
def _get_parent_attribute ( self , attr , extend = False , prepend = False ) :
'''
'''
Generic logic to get the attribute or parent attribute for a block value .
Generic logic to get the attribute or parent attribute for a block value .
'''
'''
value = None
extend = self . _valid_attrs [ attr ] . extend
prepend = self . _valid_attrs [ attr ] . prepend
try :
try :
value = self . _attributes [ attr ]
value = self . _attributes [ attr ]
if self . _parent and ( value is None or extend ) :
if self . _parent and ( value is None or extend ) :
try :
try :
if attr != ' when ' or getattr ( self . _parent , ' statically_loaded ' , True ) :
if getattr ( self . _parent , ' statically_loaded ' , True ) :
parent_value = getattr ( self . _parent , attr , None )
if hasattr ( self . _parent , ' _get_parent_attribute ' ) :
parent_value = self . _parent . _get_parent_attribute ( attr )
else :
parent_value = self . _parent . _attributes . get ( attr , None )
if extend :
if extend :
value = self . _extend_value ( value , parent_value , prepend )
value = self . _extend_value ( value , parent_value , prepend )
else :
else :
@ -302,7 +302,10 @@ class Block(Base, Become, Conditional, Taggable):
pass
pass
if self . _role and ( value is None or extend ) :
if self . _role and ( value is None or extend ) :
try :
try :
parent_value = getattr ( self . _role , attr , None )
if hasattr ( self . _role , ' _get_parent_attribute ' ) :
parent_value = self . _role . get_parent_attribute ( attr )
else :
parent_value = self . _role . _attributes . get ( attr , None )
if extend :
if extend :
value = self . _extend_value ( value , parent_value , prepend )
value = self . _extend_value ( value , parent_value , prepend )
else :
else :
@ -312,7 +315,10 @@ class Block(Base, Become, Conditional, Taggable):
if dep_chain and ( value is None or extend ) :
if dep_chain and ( value is None or extend ) :
dep_chain . reverse ( )
dep_chain . reverse ( )
for dep in dep_chain :
for dep in dep_chain :
dep_value = getattr ( dep , attr , None )
if hasattr ( dep , ' _get_parent_attribute ' ) :
dep_value = dep . _get_parent_attribute ( attr )
else :
dep_value = dep . _attributes . get ( attr , None )
if extend :
if extend :
value = self . _extend_value ( value , dep_value , prepend )
value = self . _extend_value ( value , dep_value , prepend )
else :
else :
@ -324,11 +330,12 @@ class Block(Base, Become, Conditional, Taggable):
pass
pass
if self . _play and ( value is None or extend ) :
if self . _play and ( value is None or extend ) :
try :
try :
parent_value = getattr ( self . _play , attr , None )
play_value = self . _play . _attributes . get ( attr , None )
if extend :
if play_value is not None :
value = self . _extend_value ( value , parent_value , prepend )
if extend :
else :
value = self . _extend_value ( value , play_value , prepend )
value = parent_value
else :
value = play_value
except AttributeError :
except AttributeError :
pass
pass
except KeyError :
except KeyError :