Commit 5480a87e authored by Nicolas Dumazet's avatar Nicolas Dumazet

getAggregatedAmountList: generated temporary ids must be context-dependent

This fixes an interesting bug:
  # Takes place during indexing phase, when Transactional Cache is on

  # A transformation is defined, producing a (blue|red) resource from
  # (blue|red) fabric
  transformation = ...

  movement1 = newTempMovement(colour="blue", resource=A)
  movement2 = newTempMovement(colour="red", resource=A)

  amount1 = transformation.getAggregatedAmountList(movement1)[0]
  amount2 = transformation.getAggregatedAmountList(movement2)[0]

  # amount1 and amount2 have wrongly the same Physical path.
  # Which means that due to caching in CategoryTool, the category
  # values will be computed only once instead of twice:
  assert amount1.getVariationText() == "colour/blue" #OK
  assert amount2.getVariationText() == "colour/blue" # !!



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33314 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ff3ad812
......@@ -172,7 +172,8 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
aggregated_amount_list = AggregatedAmountList()
base_application_list = self.getBaseApplicationList()
self_id = self.getParentValue().getId() + '_' + self.getId()
document = self.getParentValue()
self_id = '_'.join(document.getId(), self.getId(), context.getId())
# Make tmp movement list only when trade model line is not set to movement level.
tmp_movement_list = []
......@@ -185,7 +186,6 @@ class TradeModelLine(Predicate, XMLMatrix, Amount):
update = 1
else:
# get source and destination using Business Process
document = self.getParentValue()
if getattr(document, 'findSpecialiseValueList', None) is None:
# if parent don't have findSpecialiseValueList, this mean it's on the
# specialise_value
......
......@@ -181,11 +181,12 @@ class TransformedResource(Predicate, XMLObject, XMLMatrix, Amount):
# If no predicate is defined on line, the result of the test
# must be true
# Create temporary object to store amount
# XXX changed by TB getParentID()+getId() instead of getId()
# This might not be enough if we have different transformation
# with the same id (for example in several modules)
parent = self.getParentValue()
tmp_amount = parent.newContent(id=self.getParentId()+'_'+self.getId(),
# Be careful: this id must be unique, and change when the context is
# changing. Failure to do so exposes to possible erroneous cache hits
# for physical path based caching.
tmp_id = '_'.join((parent.getId(), self.getId(), context.getId()))
tmp_amount = parent.newContent(id=tmp_id,
temp_object=1, portal_type=self.getPortalType())
# Create error string
error_string = ''
......
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