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 __call__(self, uids=[], slot="", column="", obj_uid=""): uids = uids.split(",") for i in range(len(uids)): uid = uids[i] uid = uid.replace("uid_", "") obj = self.context.reference_catalog.lookupObject(uid) # Condition for a special usecase (show the current content also # as block. But this block is no moveable) if obj == self.context: continue id_ = obj.id self.context.moveObject(id_, i) obj.reindexObject(idxs=["getObjPositionInParent"]) # set the new interfaces o_uid = obj_uid.replace("uid_", "") o = self.context.reference_catalog.lookupObject(o_uid) iface_to_remove = [] if SLOT_INTERFACES_MAP.has_key(slot): for i in SLOT_INTERFACES_MAP.values(): if i.providedBy(o): iface_to_remove.append(i) if SLOT_INTERFACES_MAP[slot] not in iface_to_remove: for iface in iface_to_remove: noLongerProvides(o, iface) alsoProvides(o, SLOT_INTERFACES_MAP[slot]) for col in column.split(" "): if col.find("column") != -1: new_col = col if COLUMN_INTERFACES_MAP.has_key(new_col): for i in COLUMN_INTERFACES_MAP.values(): if i.providedBy(o): noLongerProvides(o, i) alsoProvides(o, COLUMN_INTERFACES_MAP[new_col]) o.reindexObject(idxs=["object_provides"]) return "ok"