mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Don't do parent stuff during serialize if squashed or finalized
This commit is contained in:
parent
cddf1cf98e
commit
9ecec6c28e
2 changed files with 11 additions and 11 deletions
|
@ -312,12 +312,7 @@ class Base(with_metaclass(BaseMeta, object)):
|
||||||
'''
|
'''
|
||||||
if not self._squashed:
|
if not self._squashed:
|
||||||
for name in self._valid_attrs.keys():
|
for name in self._valid_attrs.keys():
|
||||||
getter = partial(_generic_g, name)
|
|
||||||
setter = partial(_generic_s, name)
|
|
||||||
deleter = partial(_generic_d, name)
|
|
||||||
|
|
||||||
self._attributes[name] = getattr(self, name)
|
self._attributes[name] = getattr(self, name)
|
||||||
#print("squashed attr %s: %s" % (name, self._attributes[name]))
|
|
||||||
self._squashed = True
|
self._squashed = True
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
|
@ -516,7 +511,9 @@ class Base(with_metaclass(BaseMeta, object)):
|
||||||
repr[name] = getattr(self, name)
|
repr[name] = getattr(self, name)
|
||||||
|
|
||||||
# serialize the uuid field
|
# serialize the uuid field
|
||||||
repr['uuid'] = getattr(self, '_uuid')
|
repr['uuid'] = self._uuid
|
||||||
|
repr['finalized'] = self._finalized
|
||||||
|
repr['squashed'] = self._squashed
|
||||||
|
|
||||||
return repr
|
return repr
|
||||||
|
|
||||||
|
@ -538,4 +535,6 @@ class Base(with_metaclass(BaseMeta, object)):
|
||||||
|
|
||||||
# restore the UUID field
|
# restore the UUID field
|
||||||
setattr(self, '_uuid', data.get('uuid'))
|
setattr(self, '_uuid', data.get('uuid'))
|
||||||
|
self._finalized = data.get('finalized', False)
|
||||||
|
self._squashed = data.get('squashed', False)
|
||||||
|
|
||||||
|
|
|
@ -342,12 +342,13 @@ class Task(Base, Conditional, Taggable, Become):
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
data = super(Task, self).serialize()
|
data = super(Task, self).serialize()
|
||||||
|
|
||||||
if self._parent:
|
if not self._squashed and not self._finalized:
|
||||||
data['parent'] = self._parent.serialize()
|
if self._parent:
|
||||||
data['parent_type'] = self._parent.__class__.__name__
|
data['parent'] = self._parent.serialize()
|
||||||
|
data['parent_type'] = self._parent.__class__.__name__
|
||||||
|
|
||||||
if self._role:
|
if self._role:
|
||||||
data['role'] = self._role.serialize()
|
data['role'] = self._role.serialize()
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue