Commit 47fbbd53 authored by Julien Muchembled's avatar Julien Muchembled

Small optimizations

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@37909 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c996e3e2
......@@ -588,18 +588,12 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
#
# store a causality -> causality_related_movement_list mapping
causality_dict = dict()
current = self.getParentValue()
while True:
portal_type = current.getPortalType()
if portal_type == "Simulation Movement":
causality_dict = {}
current = self.getParentValue().getParentValue()
while current.getPortalType() == "Simulation Movement":
causality_dict[current.getCausality(portal_type='Business Link')] = \
current
elif portal_type != "Applied Rule":
break
# XXX or maybe directly go up by two levels?
current = current.getParentValue()
current = current.getParentValue().getParentValue()
remaining_path_set = set()
for path in predecessor_path_list:
......
......@@ -185,27 +185,26 @@ class ExplanationCache:
kw_tuple = tuple(kw.items()) # We hope that no sorting is needed
def getParentSimulationMovementValueList(obj, movement_list, trade_phase):
if getattr(obj, "getParentValue", None):
parent = obj.getParentValue()
if parent is not None:
if parent.getPortalType() == "Simulation Movement" and \
parent.getCausalityValue().isMemberOf(trade_phase, strict_membership=1):
while parent.getPortalType() == "Simulation Movement":
if parent.getCausalityValue(
).isMemberOf(trade_phase, strict_membership=1):
movement_list.append(parent)
getParentSimulationMovementValueList(parent, movement_list, trade_phase)
parent = parent.getParentValue().getParentValue()
def getChildSimulationMovementValueList(obj, movement_list, trade_phase):
child_list = obj.objectValues()
for child in child_list:
if child.getPortalType() == "Simulation Movement" and \
child.getCausalityValue().isMemberOf(trade_phase, strict_membership=1):
for child in obj.objectValues():
if (child.getPortalType() == "Simulation Movement" and
child.getCausalityValue(
).isMemberOf(trade_phase, strict_membership=1)):
movement_list.append(child)
getChildSimulationMovementValueList(child, movement_list, trade_phase)
if self.simulation_movement_cache.get(kw_tuple, None) is None:
if kw_tuple not in self.simulation_movement_cache:
if self.explanation.getPortalType() == "Applied Rule":
movement_list = []
getParentSimulationMovementValueList(self.explanation, movement_list, kw.get('trade_phase', None))
getChildSimulationMovementValueList(self.explanation, movement_list, kw.get('trade_phase', None))
getParentSimulationMovementValueList(self.explanation, movement_list, kw['trade_phase'])
getChildSimulationMovementValueList(self.explanation, movement_list, kw['trade_phase'])
self.simulation_movement_cache[kw_tuple] = movement_list
else:
# XXX-Aurel : the following code seems not working as expected, it returns
......
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