本文整理汇总了Python中plone.app.layout.viewlets.content.ContentRelatedItems.related_items方法的典型用法代码示例。如果您正苦于以下问题:Python ContentRelatedItems.related_items方法的具体用法?Python ContentRelatedItems.related_items怎么用?Python ContentRelatedItems.related_items使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.app.layout.viewlets.content.ContentRelatedItems
的用法示例。
在下文中一共展示了ContentRelatedItems.related_items方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_related_items
# 需要导入模块: from plone.app.layout.viewlets.content import ContentRelatedItems [as 别名]
# 或者: from plone.app.layout.viewlets.content.ContentRelatedItems import related_items [as 别名]
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()
示例2: testDexterityDeletedRelatedItems
# 需要导入模块: from plone.app.layout.viewlets.content import ContentRelatedItems [as 别名]
# 或者: from plone.app.layout.viewlets.content.ContentRelatedItems import related_items [as 别名]
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'])