Commit 437a197e authored by Ayush Tiwari's avatar Ayush Tiwari

multiple_catalog:[Workaround] ERP5SiteReindexAll should reindex in all catalog...

multiple_catalog:[Workaround] ERP5SiteReindexAll should reindex in all catalog by creating activities for each one of them
parent 4a746445
......@@ -10,12 +10,15 @@ if clear_catalog:
if is_subscribed:
portal.portal_alarms.unsubscribe()
# Reindex person module
print "#### Indexing person_module, stage 1 ####"
person_module=getattr(portal, 'person_module', None)
higher_priority = 1 + additional_priority
if person_module is not None :
tag = 'person_stage_1'
catalog_id_list = [portal.portal_catalog.getSQLCatalog().id]
for sql_catalog_id in catalog_id_list:
# Reindex person module
print "#### Indexing person_module, stage 1 ####"
person_module=getattr(portal, 'person_module', None)
higher_priority = 1 + additional_priority
if person_module is not None :
tag = 'person_stage_1_%s'%sql_catalog_id
person_module.recurseCallMethod(
method_id='immediateReindexObject',
group_method_id='portal_catalog/catalogObjectList',
......@@ -29,17 +32,16 @@ if person_module is not None :
max_depth=1, # Do not reindex Person's subobjects
)
print "#### Indexing translations ####"
context.ERP5Site_updateTranslationTable(sql_catalog_id=sql_catalog_id)
print "#### Indexing translations ####"
context.ERP5Site_updateTranslationTable(sql_catalog_id=sql_catalog_id)
# Reindex categories
print "#### Indexing categories ####"
folder_tag = 'module_%s'%sql_catalog_id
folder_after_tag = ('person_stage_1_%s'%sql_catalog_id, 'group_person_stage_1')
object_tag = 'category_%s'%sql_catalog_id
object_after_tag = folder_after_tag
# Reindex categories
print "#### Indexing categories ####"
folder_tag = 'module'
folder_after_tag = ('person_stage_1', 'group_person_stage_1')
object_tag = 'category'
object_after_tag = folder_after_tag
context.portal_categories.activate(
context.portal_categories.activate(
tag=folder_tag,
priority=higher_priority,
after_tag=folder_after_tag).Folder_reindexAll(
......@@ -52,14 +54,14 @@ context.portal_categories.activate(
start_tree=start_tree,
stop_tree=stop_tree,)
print "#### Indexing alarms ####"
print "#### Indexing active results ####"
folder_tag = 'module'
folder_after_tag = ('category', 'person_stage_1', 'group_person_stage_1')
object_tag = 'document'
object_after_tag = folder_after_tag
object_priority = 2 + additional_priority
for folder in [context.portal_alarms, context.portal_activities]:
print "#### Indexing alarms ####"
print "#### Indexing active results ####"
folder_tag = 'module_%s'%sql_catalog_id
folder_after_tag = ('category_%s'%sql_catalog_id, 'person_stage_1_%s'%sql_catalog_id, 'group_person_stage_1')
object_tag = 'document_%s'%sql_catalog_id
object_after_tag = folder_after_tag
object_priority = 2 + additional_priority
for folder in [context.portal_alarms, context.portal_activities]:
folder.activate(
tag=folder_tag,
priority=object_priority,
......@@ -73,9 +75,9 @@ for folder in [context.portal_alarms, context.portal_activities]:
start_tree=start_tree,
stop_tree=stop_tree,)
print "#### Indexing preferences ####"
preference_tag = 'portal_preferences'
context.portal_preferences.activate(
print "#### Indexing preferences ####"
preference_tag = 'portal_preferences_%s'%sql_catalog_id
context.portal_preferences.activate(
tag=preference_tag,
after_tag='category',
priority=additional_priority).Folder_reindexAll(
......@@ -86,15 +88,15 @@ context.portal_preferences.activate(
start_tree=start_tree,
stop_tree=stop_tree,)
# We index simulation first to make sure we can calculate tests
# (ie. related quantity)
print "#### Indexing simulation ####"
folder_tag = 'module'
folder_after_tag = ('category', 'document', 'person_stage_1', 'group_person_stage_1', preference_tag)
object_tag = 'simulation'
object_after_tag = folder_after_tag
object_priority = 3 + additional_priority
context.portal_simulation.activate(
# We index simulation first to make sure we can calculate tests
# (ie. related quantity)
print "#### Indexing simulation ####"
folder_tag = 'module_%s'%sql_catalog_id
folder_after_tag = ('category_%s'%sql_catalog_id, 'document_%s'%sql_catalog_id, 'person_stage_1_%s'%sql_catalog_id, 'group_person_stage_1', preference_tag)
object_tag = 'simulation_%s'%sql_catalog_id
object_after_tag = folder_after_tag
object_priority = 3 + additional_priority
context.portal_simulation.activate(
tag=folder_tag,
priority=higher_priority,
after_tag=folder_after_tag).Folder_reindexAll(
......@@ -107,20 +109,34 @@ context.portal_simulation.activate(
start_tree=start_tree,
stop_tree=stop_tree,)
# We index tools secondly
print "#### Indexing tools ####"
# XXX: Hack to avoid even trying to index these objects
restricted_tool_id_list = ( 'portal_alarms', 'portal_activities',
'portal_classes', 'portal_preferences',
'portal_simulation', 'portal_uidhandler',
'portal_actions', 'portal_memberdata',
'portal_skins', 'portal_undo',
'portal_url', 'portal_workflow',
'portal_discussion', 'portal_membership',
'portal_registration', 'portal_properties',
'portal_metadata', 'portal_syndication',
'portal_syndication', 'portal_syndication',
)
folder_tag = 'module'
folder_after_tag = ('category', 'person_stage_1', 'group_person_stage_1', preference_tag)
object_tag = 'document'
object_after_tag = folder_after_tag
object_priority = 2 + additional_priority
tool_list = [x for x in portal.objectValues() if \
x.getUid != portal.getUid and \
# We index tools secondly
print "#### Indexing tools ####"
folder_tag = 'module_%s'%sql_catalog_id
folder_after_tag = ('category_%s'%sql_catalog_id, 'person_stage_1_%s'%sql_catalog_id, 'group_person_stage_1', preference_tag)
object_tag = 'document_%s'%sql_catalog_id
object_after_tag = folder_after_tag
object_priority = 2 + additional_priority
tool_list = [x for x in portal.objectValues() if \
x.meta_type != 'ERP5 Folder' and \
x.id not in ('portal_alarms', 'portal_activities', 'portal_classes', 'portal_preferences', 'portal_simulation', 'portal_uidhandler')]
x.id != portal.id and \
x.id not in restricted_tool_id_list]
for folder in tool_list:
for folder in tool_list:
try:
folder.activate(
tag=folder_tag,
priority=object_priority,
......@@ -133,16 +149,27 @@ for folder in tool_list:
sql_catalog_id=sql_catalog_id,
start_tree=start_tree,
stop_tree=stop_tree,)
except:
continue
# for sql_catalog_id in catalog_id_list:
# Then we index ERP5 Python Scripts
print "#### Indexing ERP5 Python Scripts ####"
for path, obj in portal.portal_skins.ZopeFind(portal.portal_skins, obj_metatypes=('ERP5 Python Script',), search_sub=1):
obj.activate(tag=folder_tag,
priority=object_priority,
after_tag=folder_after_tag).immediateReindexObject(sql_catalog_id=sql_catalog_id)
# Then we index ERP5 Python Scripts and ERP5 Form
print "#### Indexing ERP5 Python Scripts, ERP5 Forms and ERP5 Reports ####"
for _, obj in portal.portal_skins.ZopeFind(portal.portal_skins, obj_metatypes=('ERP5 Python Script', 'ERP5 Form', 'ERP5 Report'), search_sub=1):
#for sql_catalog_id in catalog_id_list:
# Then we index ERP5 SQL Methods
print "#### Indexing ERP5 SQL Methods ####"
for path, obj in portal.portal_skins.ZopeFind(portal.portal_skins, obj_metatypes=('ERP5 SQL Method',), search_sub=1):
obj.activate(tag=folder_tag,
priority=object_priority,
after_tag=folder_after_tag).immediateReindexObject(sql_catalog_id=sql_catalog_id)
# Then we index everything except inventories
for folder in portal.objectValues(("ERP5 Folder",)):
# Then we index everything except inventories
for folder in portal.objectValues(("ERP5 Folder",)):
if folder.getId().find('inventory') < 0:
print "#### Indexing contents inside folder %s ####" % folder.id
folder.activate(
......@@ -158,10 +185,10 @@ for folder in portal.objectValues(("ERP5 Folder",)):
start_tree=start_tree,
stop_tree=stop_tree,)
# Then we index inventories
object_tag = 'inventory'
object_after_tag = ('module', 'category', 'person_stage_1', 'document', 'group_person_stage_1')
for folder in portal.objectValues(("ERP5 Folder",)):
# Then we index inventories
object_tag = 'inventory_%s'%sql_catalog_id
object_after_tag = ('module_%s'%sql_catalog_id, 'category_%s'%sql_catalog_id, 'person_stage_1_%s'%sql_catalog_id, 'document_%s'%sql_catalog_id, 'group_person_stage_1')
for folder in portal.objectValues(("ERP5 Folder",)):
if folder.getId().find('inventory') >= 0:
print "#### Indexing contents inside folder %s ####" % folder.id
folder.activate(
......@@ -177,28 +204,29 @@ for folder in portal.objectValues(("ERP5 Folder",)):
start_tree=start_tree,
stop_tree=stop_tree,)
# start activty from simulation because the erp5site is not an active object
context.portal_simulation.activate(
after_tag=('inventory', 'simulation', 'person_stage_1', 'group_person_stage_1'),
# start activty from simulation because the erp5site is not an active object
context.portal_simulation.activate(
after_tag=('inventory_%s'%sql_catalog_id, 'simulation_%s'%sql_catalog_id, 'person_stage_1_%s'%sql_catalog_id, 'group_person_stage_1'),
priority=3 + additional_priority
).InventoryModule_reindexMovementList(
sql_catalog_id=sql_catalog_id,
final_activity_tag='last_inventory_activity')
final_activity_tag='last_inventory_activity_%s'%sql_catalog_id)
# restore alarm node
if clear_catalog and is_subscribed:
portal.portal_alarms.activate(after_tag=('inventory', 'module', 'inventory', 'simulation', 'person_stage_1',
'group_person_stage_1', 'last_inventory_activity', 'document')).subscribe()
# restore alarm node
if clear_catalog and is_subscribed:
portal.portal_alarms.activate(after_tag=('inventory_%s'%sql_catalog_id, 'module_%s'%sql_catalog_id, 'inventory_%s'%sql_catalog_id, 'simulation_%s'%sql_catalog_id, 'person_stage_1_%s'%sql_catalog_id,
'group_person_stage_1', 'last_inventory_activity_%s'%sql_catalog_id, 'document_%s'%sql_catalog_id)).subscribe()
if final_activity_tag is not None:
if final_activity_tag is not None:
# Start a dummy activity which will get discarded when all started activities
# (and all activities they trigger) are over.
# Started on portal_simulation because activate does not work on portal object...
# No idea if there is a better place.
context.portal_simulation.activate(tag=final_activity_tag,
priority=3 + additional_priority,
after_tag=('module', 'inventory', 'simulation', 'person_stage_1',
'group_person_stage_1', 'last_inventory_activity', 'document')
after_tag=('module_%s'%sql_catalog_id, 'inventory_%s'%sql_catalog_id, 'simulation_%s'%sql_catalog_id, 'person_stage_1_%s'%sql_catalog_id,
'group_person_stage_1', 'last_inventory_activity_%s'%sql_catalog_id, 'document_%s'%sql_catalog_id)
).getId()
folder_after_tag = ()
return printed
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