Commit f96752f6 authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5Type: Assorted cleanups around indexation methods.

Directly bind superclass callable instead when applicable.
Trivial python simplifications.
Assorted coding style improvements.
Drop unhelpful comments and docstrings.
parent b6eec549
...@@ -2790,18 +2790,9 @@ class Base( CopyContainer, ...@@ -2790,18 +2790,9 @@ class Base( CopyContainer,
security.declarePublic('immediateReindexObject') security.declarePublic('immediateReindexObject')
def immediateReindexObject(self, *args, **kw): def immediateReindexObject(self, *args, **kw):
""" if self.isIndexable and int(getattr(self.getPortalObject(), 'isIndexable', 1)):
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
with super_user(): with super_user():
PortalContent.reindexObject(self, *args, **kw) PortalContent.reindexObject(self, *args, **kw)
else:
pass
#LOG("No reindex now",0,self.getRelativeUrl())
security.declarePublic('recursiveImmediateReindexObject') security.declarePublic('recursiveImmediateReindexObject')
recursiveImmediateReindexObject = immediateReindexObject recursiveImmediateReindexObject = immediateReindexObject
...@@ -2833,10 +2824,10 @@ class Base( CopyContainer, ...@@ -2833,10 +2824,10 @@ class Base( CopyContainer,
activate_kw = reindex_activate_kw activate_kw = reindex_activate_kw
group_id_list = [] group_id_list = []
if kw.get("group_id", "") not in ('', None): if kw.get("group_id") not in ('', None):
group_id_list.append(kw.get("group_id", "")) group_id_list.append(kw["group_id"])
if kw.get("sql_catalog_id", "") not in ('', None): if kw.get("sql_catalog_id") not in ('', None):
group_id_list.append(kw.get("sql_catalog_id", "")) group_id_list.append(kw["sql_catalog_id"])
group_id = ' '.join(group_id_list) group_id = ' '.join(group_id_list)
self.activate(group_method_id='portal_catalog/catalogObjectList', self.activate(group_method_id='portal_catalog/catalogObjectList',
......
...@@ -1290,11 +1290,8 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn): ...@@ -1290,11 +1290,8 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn):
# Catalog related # Catalog related
security.declarePublic( 'reindexObject' ) security.declarePublic('reindexObject')
def reindexObject(self, *args, **kw): reindexObject = Base.reindexObject
"""Fixes the hierarchy structure (use of Base class)
"""
return Base.reindexObject(self, *args, **kw)
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'reindexObjectSecurity') 'reindexObjectSecurity')
...@@ -1303,14 +1300,13 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn): ...@@ -1303,14 +1300,13 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn):
Reindex security-related indexes on the object Reindex security-related indexes on the object
""" """
# In ERP5, simply reindex all objects, recursively by default. # In ERP5, simply reindex all objects, recursively by default.
reindex = self._getTypeBasedMethod('reindexObjectSecurity', self._getTypeBasedMethod(
'recursiveReindexObject') 'reindexObjectSecurity',
reindex(*args, **kw) 'recursiveReindexObject',
)(*args, **kw)
security.declarePublic( 'recursiveReindexObject' ) security.declarePublic('recursiveReindexObject')
def recursiveReindexObject(self, activate_kw=None, **kw): def recursiveReindexObject(self, activate_kw=None, **kw):
"""Recursively indexes the content of self.
"""
if self.isIndexable: if self.isIndexable:
if not activate_kw and self.objectCount() > REINDEX_SPLIT_COUNT: if not activate_kw and self.objectCount() > REINDEX_SPLIT_COUNT:
# If the number of objects to reindex is too high # If the number of objects to reindex is too high
...@@ -1343,10 +1339,10 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn): ...@@ -1343,10 +1339,10 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn):
activate_kw = reindex_activate_kw activate_kw = reindex_activate_kw
group_id_list = [] group_id_list = []
if kw.get("group_id", "") not in ('', None): if kw.get("group_id") not in ('', None):
group_id_list.append(kw.get("group_id", "")) group_id_list.append(kw["group_id"])
if kw.get("sql_catalog_id", "") not in ('', None): if kw.get("sql_catalog_id") not in ('', None):
group_id_list.append(kw.get("sql_catalog_id", "")) group_id_list.append(kw["sql_catalog_id"])
group_id = ' '.join(group_id_list) group_id = ' '.join(group_id_list)
self.activate(group_method_id='portal_catalog/catalogObjectList', self.activate(group_method_id='portal_catalog/catalogObjectList',
...@@ -1372,18 +1368,12 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn): ...@@ -1372,18 +1368,12 @@ class Folder(CopyContainer, CMFBTreeFolder, CMFHBTreeFolder, Base, FolderMixIn):
security.declarePublic( 'recursiveImmediateReindexObject' ) security.declarePublic( 'recursiveImmediateReindexObject' )
def recursiveImmediateReindexObject(self, **kw): def recursiveImmediateReindexObject(self, **kw):
""" if self.isIndexable and int(getattr(self.getPortalObject(), 'isIndexable', 1)):
Applies immediateReindexObject recursively self.immediateReindexObject(**kw)
""" for c in self.objectValues():
# Reindex self if getattr(aq_base(c),
root_indexable = int(getattr(self.getPortalObject(),'isIndexable',1)) 'recursiveImmediateReindexObject', None) is not None:
if self.isIndexable and root_indexable: c.recursiveImmediateReindexObject(**kw)
self.immediateReindexObject(**kw)
# Reindex contents
for c in self.objectValues():
if getattr(aq_base(c),
'recursiveImmediateReindexObject', None) is not None:
c.recursiveImmediateReindexObject(**kw)
security.declareProtected(Permissions.ModifyPortalContent, 'moveObject') security.declareProtected(Permissions.ModifyPortalContent, 'moveObject')
def moveObject(self, idxs=None): 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