Example #1
0
    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())
Example #2
0
def blockMoved(obj, event):
    reindexContainer(obj, event, parent=event.oldParent)
    reindexContainer(obj, event, parent=event.newParent)

    if obj != event.object:
        # Moving the parent, so we do not reset the layout.
        return

    # remove slote interfaces
    for key, iface in SLOT_INTERFACES_MAP.items():
        if iface.providedBy(obj):
            noLongerProvides(obj, iface)

    # set current view config interfaces (slot and colum interface)
    for name, iface in VIEW_INTERFACES_MAP.items():
        if iface.providedBy(event.newParent):
            alsoProvides(obj, INIT_INTERFACES_MAP.get(name))
            break
Example #3
0
def setDefaultBlockInterfaces(obj, event):
    parent = obj.aq_parent
    parent_iface = None
    for i in VIEW_INTERFACES_MAP.values():
        if i.providedBy(parent):
            parent_iface = i

    if parent_iface is None:
        return
    name = parent_iface['name'].__name__
    ifaces = []
    if name in INIT_INTERFACES_MAP:
        ifaces = INIT_INTERFACES_MAP[name]
    for iface in ifaces:
        alsoProvides(obj, iface)
    obj.reindexObject(idxs=['object_provides'])

    #XXX this should be done earlier, we do now twice... once is enought
    #calc new images sizes and store them
    try:
        converter = getUtility(IBlockControl, name='block-layout')
    except ComponentLookupError:
        pass
    converter.update(parent, obj, obj.REQUEST)