def setDesignInterface(self, name, blocks=[]): """ sets the new view interface """ context = self.context context_expl = aq_inner(self.context).aq_explicit if not blocks: #remove grid infos if hasattr(context_expl, 'align_to_grid'): context.manage_changeProperties({'align_to_grid': '0'}) if name not in VIEW_INTERFACES_MAP: new = VIEW_INTERFACES_MAP['normal'] else: new = VIEW_INTERFACES_MAP[name] #remove current design interface for iface in VIEW_INTERFACES_MAP.values(): if iface.providedBy(context): noLongerProvides(context, iface) #set the new one alsoProvides(context, new) context.reindexObject(idxs=['object_provides']) #set init interfaces on blocks ifaces = [] if name in INIT_INTERFACES_MAP: ifaces = INIT_INTERFACES_MAP[name] contents = blocks and blocks or context.getFolderContents( {'object_provides': BLOCK_INTERFACES}, full_objects=True) for obj in contents: #remove given block heights blockconf = IBlockConfig(obj) blockconf.block_height = None #remove all related Interfaces for i in COLUMN_INTERFACES_MAP.values() + \ SLOT_INTERFACES_MAP.values(): if i.providedBy(obj): noLongerProvides(obj, i) for iface in ifaces: alsoProvides(obj, iface) obj.reindexObject(idxs=['object_provides']) #calc new images sizes and store them try: converter = getUtility(IBlockControl, name='block-layout') except ComponentLookupError: pass converter.update(context, obj, obj.REQUEST) if not blocks: return self.request.RESPONSE.redirect(context.absolute_url())
def setBlockHeights(self, uids=[], left=[], right=[]): """ usage: needs a list of uid, height pairs... if the uid of a block is missing, the height attribute of this block will be deleted """ # XXX: # Don't understand, why the varname:list, will shown as # varname:list[] # I just make this work, but it needs to be fixed uids = self.request.get('uids:list[]', []) # In case if only one block is available if not isinstance(uids, list): uids = [uids] left = self.request.get('left:list[0][]', []) right = self.request.get('right:list[0][]', []) # create a dict _d = {} real_uids = [u.replace('uid_', '') for u in uids] if right or left: for uid, height in [right] + [left]: _d[uid.replace('uid_', '')] = height for uid in real_uids: block = self.context.reference_catalog.lookupObject(uid) blockconf = IBlockConfig(block) if uid in _d.keys(): #set height blockconf.block_height = _d[uid] else: #remove heights blockconf.block_height = None return 1