Commit a5e91ad3 authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5Type: Assorted cleanups around indexation methods.

Do not check portal's isIndexable, it is checked again in ZSQLCatalog.
Directly bind superclass callable instead of doing an extra getattr +
call.
Trivial python simplifications.
Assorted coding style improvements.
Drop unhelpful comments and docstrings.
parent 60e846fe
......@@ -2790,18 +2790,9 @@ class Base( CopyContainer,
security.declarePublic('immediateReindexObject')
def immediateReindexObject(self, *args, **kw):
"""
Reindexes an object - also useful for testing
"""
root_indexable = int(getattr(self.getPortalObject(),'isIndexable',1))
if self.isIndexable and root_indexable:
#LOG("immediateReindexObject",0,self.getRelativeUrl())
# Reindex result should not depend on the user
if self.isIndexable:
with super_user():
PortalContent.reindexObject(self, *args, **kw)
else:
pass
#LOG("No reindex now",0,self.getRelativeUrl())
security.declarePublic('recursiveImmediateReindexObject')
recursiveImmediateReindexObject = immediateReindexObject
......@@ -2833,10 +2824,10 @@ class Base( CopyContainer,
activate_kw = reindex_activate_kw
group_id_list = []
if kw.get("group_id", "") not in ('', None):
group_id_list.append(kw.get("group_id", ""))
if kw.get("sql_catalog_id", "") not in ('', None):
group_id_list.append(kw.get("sql_catalog_id", ""))
if kw.get("group_id") not in ('', None):
group_id_list.append(kw["group_id"])
if kw.get("sql_catalog_id") not in ('', None):
group_id_list.append(kw["sql_catalog_id"])
group_id = ' '.join(group_id_list)
self.activate(group_method_id='portal_catalog/catalogObjectList',
......
......@@ -1252,11 +1252,8 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn):
# Catalog related
security.declarePublic( 'reindexObject' )
def reindexObject(self, *args, **kw):
"""Fixes the hierarchy structure (use of Base class)
"""
return Base.reindexObject(self, *args, **kw)
security.declarePublic('reindexObject')
reindexObject = Base.reindexObject
security.declareProtected(Permissions.ModifyPortalContent,
'reindexObjectSecurity')
......@@ -1265,14 +1262,13 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn):
Reindex security-related indexes on the object
"""
# In ERP5, simply reindex all objects, recursively by default.
reindex = self._getTypeBasedMethod('reindexObjectSecurity',
'recursiveReindexObject')
reindex(*args, **kw)
self._getTypeBasedMethod(
'reindexObjectSecurity',
'recursiveReindexObject',
)(*args, **kw)
security.declarePublic( 'recursiveReindexObject' )
security.declarePublic('recursiveReindexObject')
def recursiveReindexObject(self, activate_kw=None, **kw):
"""Recursively indexes the content of self.
"""
if self.isIndexable:
if not activate_kw and self.objectCount() > REINDEX_SPLIT_COUNT:
# If the number of objects to reindex is too high
......@@ -1305,10 +1301,10 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn):
activate_kw = reindex_activate_kw
group_id_list = []
if kw.get("group_id", "") not in ('', None):
group_id_list.append(kw.get("group_id", ""))
if kw.get("sql_catalog_id", "") not in ('', None):
group_id_list.append(kw.get("sql_catalog_id", ""))
if kw.get("group_id") not in ('', None):
group_id_list.append(kw["group_id"])
if kw.get("sql_catalog_id") not in ('', None):
group_id_list.append(kw["sql_catalog_id"])
group_id = ' '.join(group_id_list)
self.activate(group_method_id='portal_catalog/catalogObjectList',
......@@ -1334,18 +1330,12 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn):
security.declarePublic( 'recursiveImmediateReindexObject' )
def recursiveImmediateReindexObject(self, **kw):
"""
Applies immediateReindexObject recursively
"""
# Reindex self
root_indexable = int(getattr(self.getPortalObject(),'isIndexable',1))
if self.isIndexable and root_indexable:
self.immediateReindexObject(**kw)
# Reindex contents
for c in self.objectValues():
if getattr(aq_base(c),
'recursiveImmediateReindexObject', None) is not None:
c.recursiveImmediateReindexObject(**kw)
if self.isIndexable:
self.immediateReindexObject(**kw)
for c in self.objectValues():
if getattr(aq_base(c),
'recursiveImmediateReindexObject', None) is not None:
c.recursiveImmediateReindexObject(**kw)
security.declareProtected(Permissions.ModifyPortalContent, 'moveObject')
def moveObject(self, idxs=None):
......
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