Commit 8a0ad4a3 authored by Jean-Paul Smets's avatar Jean-Paul Smets

added optimization to recursiveReindexObject so that it is possible to call it...

added optimization to recursiveReindexObject so that it is possible to call it on a module or on a large folder without creating huge transactions

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15219 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 89a66f50
...@@ -56,6 +56,8 @@ import os ...@@ -56,6 +56,8 @@ import os
from zLOG import LOG, PROBLEM from zLOG import LOG, PROBLEM
import warnings import warnings
REINDEX_SPLIT_COUNT = 100 # if folder containes more than this, reindexing should be splitted.
# Dummy Functions for update / upgrade # Dummy Functions for update / upgrade
def dummyFilter(object,REQUEST=None): def dummyFilter(object,REQUEST=None):
return 1 return 1
...@@ -575,6 +577,20 @@ class Folder( CopyContainer, CMFBTreeFolder, Base, FolderMixIn): ...@@ -575,6 +577,20 @@ class Folder( CopyContainer, CMFBTreeFolder, Base, FolderMixIn):
BUG here : when creating a new base category BUG here : when creating a new base category
""" """
if self.isIndexable: if self.isIndexable:
if activate_kw is None and self.objectCount() > REINDEX_SPLIT_COUNT:
# If the number of objects to reindex is too high
# we should try to split reindexing in order to be more efficient
# NOTE: this heuristic will fail for example with orders which
# contain > REINDEX_SPLIT_COUNT order lines.
# It will be less efficient in this case. We also do not
# use this heuristic whenever activate_kw is defined
self._reindexObject(**kw)
for c in self.objectValues():
if getattr(aq_base(c),
'recursiveReindexObject', None) is not None:
c.recursiveReindexObject(**kw)
return
if activate_kw is None: if activate_kw is None:
activate_kw = {} activate_kw = {}
......
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