[CMF-checkins] CVS: CMF/CMFDefault/Extensions - update_catalogIndexes.py:

Andrew Sawyers andrew@zope.com
Mon, 7 Jan 2002 17:27:15 -0500

Update of /cvs-repository/CMF/CMFDefault/Extensions
In directory cvs.zope.org:/tmp/cvs-serv31287/CMFDefault/Extensions

Added Files:
      Tag: CMF-1_2-branch
Log Message:

*external method for tracker 431
*updated CHANGES.txt to reflect bug fix.

=== Added File CMF/CMFDefault/Extensions/update_catalogIndexes.py ===
from Products.CMFCore.utils import getToolByName

def update_catalogIndexes(self):
    External method to drop, re-add, and rebuild catalog Indexes for migrated 
    CMF sites from Zope 2.3 to 2.4+.
    rIndexes = {'allowedRolesAndUsers': 'KeywordIndex'
              , 'effective': 'FieldIndex'
              , 'expires': 'FieldIndex'}
    ct = getToolByName(self, 'portal_catalog')
    map(lambda x, ct=ct: ct.delIndex(x), rIndexes.keys())
    map(lambda x, ct=ct: ct.addIndex(x[0], x[1]), rIndexes.items()) 
    return 'Catalog Indexes rebuilt.'