当前位置: 首页>>代码示例>>Python>>正文


Python content.ContentRelatedItems类代码示例

本文整理汇总了Python中plone.app.layout.viewlets.content.ContentRelatedItems的典型用法代码示例。如果您正苦于以下问题:Python ContentRelatedItems类的具体用法?Python ContentRelatedItems怎么用?Python ContentRelatedItems使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ContentRelatedItems类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_related_items

    def get_related_items(self):
        """
        Como ainda customizamos a visão de nitf, na versão 1.x de
        collective.nitf, tínhamos o atributo relatedItems no tipo nitf. Na
        template customizada, renderizávamos o widget presente em
        collective.z3cform.widgets, pro campo relatedItems (esses são os objetos
        que eram disponibilizados em nitf_custom_view na div newsRelatedItems).

        <NITF at conheca-o-novo-modelo-da-identidade-digital-padrao-do-governo-federal>
        [<z3c.relationfield.relation.RelationValue object at 0x7f15d8575cf8>]
        <brasil.gov.portal.browser.content.nitf_custom_view.View object at 0x7f15d6c72f90>
        {'byline': <TextWidget 'form.widgets.byline'>,
        'subtitle': <TextWidget 'form.widgets.subtitle'>,
        'text': <RichTextWidget 'form.widgets.text'>,
        'section': <SelectWidget 'form.widgets.section'>,
        'relatedItems': <MultiContentSearchWidget 'form.widgets.relatedItems'>,
        'location': <TextWidget 'form.widgets.location'>,
        'genre': <SelectWidget 'form.widgets.genre'>,
        'urgency': <SelectWidget 'form.widgets.urgency'>}

        Acontece que após os commits:

        https://github.com/collective/collective.nitf/commit/a4704e26210cbdf5aadd473503d14947034a613a

        https://github.com/collective/collective.nitf/commit/5a27baa54f728f1de123c6883e02020b481d7d00

        Esse campo foi completamente removido e portanto ao atualizar para 2.x
        dá erro na renderização da template que ainda espera esses atributos.

        Dessa forma, usaremos o método padrão da viewlet do Plone de retornar
        itens relacionados, e montaremos na template com o mesmo html que o
        widgets da versão 1.x montaria mantendo assim o layotu padrão.
        """
        viewlet = ContentRelatedItems(self.context, self.request, None, None)
        return viewlet.related_items()
开发者ID:brunobbbs,项目名称:brasil.gov.portal,代码行数:35,代码来源:nitf_custom_view.py

示例2: testDexterityDeletedRelatedItems

 def testDexterityDeletedRelatedItems(self):
     # Deleted related items should not cause problems.
     self.folder._delObject('doc1')
     request = self.app.REQUEST
     viewlet = ContentRelatedItems(self.folder.dex1, request, None, None)
     viewlet.update()
     related = viewlet.related_items()
     self.assertEqual([x.id for x in related], ['doc2'])
开发者ID:plone,项目名称:plone.app.layout,代码行数:8,代码来源:test_content.py


注:本文中的plone.app.layout.viewlets.content.ContentRelatedItems类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。