Commit 707058d7 authored by Julien Muchembled's avatar Julien Muchembled

Fix reindexing with custom grouping using 'group_id'

This fixes:

  Traceback (innermost last):
    Module Products.CMFActivity.ActivityTool, line 1373, in invokeGroup
      traverse(method_id)(expanded_object_list)
    Module Products.ERP5Catalog.CatalogTool, line 946, in catalogObjectList
      super(CatalogTool, self).catalogObjectList(tmp_object_list, **m.kw)
    Module Products.ZSQLCatalog.ZSQLCatalog, line 813, in catalogObjectList
      **kw
  TypeError: catalogObjectList() got an unexpected keyword argument 'group_id'
parent b1fe6111
......@@ -3092,6 +3092,37 @@ VALUES
self.assertEqual(len([x for x in portal_activities.getMessageList() if x.processing_node == 0]), 2)
self.tic()
def test_reindexWithGroupId(self):
CatalogTool = type(self.getCatalogTool().aq_base)
counts = []
orig_catalogObjectList = CatalogTool.catalogObjectList.__func__
def catalogObjectList(self, object_list, *args, **kw):
counts.append(len(object_list))
return orig_catalogObjectList(self, object_list, *args, **kw)
def check(*x):
self.tic()
self.assertEqual(counts, list(x))
del counts[:]
try:
CatalogTool.catalogObjectList = catalogObjectList
module = self.getPersonModule()
ob = module.newContent(), module.newContent()
check(2)
ob[0].reindexObject(group_id='x')
ob[1].reindexObject(group_id='x')
check(2)
ob[0].reindexObject(group_id='1')
ob[1].reindexObject(group_id='2')
check(1, 1)
ob[0].reindexObject(activate_kw={'group_id':'x'})
ob[1].reindexObject(activate_kw={'group_id':'x'})
check(2)
ob[0].reindexObject(activate_kw={'group_id':'1'})
ob[1].reindexObject(activate_kw={'group_id':'2'})
check(1, 1)
finally:
CatalogTool.catalogObjectList = orig_catalogObjectList
def test_PercentCharacter(self):
"""
Check expected behaviour of % character for simple query
......
......@@ -2878,14 +2878,11 @@ class Base( CopyContainer,
kw = reindex_kw
# And top activate_kw priority: the direct parameter.
full_activate_kw.update(activate_kw or ())
group_id_list = []
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"])
if full_activate_kw.get('group_id') not in ('', None):
group_id_list.append(full_activate_kw['group_id'])
full_activate_kw['group_id'] = ' '.join(group_id_list)
full_activate_kw['group_id'] = ' '.join(group_id for group_id in (
kw.pop("group_id", None),
kw.get("sql_catalog_id"),
full_activate_kw.get('group_id'),
) if group_id)
full_activate_kw['group_method_id'] = 'portal_catalog/catalogObjectList'
full_activate_kw['alternate_method_id'] = 'alternateReindexObject'
full_activate_kw['activity'] = 'SQLDict'
......
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