Back to index

plone3  3.1.7
final_two11.py
Go to the documentation of this file.
00001 from Products.MimetypesRegistry.setuphandlers import fixUpSMIGlobs
00002 from Products.CMFPlone.migrations.v3_0.alphas import enableZope3Site
00003 from Products.CMFPlone.migrations.v3_0.alphas import registerToolsAsUtilities
00004 
00005 
00006 def final_two11(portal):
00007     """2.1-final -> 2.1.1
00008     """
00009     out = []
00010     
00011     # Make the portal a Zope3 site
00012     enableZope3Site(portal, out)
00013 
00014     # register some tools as utilities
00015     registerToolsAsUtilities(portal, out)
00016 
00017     try:
00018         fixUpSMIGlobs(portal, out)
00019     except TypeError:
00020         fixUpSMIGlobs(out)
00021 
00022 
00023     # Update path index for new EPI version
00024     reindexPathIndex(portal, out)
00025 
00026     return out
00027 
00028 
00029 def reindexPathIndex(portal, out):
00030     """Rebuilds the path index."""
00031     from Products.ZCatalog.ZCatalog import ZCatalog
00032     for catalog in portal.objectValues():
00033         if not isinstance(catalog, ZCatalog):
00034             # catalog is not really a catalog
00035             continue
00036         for name,index in catalog.Indexes.objectItems():
00037             if (index.meta_type == "ExtendedPathIndex" and
00038             getattr(catalog.Indexes._getOb('path', None), '_index_parents', None) is None):
00039                 # Reduce threshold for the reindex run
00040                 old_threshold = catalog.threshold
00041                 pg_threshold = getattr(catalog, 'pgthreshold', 0)
00042                 catalog.pgthreshold = 300
00043                 catalog.threshold = 2000
00044                 catalog.clearIndex(name)
00045                 catalog.manage_reindexIndex(ids=[name])
00046                 catalog.threshold = old_threshold
00047                 catalog.pgthreshold = pg_threshold
00048                 out.append("Reindexed %s index in catalog %s."%(name, catalog.getId()))