You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After static resources reorganization, the getIcon catalog metadata was not updated.
We need to create a new upgrade step to fix this metadata:
deffix_cover_icons(context):
""" Based on https://bit.ly/2FZcnYY """zcatalog=getToolByName(context, 'portal_catalog')
# get the more hidden, inner (real) catalog implementationcatalog=zcatalog._catalogtry:
# Get the getIcon index value and# check if there is a getIcon at all, this may not exist in some# customizations, who knows, but always exists in default Plonemetadata_index=catalog.names.index('getIcon')
exceptValueError:
logger.info('`getIcon` not in metadata, skip upgrade step')
returncnt=0# search whole catalogresults=zcatalog.unrestrictedSearchResults(
portal_type='collective.cover.content')
num_objects=len(results)
pghandler=ZLogHandler(1000)
pghandler.init('Updating getIcon metadata', num_objects)
forbraininresults:
pghandler.report(cnt)
# First get the new valuetry:
obj=brain._unrestrictedGetObject()
except (AttributeError, KeyError, TypeError, NotFound):
continue# We can now update the record with the new getIcon valuerecord=list(catalog.data[brain.getRID()])
new_value=record[metadata_index]
if'/img/'notinnew_value:
new_value=new_value.split('/')
new_value.insert(1, 'img')
new_value='/'.join(new_value)
record[metadata_index] =new_valuecatalog.data[brain.getRID()] =tuple(record)
cnt+=1# we are curious# donepghandler.finish()
logger.info('Reindexed `getIcon` for %s items', str(cnt))
The text was updated successfully, but these errors were encountered:
After static resources reorganization, the
getIcon
catalog metadata was not updated.We need to create a new upgrade step to fix this metadata:
The text was updated successfully, but these errors were encountered: