def migrateActionsAndLayoutNames(portal_setup): portal_url = getToolByName(portal_setup, 'portal_url') portal = portal_url.getPortalObject() catalog = getToolByName(portal_setup, 'portal_catalog') query = {} query['portal_type'] = ['Image', 'Paragraph'] results = catalog(query) for b in results: obj = aq_inner(b.getObject()).aq_explicit blockconf = IBlockConfig(obj) layout = blockconf.image_layout migrate_layout = {'half': 'middle', 'squarish': 'small', 'full': 'full', 'thumbnail': 'small', '25': 'small', '33': 'middle', '50': 'full', 'no-image': 'no-image'} if layout and layout not in ['small', 'middle', 'full']: blockconf.image_layout = migrate_layout[layout] obsoleteactions = ['sl-25', 'sl-33', 'sl-50', 'sl-squarish'] image_actions = portal.portal_types.Image._cloneActions() for a in image_actions: if a.id in obsoleteactions: image_actions.remove(a) portal.portal_types.Image._actions = image_actions return 'migration done'
def update(self, parent, block, request, **kwargs): self.block = block #we store everything in annotations blockconf = IBlockConfig(block) layout = kwargs.get('layout', '') viewname = kwargs.get('viewname', '') if not layout: layout = request.get('layout', '') fieldname = request.get('fieldname', '') if not fieldname: fieldname = 'image' #This allows us to change the view without changing the imagelayout. if layout != '' and layout != 'dummy-dummy': blockconf.image_layout = layout #This allows us to change the imagelayout without reseting the view. if viewname != '' and viewname != 'dummy': blockconf.viewname = viewname #This is a fallback for old actions which switch to the default view without defining a viewname. elif (layout == '' or layout == 'dummy-dummy') and (viewname != '' and viewname == 'dummy'): blockconf.viewname = 'block_view'