Commit c0b284be authored by Vincent Pelletier's avatar Vincent Pelletier

all: Remove recursiveImmediateReindexObject, and references to it.

This method does not belong to Folder (nor Base, even as an alias), as
it recurses wihout any limit in a tree whose node count is unknown.
Such generic recursion should either be deferred (split in multiple
transactions, each processing a limited chunk of the tree) or not be
recursive (which of course depends on the need).
There is a single caller left (constructInstance) where the subtree size
is assumed to be reasonable, as it was constructed inside current
transaction. So essentially rename this method so it is only used in such
conditions.
parent 5c4c69a0
......@@ -21,8 +21,7 @@ for builder_id in builder_id_list:
after_tag = index_tag
# depend on reindexing so that select methods
# do not return movements that are already built
after_method_id = ('recursiveImmediateReindexObject',
'immediateReindexObject',
after_method_id = ('immediateReindexObject',
'_updateSimulation')
activate_kw = dict(tag=index_tag)
builder.activate(
......
......@@ -33,8 +33,7 @@ for builder_id in builder_id_list:
after_tag = index_tag
# depend on reindexing so that select methods
# do not return movements that are already built
after_method_id = ('recursiveImmediateReindexObject',
'immediateReindexObject',
after_method_id = ('immediateReindexObject',
'_updateSimulation')
activate_kw = dict(tag=index_tag)
builder.activate(
......
......@@ -30,8 +30,7 @@ for builder_id in builder_id_list:
after_tag = index_tag
# depend on reindexing so that select methods
# do not return movements that are already built
after_method_id = ('recursiveImmediateReindexObject',
'immediateReindexObject',
after_method_id = ('immediateReindexObject',
'_updateSimulation')
activate_kw = dict(tag=index_tag)
builder.activate(
......
......@@ -6,5 +6,5 @@ if web_page.getPublicationSection() == "application/landing_page":
software_product.activate(
after_path_and_method_id=(
(web_page.getPath(),),
("immediateReindexObject", "recursiveImmediateReindexObject")
("immediateReindexObject", )
)).SoftwareProduct_fixRelatedWebSite()
......@@ -36,11 +36,9 @@ if configurator.getSimulationState() == "draft":
# create users if installation is done
try:
context.portal_categories.activate(after_method_id = ('ERP5Site_afterConfigurationSetup',
'recursiveImmediateReindexObject',
'immediateReindexObject')
).ERP5Site_createTestData(user_quantity, password)
context.portal_categories.activate(after_method_id = ('ERP5Site_afterConfigurationSetup',
'recursiveImmediateReindexObject',
'immediateReindexObject')
).ERP5Site_setIdGenerator()
except Exception as e:
......
......@@ -8,8 +8,7 @@ builder = delivery.getPortalObject().portal_deliveries[{
delivery_portal_type = builder.getDeliveryPortalType()
serialization_tag = 'build:' + delivery_portal_type
index_tag = 'index:' + delivery_portal_type
after_method_id = ('recursiveImmediateReindexObject',
'immediateReindexObject',
after_method_id = ('immediateReindexObject',
'expand',
'_updateSimulation')
activate_kw = dict(tag=index_tag)
......
......@@ -21,8 +21,7 @@ for builder_id in builder_id_list:
after_tag = index_tag
# depend on reindexing so that select methods
# do not return movements that are already built
after_method_id = ('recursiveImmediateReindexObject',
'immediateReindexObject',
after_method_id = ('immediateReindexObject',
'_updateSimulation')
activate_kw = dict(tag=index_tag)
builder.activate(
......
......@@ -22,8 +22,7 @@ for builder_id in builder_id_list:
after_tag = index_tag
# depend on reindexing so that select methods
# do not return movements that are already built
after_method_id = ('recursiveImmediateReindexObject',
'immediateReindexObject',
after_method_id = ('immediateReindexObject',
'_updateSimulation')
activate_kw = dict(tag=index_tag)
builder.activate(
......
......@@ -271,7 +271,6 @@ class AppliedRule(XMLObject, ExplainableMixin):
if rar_list and portal.portal_activities.countMessage(
path=[x.getPath() for x in rar_list],
method_id=('immediateReindexObject',
'recursiveImmediateReindexObject',
'recursiveImmediateReindexSimulationMovement')):
raise ConflictError
# Do not try to keep simulation tree for a draft delivery
......
......@@ -52,6 +52,3 @@ class BalanceTransactionLine(AccountingTransactionLine, InventoryLine):
reindexObject = InventoryLine.reindexObject
recursiveReindexObject = InventoryLine.recursiveReindexObject
immediateReindexObject = InventoryLine.immediateReindexObject
recursiveImmediateReindexObject = \
InventoryLine.recursiveImmediateReindexObject
......@@ -505,26 +505,6 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
root_rule = self.getRootAppliedRule()
return root_rule.getCausalityValueList()
# XXX FIXME Use a interaction workflow instead
# XXX This behavior is now done by simulation_movement_interaction_workflow
# The call to activate() must be done after actual call to
# setDelivery() on the movement,
# but activate() must be called on the previous delivery...
#def _setDelivery(self, value):
# LOG('setDelivery before', 0, '')
# delivery_value = self.getDeliveryValue()
# Movement.setDelivery(value)
# LOG('setDelivery', 0, '')
# if delivery_value is not None:
# LOG('delivery_value = ', 0, repr(delivery_value))
# activity = delivery_value.activate(
# activity='SQLQueue',
# after_path_and_method_id=(
# self.getPath(),
# ['immediateReindexObject',
# 'recursiveImmediateReindexObject']))
# activity.edit()
def _isTreeDelivered(self):
"""
checks if subapplied rules of this movement (going down the complete
......
......@@ -1973,7 +1973,7 @@ class ERP5Generator(PortalGenerator):
# nodes have nothing else to do.
after_method_id = tuple({after_method_id}.union(('Folder_reindexAll',
'Folder_reindexObjectList', 'InventoryModule_reindexMovementList',
'immediateReindexObject', 'recursiveImmediateReindexObject', 'SQLCatalog_deferFullTextIndexActivity')))
'immediateReindexObject', 'SQLCatalog_deferFullTextIndexActivity')))
p.portal_activities.activateObject(p, after_method_id=after_method_id,
)._delPropValue(id_)
......
......@@ -98,13 +98,11 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
self.ImmediateReindexObjectIsCalled()
from Products.ERP5Type.Document.Organisation import Organisation
Organisation.immediateReindexObject = crashingMethod
Organisation.recursiveImmediateReindexObject = crashingMethod
def beforeTearDown(self):
# Remove crashing method
from Products.ERP5Type.Document.Organisation import Organisation
del Organisation.immediateReindexObject
del Organisation.recursiveImmediateReindexObject
def createCategories(self):
"""
......@@ -188,8 +186,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertTrue(len(message_list) > 0)
self.assertTrue(len(message_list) < 3)
for method_id in method_id_list:
self.assertTrue(method_id in ["immediateReindexObject",
"recursiveImmediateReindexObject"])
self.assertTrue(method_id in ["immediateReindexObject"])
def stepSetSameTitleValueWithEdit(self, sequence=None, sequence_list=None,
**kw):
......
......@@ -120,8 +120,7 @@ class TestERP5Simulation(TestPackingListMixin, SecurityTestCase):
after_tag.append(previous_tag)
delivery_builder.activate(
after_method_id=('solve',
'immediateReindexObject',
'recursiveImmediateReindexObject',), # XXX too brutal.
'immediateReindexObject'), # XXX too brutal.
after_tag=after_tag,
).build(explanation_uid=packing_list.getCausalityValue().getUid())
......
......@@ -1006,8 +1006,7 @@ class TestPackingListMixin(TestOrderMixin):
after_tag.append(previous_tag)
delivery_builder.activate(
after_method_id=('solve',
'immediateReindexObject',
'recursiveImmediateReindexObject',), # XXX too brutal.
'immediateReindexObject'), # XXX too brutal.
after_tag=after_tag,
).build(explanation_uid=packing_list.getCausalityValue().getUid())
......
......@@ -335,7 +335,6 @@ class BusinessConfiguration(Item):
"""
kw = dict(tag="start_configuration_%s" % self.getId(),
after_method_id=["updateBusinessTemplateFromUrl",
"recursiveImmediateReindexObject",
"immediateReindexObject"])
# build
configuration_save_list = self.contentValues(portal_type='Configuration Save')
......@@ -353,8 +352,7 @@ class BusinessConfiguration(Item):
configurator_item.getUid())
kw["tag"] = "final_configuration_step_%s" % self.getId()
kw["after_method_id"] = ["fixConsistency", 'immediateReindexObject', \
"recursiveImmediateReindexObject"]
kw["after_method_id"] = ["fixConsistency", 'immediateReindexObject']
self.activate(**kw).ERP5Site_afterConfigurationSetup()
......
......@@ -2820,9 +2820,7 @@ class Base( CopyContainer,
if self.isAncestryIndexable():
with super_user():
PortalContent.reindexObject(self, *args, **kw)
security.declarePrivate('recursiveImmediateReindexObject')
recursiveImmediateReindexObject = immediateReindexObject
_reindexOnCreation = immediateReindexObject
security.declarePublic('reindexObject')
def reindexObject(self, *args, **kw):
......
......@@ -1266,14 +1266,19 @@ class Folder(CopyContainer, OFSFolder2, CMFBTreeFolder, CMFHBTreeFolder, Base, F
value_list.extend(c.getIndexableChildValueList())
return value_list
security.declarePrivate('recursiveImmediateReindexObject')
def recursiveImmediateReindexObject(self, **kw):
if self.isIndexable and int(getattr(self.getPortalObject(), 'isIndexable', 1)):
self.immediateReindexObject(**kw)
for c in self.objectValues():
if getattr(aq_base(c),
'recursiveImmediateReindexObject', None) is not None:
c.recursiveImmediateReindexObject(**kw)
def _reindexOnCreation(self, **reindex_kw):
"""
Immediately and recursively reindex self, a document which was created
(bound to its parent) within current transaction.
Here, immediate recursion is expected to be fine as document tree just
created: assume we can iterate over what was just created without causing
memory exhaustion.
"""
self.immediateReindexObject(**reindex_kw)
dummy = lambda **kw: None
for document in self.objectValues():
getattr(document, '_reindexOnCreation', dummy)(**reindex_kw)
security.declareProtected(Permissions.ModifyPortalContent, 'moveObject')
def moveObject(self, idxs=None):
......
......@@ -454,7 +454,7 @@ class ERP5TypeInformation(XMLObject,
# (activities). Or just not request immediate indexation.
# - if ImmediateReindexContextManager is used, anything until
# context manager exits.
method = ob.recursiveImmediateReindexObject
method = ob._reindexOnCreation
if reindex_kw is not None:
method = partial(method, **reindex_kw)
if isinstance(immediate_reindex, ImmediateReindexContextManager):
......
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