Commit 1d6b777c authored by Yoshinori Okuji's avatar Yoshinori Okuji

Use references only, as using portal types as keys does not make sense. Also,...

Use references only, as using portal types as keys does not make sense. Also, skip calling Rule.test, because it should have been called implicitly by searchRuleList.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37739 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1c414ff9
...@@ -243,22 +243,22 @@ class SimulationMovement(Movement, PropertyRecordableMixin): ...@@ -243,22 +243,22 @@ class SimulationMovement(Movement, PropertyRecordableMixin):
applicable_rule_dict = {} applicable_rule_dict = {}
for rule in portal_rules.searchRuleList(self, sort_on='version', for rule in portal_rules.searchRuleList(self, sort_on='version',
sort_order='descending'): sort_order='descending'):
ref = rule.getReference() reference = rule.getReference()
if ref and ref not in applicable_rule_dict: if reference:
applicable_rule_dict[ref] = rule applicable_rule_dict.setdefault(reference, []).append(rule)
for applied_rule in list(self.objectValues()): for applied_rule in list(self.objectValues()):
rule = applied_rule.getSpecialiseValue() rule = applied_rule.getSpecialiseValue()
if not applied_rule._isTreeDelivered() and not rule.test(self): if rule in applicable_rule_dict.get(rule.getReference(), ()) \
self._delObject(applied_rule.getId()) or applied_rule._isTreeDelivered():
applied_rule_dict[rule.getReference()] = applied_rule
else: else:
applied_rule_dict[rule.getPortalType()] = applied_rule self._delObject(applied_rule.getId())
for rule in applicable_rule_dict.itervalues(): for reference, rule_list in applicable_rule_dict.iteritems():
rule_type = rule.getPortalType() if reference not in applied_rule_dict:
if rule_type not in applied_rule_dict: applied_rule = rule_list[0].constructNewAppliedRule(self, **kw)
applied_rule = rule.constructNewAppliedRule(self, **kw) applied_rule_dict[reference] = applied_rule
applied_rule_dict[rule_type] = applied_rule
self.setCausalityState('expanded') self.setCausalityState('expanded')
# expand # expand
......
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