def update_asset_download_children(root, registry): # pragma: no cover """Add asset downloads and update IAssetMetadata sheet.""" from adhocracy_core.sheets.asset import IAssetMetadata from adhocracy_core.sheets.image import IImageMetadata from adhocracy_core.resources.asset import add_metadata from adhocracy_core.resources.image import add_image_size_downloads catalogs = find_service(root, 'catalogs') assets = _search_for_interfaces(catalogs, IAsset) count = len(assets) for index, asset in enumerate(assets): logger.info('Migrating resource {0} of {1}'.format(index + 1, count)) old_downloads = [x for x in asset] for old in old_downloads: del asset[old] try: if IAssetMetadata.providedBy(asset): add_metadata(asset, registry) if IImageMetadata.providedBy(asset): add_image_size_downloads(asset, registry) except AttributeError: logger.warn('Asset {} has no downloads to migrate.'.format(asset))
def update_asset_download(event): """Update asset download.""" add_metadata(event.object, event.registry)