[CMF-checkins] CVS: CMF/CMFDefault/Extensions - update_catalogIndexes.py:1.1.2.1
Andrew Sawyers
andrew@zope.com
Mon, 7 Jan 2002 17:01:27 -0500
Update of /cvs-repository/CMF/CMFDefault/Extensions
In directory cvs.zope.org:/tmp/cvs-serv25420/CMFDefault/Extensions
Added Files:
Tag: andrew-tracker431_branch
update_catalogIndexes.py
Log Message:
*added external method to delete, add, and rebuild indexes for
CMF sites which started on Zope2.3 and are migrating to Zope2.4
=== 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())
ct.manage_reindexIndex(ids=rIndexes.keys())
return 'Catalog Indexes rebuilt.'