[CMF-checkins] CVS: CMF/CMFDefault/Extensions - Upgrade.py:1.2 update_catalogIndexes.py:1.2
Andrew Sawyers
andrew@zope.com
Thu, 10 Jan 2002 11:26:23 -0500
Update of /cvs-repository/CMF/CMFDefault/Extensions
In directory cvs.zope.org:/tmp/cvs-serv5016/CMFDefault/Extensions
Added Files:
Upgrade.py update_catalogIndexes.py
Log Message:
*Merging bugfixes from 1_2-branch into head.
=== CMF/CMFDefault/Extensions/Upgrade.py 1.1 => 1.2 ===
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+"""
+ Utility functions for upgrading CMFDefault-based sites.
+"""
+
+from Acquisition import aq_inner
+import string
+
+def upgrade_decor_skins( self ):
+ """
+ Upgrade old skin diretories loaded from 'CMFDecor' to load from
+ 'CMFDefault' (and zap the 'zpt_images' one).
+ """
+ log = []
+
+ DELETED_SKINS = ( 'zpt_images' , )
+
+ MOVED_SKINS = ( 'zpt_content'
+ , 'zpt_control'
+ , 'zpt_generic'
+ )
+
+ skins_tool = aq_inner( self ).portal_skins # start from CMFSite!
+
+ for deleted in DELETED_SKINS:
+
+ try:
+
+ skins_tool._delObject( deleted )
+
+ except AttributeError:
+ pass
+
+ else:
+ log.append( 'Deleted CMFDecor skin directory: %s' % deleted )
+
+ for moved in MOVED_SKINS:
+
+ skin_dir = getattr( skins_tool, moved, None )
+
+ if skin_dir is not None:
+
+ skin_dir.manage_properties(
+ dirpath='Products/CMFDefault/skins/%s' % moved )
+ log.append( 'Updated CMFDecor skin directory to CMFDefault: %s'
+ % moved )
+
+ return string.join( log, '\n' )
=== CMF/CMFDefault/Extensions/update_catalogIndexes.py 1.1 => 1.2 ===
+
+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.'