Beispiel #1
0
    def test_syncs_pagestate_before_publishing(self):
        page = create(Builder('sl content page'))
        create(Builder('sl textblock').within(page))
        self.assertEquals([],
                          flattened_block_uids(
                              IPageConfiguration(page).load()))

        page.restrictedTraverse('@@publisher.publish')()
        self.assertEquals(['staticuid00000000000000000000002'],
                          flattened_block_uids(
                              IPageConfiguration(page).load()))
    def test_data_setter(self):
        page = create(Builder('sl content page').titled(u'The Page'))
        block = create(
            Builder('sl textblock').titled(u'The Block').within(page))
        component = getAdapter(
            page,
            IDataCollector,
            name='ftw.simplelayout:SimplelayoutPageAnnotations')
        component.setData(
            {"default": [
                {
                    "cols": [
                        {
                            "blocks": [{
                                "uid": IUUID(block)
                            }]
                        },
                    ]
                },
            ]}, {})

        self.assertEquals(
            {"default": [
                {
                    "cols": [
                        {
                            "blocks": [{
                                "uid": IUUID(block)
                            }]
                        },
                    ]
                },
            ]},
            IPageConfiguration(page).load())
Beispiel #3
0
    def migrate_prepare_page_state(self):
        config = IPageConfiguration(self.new)

        page_config = {
            "default": [{
                "cols": [
                    {
                        "blocks": []
                    },
                    {
                        "blocks": []
                    },
                    {
                        "blocks": []
                    },
                    {
                        "blocks": []
                    },
                ]
            }, {
                "cols": [{
                    "blocks": []
                }, {
                    "blocks": []
                }]
            }]
        }
        config.store(page_config)
Beispiel #4
0
    def create_block(self, portlet, manager, type_):

        config = IPageConfiguration(self.new)
        normalizer = getUtility(IFileNameNormalizer).normalize
        if type_ == 'teaser':
            block = create(
                Builder('sl textblock').within(self.new).titled(
                    portlet.teasertitle).having(
                        text=RichTextValue(portlet.teaserdesc),
                        image=NamedBlobImage(filename=normalizer(
                            portlet.image.filename).decode('utf-8'),
                                             data=portlet.image.data)))

            blockconfig = IBlockConfiguration(block)
            blockconfigdata = blockconfig.load()
            blockconfigdata['scale'] = 'large'
            blockconfigdata['imagefloat'] = 'no-float'
            blockconfig.store(blockconfigdata)

            if portlet.internal_target:
                teaser = ITeaser(block)
                target = uuidToObject(portlet.internal_target)
                if target:
                    intids = getUtility(IIntIds)
                    teaser.internal_link = RelationValue(intids.getId(target))

        elif type_ == 'static':
            block = create(
                Builder('sl textblock').within(self.new).titled(
                    portlet.header).having(text=RichTextValue(portlet.text)))
        else:
            return

        uid = IUUID(block)

        page_state = config.load()
        if manager == 'ftw.subsite.front1':
            page_state['default'][0]['cols'][0]['blocks'].append({'uid': uid})
        elif manager == 'ftw.subsite.front2':
            page_state['default'][0]['cols'][1]['blocks'].append({'uid': uid})
        elif manager == 'ftw.subsite.front3':
            page_state['default'][0]['cols'][2]['blocks'].append({'uid': uid})
        elif manager == 'ftw.subsite.front4':
            page_state['default'][0]['cols'][3]['blocks'].append({'uid': uid})
        elif manager == 'ftw.subsite.front5':
            page_state['default'][1]['cols'][0]['blocks'].append({'uid': uid})
        elif manager == 'ftw.subsite.front6':
            page_state['default'][1]['cols'][1]['blocks'].append({'uid': uid})
        # Don't know where manager 7 belongs
        elif manager == 'ftw.subsite.front7':
            page_state['default'][1]['cols'][0]['blocks'].append({'uid': uid})

        config.store(page_state)
 def setData(self, data, metadata):
     IPageConfiguration(self.context).store(data)
 def getData(self):
     return unwrap_persistence(IPageConfiguration(self.context).load())