Commit 0528f9c6 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Delivery: Fix maximum recursion depth in getRootCausalityValueList().

Pattern: SIT_1 => RSPL => SIT_1.

Also, this reduces the complexity by not checking objects twice.
parent 38e4be07
...@@ -710,21 +710,28 @@ class Delivery(XMLObject, ImmobilisationDelivery, SimulableMixin, ...@@ -710,21 +710,28 @@ class Delivery(XMLObject, ImmobilisationDelivery, SimulableMixin,
This method will look at the causality and check if the This method will look at the causality and check if the
causality has already a causality causality has already a causality
""" """
causality_value_list = self.getCausalityValueList() seen_set = set()
if causality_value_list: def recursive(self):
initial_list = [] if self in seen_set:
for causality in causality_value_list: return []
# The causality may be something which has not this method
# (e.g. item) seen_set.add(self)
try: causality_value_list = self.getCausalityValueList()
getRootCausalityValueList = causality.getRootCausalityValueList if causality_value_list:
except AttributeError: initial_list = []
continue for causality in causality_value_list:
assert causality != self # The causality may be something which has not this method
initial_list += [x for x in getRootCausalityValueList() # (e.g. item)
if getattr(causality, 'getRootCausalityValueList', None) is None:
continue
assert causality != self
initial_list += [x for x in recursive(causality)
if x not in initial_list] if x not in initial_list]
return initial_list return initial_list
return [self] return [self]
return recursive(self)
# XXX Temp hack, should be removed has soon as the structure of # XXX Temp hack, should be removed has soon as the structure of
# the order/delivery builder will be reviewed. It might # the order/delivery builder will be reviewed. It might
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment