def test_synchronize_page_config_with_blocks_on_empty_page(self): page = create(Builder("sample container")) create(Builder("sample block").within(page)) result = synchronize_page_config_with_blocks(page) self.assertEquals({"added": ["staticuid00000000000000000000002"], "removed": []}, result) self.assertEquals( {"default": [{"cols": [{"blocks": [{"uid": "staticuid00000000000000000000002"}]}]}]}, IPageConfiguration(page).load(), )
def test_synchronize_page_config_with_blocks_on_empty_page(self): page = create(Builder('sample container')) create(Builder('sample block').within(page)) result = synchronize_page_config_with_blocks(page) self.assertEquals( {'added': ['staticuid00000000000000000000002'], 'removed': []}, result) self.assertEquals( {'default': [{'cols': [{'blocks': [ {'uid': 'staticuid00000000000000000000002'}]}]}]}, IPageConfiguration(page).load())
def test_sl_page_state_is_updated_when_applying_working_copy(self): with staticuid('baseline'): baseline = create(Builder('sl content page').titled(u'A page') .with_blocks(Builder('sl textblock').titled(u'First'))) self.assertEquals( {'default': [{'cols': [{'blocks': [ {'uid': 'baseline000000000000000000000002'}]}]}]}, IPageConfiguration(baseline).load()) with staticuid('workingcopy'): working_copy = IStaging(baseline).create_working_copy(self.portal) self.assertEquals( {'default': [{'cols': [{'blocks': [ {'uid': 'workingcopy000000000000000000001'}]}]}]}, IPageConfiguration(working_copy).load()) with staticuid('editing'): create(Builder('sl textblock').titled(u'Second').within(working_copy)) synchronize_page_config_with_blocks(working_copy) self.assertEquals( {'default': [{'cols': [{'blocks': [ {'uid': 'workingcopy000000000000000000001'}, {'uid': 'editing0000000000000000000000001'}]}]}]}, IPageConfiguration(working_copy).load()) with staticuid('applying'): IStaging(working_copy).apply_working_copy() self.assertEquals( {'default': [{'cols': [{'blocks': [ {'uid': 'baseline000000000000000000000002'}, {'uid': 'applying000000000000000000000001'}]}]}]}, IPageConfiguration(baseline).load())
def reply(self): return synchronize_page_config_with_blocks(self.context)
def __call__(self, *args, **kwargs): synchronize_page_config_with_blocks(self.context) return super(PublishSLContainer, self).__call__(*args, **kwargs)
def after_create(self, obj): if self.block_builders: map(create, map(methodcaller('within', obj), self.block_builders)) synchronize_page_config_with_blocks(obj) return super(ContenPageBuilder, self).after_create(obj)
def synchronize_sl_page(obj, event): """ Always synchronize the simplelayout page config with the blocks before publishing. """ synchronize_page_config_with_blocks(obj)