コード例 #1
0
ファイル: indexer.py プロジェクト: 4teamwork/ftw.contentpage
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
コード例 #2
0
ファイル: sl.py プロジェクト: 4teamwork/ftw.publisher.sender
    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
コード例 #3
0
    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
コード例 #4
0
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')
コード例 #5
0
 def test_simplelayout_integration(self):
     listingblock = self._create_listingblock()
     ISimpleLayoutBlock.providedBy(listingblock)
コード例 #6
0
 def test_simplelayout_integration(self):
     textblock = create(Builder('text block').within(self.contentpage))
     ISimpleLayoutBlock.providedBy(textblock)
コード例 #7
0
 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)
コード例 #9
0
 def test_simplelayout_integration(self):
     addressblock = self.portal.get(self.contentpage.invokeFactory("AddressBlock", "addressblock"))
     ISimpleLayoutBlock.providedBy(addressblock)