Commit 18e9c69a authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

erp5_core: reindex recursively only if indexable children type exists in...

erp5_core: reindex recursively only if indexable children type exists in Base_reindexObjectSecurity.

This is important especially for SyncML Subscription having tons of SyncML Signatures that is non-indexable.

Note: first I tried the change in the restricted python only like :

--- product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_reindexObjectSecurity.py
+++ product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_reindexObjectSecurity.py
@@ -4,7 +4,8 @@
 # with lots of content could mean hours of non-usable overloaded system.
 type_tool = context.getPortalObject().portal_types
 for portal_type_name in context.getTypeInfo().getTypeAllowedContentTypeList():
-  if getattr(type_tool, portal_type_name).getTypeAcquireLocalRole():
+  if getattr(type_tool, portal_type_name).getTypeAcquireLocalRole() and \
+      type_tool.getPortalTypeClass(portal_type_name).isIndexable():
     reindex = context.recursiveReindexObject
     break
 else:

but I got the following exception :

  File "Script (Python)", line 8, in Base_reindexObjectSecurity
    type_tool.getPortalTypeClass(portal_type_name).isIndexable():
  File "/(SR)/eggs/AccessControl-4.4-py2.7-linux-x86_64.egg/AccessControl/users.py", line 179, in allowed
    if self._check_context(object):
  File "/(SR)/parts/erp5/product/ERP5Type/patches/AccessControl_patch.py", line 44, in _check_context
    return aq_inContextOf(getattr(object, '__self__', object), context, 1)
TypeError: unbound method _aq_dynamic() must be called with Address instance as first argument (got str instance instead)
parent 3ec082b3
Pipeline #37097 failed with stage
in 0 seconds
......@@ -4,7 +4,8 @@
# with lots of content could mean hours of non-usable overloaded system.
type_tool = context.getPortalObject().portal_types
for portal_type_name in context.getTypeInfo().getTypeAllowedContentTypeList():
if getattr(type_tool, portal_type_name).getTypeAcquireLocalRole():
type_ = getattr(type_tool, portal_type_name)
if type_.getTypeAcquireLocalRole() and type_.isIndexable():
reindex = context.recursiveReindexObject
break
else:
......
......@@ -360,6 +360,14 @@ class ERP5TypeInformation(XMLObject,
permission = self.permission or 'Add portal content'
return getSecurityManager().checkPermission(permission, container)
security.declarePublic('isIndexable')
def isIndexable(self):
"""Test if an instance is indexable by default
"""
portal = self.getPortalObject()
klass = portal.portal_types.getPortalTypeClass(self.getId())
return 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