[CMF-checkins] CVS: CMF - convertCatalogGetIconColumn.pys:1.1.2.1
Martijn Pieters
mj@digicool.com
Mon, 9 Apr 2001 16:06:14 -0400 (EDT)
Update of /cvs-repository/CMF/CMFDefault/scripts
In directory korak:/tmp/cvs-serv28640/CMFDefault/scripts
Added Files:
Tag: CMF-1_0-branch
convertCatalogGetIconColumn.pys
Log Message:
Issue PTK(244)[], switch to getIcon
- Use getIcon instead of icon wherever possible
- When creating a catalog, use a 'getIcon' column instead of the 'icon'
column.
- Provide a conversion Python Script for existing catalogs.
--- Added File convertCatalogGetIconColumn.pys in package CMF ---
## Script (Python) "convertCatalogGetIconColumn"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Convert portal_catalog to use 'getIcon' instead of 'icon'.
##
# Convert the 'icon' metadata column in the portal catalog to a 'getIcon'
# column. Unfortunately this means we have to drop the 'icon' column, and add
# the 'getIcon' column, then do a full reindex.
#
# To use this script, create it inside the Portal Root Folder and run it.
# You will need the Manager Role to fully assure correct execution.
catalog = context.portal_catalog
needReindex = 0
columns = catalog.schema()
if 'icon' in columns:
catalog.manage_delColumns(('icon',))
needReindex = 1
if 'getIcon' not in columns:
catalog.manage_addColumn('getIcon')
needReindex = 1
if needReindex == 1:
# We re-create the reindex code here; because we don't want to have to deal
# with the redirect that's unavoidable if we call manage_catalogReindex.
# Get all catalogued data, and extract the paths
paths = []
add = paths.append
for obj in catalog(): add(obj.getPath())
# Clear the catalog
catalog.manage_catalogClear()
# Index all paths again
for p in paths:
# I cannot use resolve_path, no access from Python Scripts.
# Having Manager access should be enough though.
obj = catalog.resolve_url(p, context.REQUEST)
if obj is not None:
catalog.catalog_object(obj, p)
return "Updated the catalog, now using 'getIcon' instead of 'icon'."
return 'Nothing done, catalog already tracks getIcon.'