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:
|
||||
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)
|
||||
#print("squashed attr %s: %s" % (name, self._attributes[name]))
|
||||
self._squashed = True
|
||||
|
||||
def copy(self):
|
||||
|
@ -516,7 +511,9 @@ class Base(with_metaclass(BaseMeta, object)):
|
|||
repr[name] = getattr(self, name)
|
||||
|
||||
# serialize the uuid field
|
||||
repr['uuid'] = getattr(self, '_uuid')
|
||||
repr['uuid'] = self._uuid
|
||||
repr['finalized'] = self._finalized
|
||||
repr['squashed'] = self._squashed
|
||||
|
||||
return repr
|
||||
|
||||
|
@ -538,4 +535,6 @@ class Base(with_metaclass(BaseMeta, object)):
|
|||
|
||||
# restore the UUID field
|
||||
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):
|
||||
data = super(Task, self).serialize()
|
||||
|
||||
if self._parent:
|
||||
data['parent'] = self._parent.serialize()
|
||||
data['parent_type'] = self._parent.__class__.__name__
|
||||
if not self._squashed and not self._finalized:
|
||||
if self._parent:
|
||||
data['parent'] = self._parent.serialize()
|
||||
data['parent_type'] = self._parent.__class__.__name__
|
||||
|
||||
if self._role:
|
||||
data['role'] = self._role.serialize()
|
||||
if self._role:
|
||||
data['role'] = self._role.serialize()
|
||||
|
||||
return data
|
||||
|
||||
|
|
Loading…
Reference in a new issue