Commit 8f1c0552 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

fixup! erp5_core: reindex recursively only if indexable children type exists...

fixup! erp5_core: reindex recursively only if indexable children type exists in Base_reindexObjectSecurity.
Co-authored-by: Xiaowu Zhang's avatarXiaowu Zhang <xiaowu.zhang@nexedi.com>
Reviewed-by: Jérome Perrin's avatarJérome Perrin <jerome@nexedi.com>
parent 9fa162e8
Pipeline #40125 failed with stage
in 0 seconds
......@@ -866,3 +866,11 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
1,
len(self.portal.portal_catalog(uid=person2.getUid())),
)
def test_ERP5Site_testisInstanceIndexable(self):
for portal_type_id in ('Base Type', 'Person'):
portal_type = getattr(self.portal.portal_types, portal_type_id)
self.assertTrue(portal_type.isInstanceIndexable())
for portal_type_id in ('Catalog', 'Solver Process'):
portal_type = getattr(self.portal.portal_types, portal_type_id)
self.assertFalse(portal_type.isInstanceIndexable())
......@@ -5,7 +5,7 @@
type_tool = context.getPortalObject().portal_types
for portal_type_name in context.getTypeInfo().getTypeAllowedContentTypeList():
type_ = getattr(type_tool, portal_type_name)
if type_.getTypeAcquireLocalRole() and type_.isIndexable():
if type_.getTypeAcquireLocalRole() and type_.isInstanceIndexable():
reindex = context.recursiveReindexObject
break
else:
......
......@@ -360,13 +360,15 @@ class ERP5TypeInformation(XMLObject,
permission = self.permission or 'Add portal content'
return getSecurityManager().checkPermission(permission, container)
security.declarePublic('isIndexable')
def isIndexable(self):
security.declarePublic('isInstanceIndexable')
def isInstanceIndexable(self):
"""Test if an instance is indexable by default
"""
portal = self.getPortalObject()
klass = portal.portal_types.getPortalTypeClass(self.getId())
return klass.isIndexable()
if klass.__isghost__:
klass.loadClass()
return bool(klass.isIndexable)
security.declarePublic('constructTempInstance')
def constructTempInstance(self, container, id, *args, **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