def snippet_text(obj): """Text for snippets (aka highlighting) in search results.""" text = obj.SearchableText() # Remove id and title for fieldname in ['id', 'title']: field = obj.getField(fieldname) accessor = field.getIndexAccessor(obj) value = accessor() text = text.replace(value, '', 1) # Include snippet text of the various block types block_texts = [] for block in obj.objectValues(): if not ISimpleLayoutBlock.providedBy(block): continue # Only add title if it's visible if 'showTitle' in block.Schema(): if block.getShowTitle(): block_texts.append(block.Title()) else: block_texts.append(block.Title()) # Add block-specific fields for fieldname in SNIPPETTEXT_FIELDS.get(block.portal_type, []): field = block.getField(fieldname) accessor = field.getIndexAccessor(block) block_texts.append(accessor()) text += ' '.join(block_texts) return text
def get_blocks_without_worfklows(self): for obj in self.context.objectValues(): if not ISimpleLayoutBlock.providedBy(obj): continue state = getMultiAdapter((obj, self.request), IPublisherContextState) if state.has_workflow(): continue yield obj
def getCurrentLayout(self, block): if ISimpleLayoutBlock.providedBy(block): blockconf = IBlockConfig(block) viewname = blockconf.viewname image_layout = blockconf.image_layout if not image_layout: image_layout = '' if not viewname: viewname = '' if viewname: viewname = '-%s' % viewname return image_layout + viewname return None
def migrate_simplelayout_page_state(old_page, new_page): for block in new_page.listFolderContents(): if INewSLBlock.providedBy(block): raise ValueError('Block must be migrated after pages.') if not ISimpleLayoutBlock.providedBy(block): continue if ISlotBlock.providedBy(block) or IPortletColumn.providedBy(block): move_sl_block_into_slot(old_page, new_page, block, 'portletright') elif ISlotD.providedBy(block): move_sl_block_into_slot(old_page, new_page, block, 'bottom') else: move_sl_block_into_slot(old_page, new_page, block, 'default')
def test_simplelayout_integration(self): listingblock = self._create_listingblock() ISimpleLayoutBlock.providedBy(listingblock)
def test_simplelayout_integration(self): textblock = create(Builder('text block').within(self.contentpage)) ISimpleLayoutBlock.providedBy(textblock)
def test_simplelayout_integration(self): textblock = self._create_textblock() ISimpleLayoutBlock.providedBy(textblock)
def test_block_marker_interface(self): block = self.page.get( self.page.invokeFactory('Paragraph', 'paragraph')) ISimpleLayoutBlock.providedBy(block)
def test_simplelayout_integration(self): addressblock = self.portal.get(self.contentpage.invokeFactory("AddressBlock", "addressblock")) ISimpleLayoutBlock.providedBy(addressblock)