Commit 9053cc93 authored by Julien Muchembled's avatar Julien Muchembled

Ignore read-only transaction cache when getting a category from a new or temp object

The purpose is to be able to use the amount generator during indexation.
At some point, it executes:

        if amount.getQuantityUnit():
        ...
        for x in property_dict.iteritems():
          amount._setProperty(*x)

where `amount.getQuantityUnit()` may getResource before it is set.
Any further access to the resource category would be wrong.

There may be a way to only change the amount generator but this kind
of pitfall is likely to happen in many other places if we keep such
a read-only transaction cache for new or temp objects.

See merge request !1818
parent 447e4be3
Pipeline #29859 failed with stage
in 0 seconds
......@@ -840,14 +840,17 @@ class CategoryTool(BaseTool):
# XXX: This cache is rarely useful, and the overhead quite important.
# It would certainly become counter-productive if any significative
# improvement was done to the cached methods.
cache = getReadOnlyTransactionCache()
if cache is not None:
key = ('getSingleCategoryAcquiredMembershipList', context,
base_category, base, spec, filter, repr(kw))
try:
return cache[key]
except KeyError:
pass
if getattr(context, '_p_jar', None) is None: # new or temporary
cache = None
else:
cache = getReadOnlyTransactionCache()
if cache is not None:
key = ('getSingleCategoryAcquiredMembershipList', context,
base_category, base, spec, filter, repr(kw))
try:
return cache[key]
except KeyError:
pass
result = self._getSingleCategoryAcquiredMembershipList(context, base_category, base=base,
spec=spec, filter=filter,
......
  • It seems erp5_simulation_performance_test:testSimulationElementPerformance fails after this change.

  • If you mean it's slower, then the test limits has to be raised.

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