Commit cf6fea4a authored by Jean-Paul Smets's avatar Jean-Paul Smets

new version based on activate


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@1159 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 640b1b63
##parameters=request=None ## Script (Python) "ERP5Site_reindexAll"
##bind container=container
error_list = [] ##bind context=context
return_list = [] ##bind namespace=
##bind script=script
context.portal_catalog.catalog_object(context.portal_categories,None) ##bind subpath=traverse_subpath
##parameters=
for category in context.portal_categories.objectValues(): ##title=
#print "#### Indexing inside the folder %s ####" % 'portal_categories' ##
error_list += context.reindexAll(object=category,request=context) print "#### Indexing categories ####"
for o in list(context.portal_categories.objectValues()):
for object in context.portal_simulation.objectValues(): o.activate(passive_commit=1).recursiveImmediateReindexObject()
#print "#### Indexing inside the folder %s ####" % 'portal_simulation'
error_list += context.reindexAll(object=object,request=context) # We index simulation first to make sure we can calculate tests (ie. related quantity)
print "#### Indexing simulation ####"
for folder in context.objectValues(("ERP5 Folder",)): for o in list(context.portal_simulation.objectValues()):
#print "#### Indexing inside the folder %s ####" % folder.id o.activate(passive_commit=1).immediateReindexObject()
error_list += folder.reindexAll(object=folder,request=context)
# Then we index everything except inventories
nb_types = {} for folder in context.portal_url.getPortalObject().objectValues(("ERP5 Folder",)):
print "#### Indexing contents inside folder %s ####" % folder.id
for error in error_list: if folder.getId() not in ('inventaire_mp','inventaire_pf'):
# We count the number of each portal type for o in list(folder.objectValues()):
if error[1]=='portal_type': try:
type = error[3] o.activate(passive_commit=1).recursiveImmediateReindexObject()
if nb_types.has_key(type): except:
nb_types[type] = nb_types[type] + 1 #raise RuntimeError, o.getRelativeUrl()
else: raise RuntimeError, 'error: folder=%s, o=%s' % (repr(folder.getId()), repr(o))
nb_types[type] = 1
else: # Then we index inventories
#print error for folder in context.portal_url.getPortalObject().objectValues(("ERP5 Folder",)):
return_list.append(error) print "#### Indexing contents inside folder %s ####" % folder.id
if folder.getId() in ('inventaire_mp','inventaire_pf'):
for type in nb_types.keys(): for o in list(folder.objectValues()):
# Find the number of each portal type in the catalog o.activate(passive_commit=1).recursiveImmediateReindexObject()
count_result = context.portal_catalog.countResults(portal_type=type)
nb_catalog = count_result[0][0] return printed
if nb_types[type] != nb_catalog:
message = "XXX Warning for %s: there is %i lines in the catalog instead of %i" % \
(type,nb_catalog,nb_types[type])
return_list.append(('Count Error', 'PortalRoot_reindexAll',1,message))
#else: print "%s: %i" % (type,nb_types[type])
return return_list
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