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: ...@@ -21,8 +21,7 @@ for builder_id in builder_id_list:
after_tag = index_tag after_tag = index_tag
# depend on reindexing so that select methods # depend on reindexing so that select methods
# do not return movements that are already built # do not return movements that are already built
after_method_id = ('recursiveImmediateReindexObject', after_method_id = ('immediateReindexObject',
'immediateReindexObject',
'_updateSimulation') '_updateSimulation')
activate_kw = dict(tag=index_tag) activate_kw = dict(tag=index_tag)
builder.activate( builder.activate(
......
...@@ -33,8 +33,7 @@ for builder_id in builder_id_list: ...@@ -33,8 +33,7 @@ for builder_id in builder_id_list:
after_tag = index_tag after_tag = index_tag
# depend on reindexing so that select methods # depend on reindexing so that select methods
# do not return movements that are already built # do not return movements that are already built
after_method_id = ('recursiveImmediateReindexObject', after_method_id = ('immediateReindexObject',
'immediateReindexObject',
'_updateSimulation') '_updateSimulation')
activate_kw = dict(tag=index_tag) activate_kw = dict(tag=index_tag)
builder.activate( builder.activate(
......
...@@ -30,8 +30,7 @@ for builder_id in builder_id_list: ...@@ -30,8 +30,7 @@ for builder_id in builder_id_list:
after_tag = index_tag after_tag = index_tag
# depend on reindexing so that select methods # depend on reindexing so that select methods
# do not return movements that are already built # do not return movements that are already built
after_method_id = ('recursiveImmediateReindexObject', after_method_id = ('immediateReindexObject',
'immediateReindexObject',
'_updateSimulation') '_updateSimulation')
activate_kw = dict(tag=index_tag) activate_kw = dict(tag=index_tag)
builder.activate( builder.activate(
......
...@@ -6,5 +6,5 @@ if web_page.getPublicationSection() == "application/landing_page": ...@@ -6,5 +6,5 @@ if web_page.getPublicationSection() == "application/landing_page":
software_product.activate( software_product.activate(
after_path_and_method_id=( after_path_and_method_id=(
(web_page.getPath(),), (web_page.getPath(),),
("immediateReindexObject", "recursiveImmediateReindexObject") ("immediateReindexObject", )
)).SoftwareProduct_fixRelatedWebSite() )).SoftwareProduct_fixRelatedWebSite()
...@@ -36,11 +36,9 @@ if configurator.getSimulationState() == "draft": ...@@ -36,11 +36,9 @@ if configurator.getSimulationState() == "draft":
# create users if installation is done # create users if installation is done
try: try:
context.portal_categories.activate(after_method_id = ('ERP5Site_afterConfigurationSetup', context.portal_categories.activate(after_method_id = ('ERP5Site_afterConfigurationSetup',
'recursiveImmediateReindexObject',
'immediateReindexObject') 'immediateReindexObject')
).ERP5Site_createTestData(user_quantity, password) ).ERP5Site_createTestData(user_quantity, password)
context.portal_categories.activate(after_method_id = ('ERP5Site_afterConfigurationSetup', context.portal_categories.activate(after_method_id = ('ERP5Site_afterConfigurationSetup',
'recursiveImmediateReindexObject',
'immediateReindexObject') 'immediateReindexObject')
).ERP5Site_setIdGenerator() ).ERP5Site_setIdGenerator()
except Exception as e: except Exception as e:
......
...@@ -8,8 +8,7 @@ builder = delivery.getPortalObject().portal_deliveries[{ ...@@ -8,8 +8,7 @@ builder = delivery.getPortalObject().portal_deliveries[{
delivery_portal_type = builder.getDeliveryPortalType() delivery_portal_type = builder.getDeliveryPortalType()
serialization_tag = 'build:' + delivery_portal_type serialization_tag = 'build:' + delivery_portal_type
index_tag = 'index:' + delivery_portal_type index_tag = 'index:' + delivery_portal_type
after_method_id = ('recursiveImmediateReindexObject', after_method_id = ('immediateReindexObject',
'immediateReindexObject',
'expand', 'expand',
'_updateSimulation') '_updateSimulation')
activate_kw = dict(tag=index_tag) activate_kw = dict(tag=index_tag)
......
...@@ -21,8 +21,7 @@ for builder_id in builder_id_list: ...@@ -21,8 +21,7 @@ for builder_id in builder_id_list:
after_tag = index_tag after_tag = index_tag
# depend on reindexing so that select methods # depend on reindexing so that select methods
# do not return movements that are already built # do not return movements that are already built
after_method_id = ('recursiveImmediateReindexObject', after_method_id = ('immediateReindexObject',
'immediateReindexObject',
'_updateSimulation') '_updateSimulation')
activate_kw = dict(tag=index_tag) activate_kw = dict(tag=index_tag)
builder.activate( builder.activate(
......
...@@ -22,8 +22,7 @@ for builder_id in builder_id_list: ...@@ -22,8 +22,7 @@ for builder_id in builder_id_list:
after_tag = index_tag after_tag = index_tag
# depend on reindexing so that select methods # depend on reindexing so that select methods
# do not return movements that are already built # do not return movements that are already built
after_method_id = ('recursiveImmediateReindexObject', after_method_id = ('immediateReindexObject',
'immediateReindexObject',
'_updateSimulation') '_updateSimulation')
activate_kw = dict(tag=index_tag) activate_kw = dict(tag=index_tag)
builder.activate( builder.activate(
......
...@@ -271,7 +271,6 @@ class AppliedRule(XMLObject, ExplainableMixin): ...@@ -271,7 +271,6 @@ class AppliedRule(XMLObject, ExplainableMixin):
if rar_list and portal.portal_activities.countMessage( if rar_list and portal.portal_activities.countMessage(
path=[x.getPath() for x in rar_list], path=[x.getPath() for x in rar_list],
method_id=('immediateReindexObject', method_id=('immediateReindexObject',
'recursiveImmediateReindexObject',
'recursiveImmediateReindexSimulationMovement')): 'recursiveImmediateReindexSimulationMovement')):
raise ConflictError raise ConflictError
# Do not try to keep simulation tree for a draft delivery # Do not try to keep simulation tree for a draft delivery
......
...@@ -52,6 +52,3 @@ class BalanceTransactionLine(AccountingTransactionLine, InventoryLine): ...@@ -52,6 +52,3 @@ class BalanceTransactionLine(AccountingTransactionLine, InventoryLine):
reindexObject = InventoryLine.reindexObject reindexObject = InventoryLine.reindexObject
recursiveReindexObject = InventoryLine.recursiveReindexObject recursiveReindexObject = InventoryLine.recursiveReindexObject
immediateReindexObject = InventoryLine.immediateReindexObject immediateReindexObject = InventoryLine.immediateReindexObject
recursiveImmediateReindexObject = \
InventoryLine.recursiveImmediateReindexObject
...@@ -505,26 +505,6 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin): ...@@ -505,26 +505,6 @@ class SimulationMovement(PropertyRecordableMixin, Movement, ExplainableMixin):
root_rule = self.getRootAppliedRule() root_rule = self.getRootAppliedRule()
return root_rule.getCausalityValueList() 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): def _isTreeDelivered(self):
""" """
checks if subapplied rules of this movement (going down the complete checks if subapplied rules of this movement (going down the complete
......
...@@ -1973,7 +1973,7 @@ class ERP5Generator(PortalGenerator): ...@@ -1973,7 +1973,7 @@ class ERP5Generator(PortalGenerator):
# nodes have nothing else to do. # nodes have nothing else to do.
after_method_id = tuple({after_method_id}.union(('Folder_reindexAll', after_method_id = tuple({after_method_id}.union(('Folder_reindexAll',
'Folder_reindexObjectList', 'InventoryModule_reindexMovementList', 'Folder_reindexObjectList', 'InventoryModule_reindexMovementList',
'immediateReindexObject', 'recursiveImmediateReindexObject', 'SQLCatalog_deferFullTextIndexActivity'))) 'immediateReindexObject', 'SQLCatalog_deferFullTextIndexActivity')))
p.portal_activities.activateObject(p, after_method_id=after_method_id, p.portal_activities.activateObject(p, after_method_id=after_method_id,
)._delPropValue(id_) )._delPropValue(id_)
......
...@@ -98,13 +98,11 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -98,13 +98,11 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
self.ImmediateReindexObjectIsCalled() self.ImmediateReindexObjectIsCalled()
from Products.ERP5Type.Document.Organisation import Organisation from Products.ERP5Type.Document.Organisation import Organisation
Organisation.immediateReindexObject = crashingMethod Organisation.immediateReindexObject = crashingMethod
Organisation.recursiveImmediateReindexObject = crashingMethod
def beforeTearDown(self): def beforeTearDown(self):
# Remove crashing method # Remove crashing method
from Products.ERP5Type.Document.Organisation import Organisation from Products.ERP5Type.Document.Organisation import Organisation
del Organisation.immediateReindexObject del Organisation.immediateReindexObject
del Organisation.recursiveImmediateReindexObject
def createCategories(self): def createCategories(self):
""" """
...@@ -188,8 +186,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -188,8 +186,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertTrue(len(message_list) > 0) self.assertTrue(len(message_list) > 0)
self.assertTrue(len(message_list) < 3) self.assertTrue(len(message_list) < 3)
for method_id in method_id_list: for method_id in method_id_list:
self.assertTrue(method_id in ["immediateReindexObject", self.assertTrue(method_id in ["immediateReindexObject"])
"recursiveImmediateReindexObject"])
def stepSetSameTitleValueWithEdit(self, sequence=None, sequence_list=None, def stepSetSameTitleValueWithEdit(self, sequence=None, sequence_list=None,
**kw): **kw):
......
...@@ -120,8 +120,7 @@ class TestERP5Simulation(TestPackingListMixin, SecurityTestCase): ...@@ -120,8 +120,7 @@ class TestERP5Simulation(TestPackingListMixin, SecurityTestCase):
after_tag.append(previous_tag) after_tag.append(previous_tag)
delivery_builder.activate( delivery_builder.activate(
after_method_id=('solve', after_method_id=('solve',
'immediateReindexObject', 'immediateReindexObject'), # XXX too brutal.
'recursiveImmediateReindexObject',), # XXX too brutal.
after_tag=after_tag, after_tag=after_tag,
).build(explanation_uid=packing_list.getCausalityValue().getUid()) ).build(explanation_uid=packing_list.getCausalityValue().getUid())
......
...@@ -1006,8 +1006,7 @@ class TestPackingListMixin(TestOrderMixin): ...@@ -1006,8 +1006,7 @@ class TestPackingListMixin(TestOrderMixin):
after_tag.append(previous_tag) after_tag.append(previous_tag)
delivery_builder.activate( delivery_builder.activate(
after_method_id=('solve', after_method_id=('solve',
'immediateReindexObject', 'immediateReindexObject'), # XXX too brutal.
'recursiveImmediateReindexObject',), # XXX too brutal.
after_tag=after_tag, after_tag=after_tag,
).build(explanation_uid=packing_list.getCausalityValue().getUid()) ).build(explanation_uid=packing_list.getCausalityValue().getUid())
......
...@@ -335,7 +335,6 @@ class BusinessConfiguration(Item): ...@@ -335,7 +335,6 @@ class BusinessConfiguration(Item):
""" """
kw = dict(tag="start_configuration_%s" % self.getId(), kw = dict(tag="start_configuration_%s" % self.getId(),
after_method_id=["updateBusinessTemplateFromUrl", after_method_id=["updateBusinessTemplateFromUrl",
"recursiveImmediateReindexObject",
"immediateReindexObject"]) "immediateReindexObject"])
# build # build
configuration_save_list = self.contentValues(portal_type='Configuration Save') configuration_save_list = self.contentValues(portal_type='Configuration Save')
...@@ -353,8 +352,7 @@ class BusinessConfiguration(Item): ...@@ -353,8 +352,7 @@ class BusinessConfiguration(Item):
configurator_item.getUid()) configurator_item.getUid())
kw["tag"] = "final_configuration_step_%s" % self.getId() kw["tag"] = "final_configuration_step_%s" % self.getId()
kw["after_method_id"] = ["fixConsistency", 'immediateReindexObject', \ kw["after_method_id"] = ["fixConsistency", 'immediateReindexObject']
"recursiveImmediateReindexObject"]
self.activate(**kw).ERP5Site_afterConfigurationSetup() self.activate(**kw).ERP5Site_afterConfigurationSetup()
......
...@@ -2820,9 +2820,7 @@ class Base( CopyContainer, ...@@ -2820,9 +2820,7 @@ class Base( CopyContainer,
if self.isAncestryIndexable(): if self.isAncestryIndexable():
with super_user(): with super_user():
PortalContent.reindexObject(self, *args, **kw) PortalContent.reindexObject(self, *args, **kw)
_reindexOnCreation = immediateReindexObject
security.declarePrivate('recursiveImmediateReindexObject')
recursiveImmediateReindexObject = immediateReindexObject
security.declarePublic('reindexObject') security.declarePublic('reindexObject')
def reindexObject(self, *args, **kw): def reindexObject(self, *args, **kw):
......
...@@ -1266,14 +1266,19 @@ class Folder(CopyContainer, OFSFolder2, CMFBTreeFolder, CMFHBTreeFolder, Base, F ...@@ -1266,14 +1266,19 @@ class Folder(CopyContainer, OFSFolder2, CMFBTreeFolder, CMFHBTreeFolder, Base, F
value_list.extend(c.getIndexableChildValueList()) value_list.extend(c.getIndexableChildValueList())
return value_list return value_list
security.declarePrivate('recursiveImmediateReindexObject') def _reindexOnCreation(self, **reindex_kw):
def recursiveImmediateReindexObject(self, **kw): """
if self.isIndexable and int(getattr(self.getPortalObject(), 'isIndexable', 1)): Immediately and recursively reindex self, a document which was created
self.immediateReindexObject(**kw) (bound to its parent) within current transaction.
for c in self.objectValues():
if getattr(aq_base(c), Here, immediate recursion is expected to be fine as document tree just
'recursiveImmediateReindexObject', None) is not None: created: assume we can iterate over what was just created without causing
c.recursiveImmediateReindexObject(**kw) 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') security.declareProtected(Permissions.ModifyPortalContent, 'moveObject')
def moveObject(self, idxs=None): def moveObject(self, idxs=None):
......
...@@ -454,7 +454,7 @@ class ERP5TypeInformation(XMLObject, ...@@ -454,7 +454,7 @@ class ERP5TypeInformation(XMLObject,
# (activities). Or just not request immediate indexation. # (activities). Or just not request immediate indexation.
# - if ImmediateReindexContextManager is used, anything until # - if ImmediateReindexContextManager is used, anything until
# context manager exits. # context manager exits.
method = ob.recursiveImmediateReindexObject method = ob._reindexOnCreation
if reindex_kw is not None: if reindex_kw is not None:
method = partial(method, **reindex_kw) method = partial(method, **reindex_kw)
if isinstance(immediate_reindex, ImmediateReindexContextManager): 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