avoid persistent containers in attribute defaults

moved from the field attribute declaration and created a placeholder
which then is resolved in the field attribute class.

this is to avoid unwanted persistent of the defaults across objects which introduces
stealth bugs when multiple objects of the same kind are used in succession while
not overriding the default values.
This commit is contained in:
Brian Coca 2015-12-09 07:21:00 -08:00
parent 0719eb3e2d
commit 87969868d4
9 changed files with 29 additions and 18 deletions

View file

@ -33,7 +33,7 @@ class Conditional:
to be run conditionally when a condition is met or skipped.
'''
_when = FieldAttribute(isa='list', default=[])
_when = FieldAttribute(isa='list', default='_ansible_container')
def __init__(self, loader=None):
# when used directly, this class needs a loader, but we want to