Plon 内容类型特定的 Portlet 分配

发布于 2024-12-05 04:29:38 字数 352 浏览 0 评论 0原文

我正在为 Plone 4 开发一个内容类型,并且我想阻止它可能从其父对象继承的所有用户、组和上下文 portlet。我对此时的文档感到非常困惑——在 portlets.xml 中, 似乎只解决了特定于路径的阻塞。 似乎是我想要的,但它似乎太具体了 – 我不想管理我的内容类型上所有可能的 portlet 的分配。

有一些提示表明我发现可以自定义特定于内容类型的 ILeftColumn 和 IRightColumn portlet 管理器,但我找不到任何好的示例。有人有任何提示或建议吗?我觉得我错过了一些非常简单的东西。

I'm developing a content type for Plone 4, and I'd like to block all user, group, and context portlets it may inherit from its parent object. I'm thoroughly confused by the documentation at this point–in portlets.xml, <blacklist/> only seems to address path-specific blocking. <assignment/> seems like what I want, but it seems too specific–I don't want to manage the assignment for all possible portlets on my content type.

There are hints that I've found that customizing an ILeftColumn and IRightColumn portlet manager specific to the content type, but I can't find any good examples. Does anyone have any hints or suggestions? I feel like I'm missing something dead simple.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

何止钟意 2024-12-12 04:29:38

为了防止 portlet 获取并保持添加 portlert 的可能性,您可以在创建内容时添加一个事件侦听器,以自动阻止获取。

像这样:

    <subscriber
        for="my.package.interfaces.IMyContent
             zope.app.container.interfaces.IObjectAddedEvent"                 
handler=".subscribers.blockPortletsUpponMyContentCreation"
                  />

然后这样做:

from zope.component import getMultiAdapter, getUtility
from plone.portlets.interfaces import IPortletManager
from plone.portlets.interfaces import ILocalPortletAssignmentManager
from plone.portlets.constants import USER_CATEGORY
from plone.portlets.constants import GROUP_CATEGORY
from plone.portlets.constants import CONTENT_TYPE_CATEGORY
from plone.portlets.constants import CONTEXT_CATEGORY

def blockPortletsUpponMyContentCreation(mycontent, event):
    for manager_name in ('plone.leftcolumn','plone.rightcolumn'):
        manager = getUtility(IPortletManager, name=manager_name)
        assignable = getMultiAdapter((mycontent, manager,), ILocalPortletAssignmentManager)
        for category in (GROUP_CATEGORY, CONTENT_TYPE_CATEGORY,CONTEXT_CATEGORY,USER_CATEGORY):
            assignable.setBlacklistStatus(category, 1)

注意:此代码的灵感来自 plone.app.portlet 管理视图

编辑 19/08/2011:在我未经测试的代码中包含 @will 建议的修复...所以现在已经测试

to prevent the portlet aquisition and maintain the possibility of adding portlert you can add an event listener on the creation of your contents that auto blocks the aquisition.

Like this:

    <subscriber
        for="my.package.interfaces.IMyContent
             zope.app.container.interfaces.IObjectAddedEvent"                 
handler=".subscribers.blockPortletsUpponMyContentCreation"
                  />

and than do this:

from zope.component import getMultiAdapter, getUtility
from plone.portlets.interfaces import IPortletManager
from plone.portlets.interfaces import ILocalPortletAssignmentManager
from plone.portlets.constants import USER_CATEGORY
from plone.portlets.constants import GROUP_CATEGORY
from plone.portlets.constants import CONTENT_TYPE_CATEGORY
from plone.portlets.constants import CONTEXT_CATEGORY

def blockPortletsUpponMyContentCreation(mycontent, event):
    for manager_name in ('plone.leftcolumn','plone.rightcolumn'):
        manager = getUtility(IPortletManager, name=manager_name)
        assignable = getMultiAdapter((mycontent, manager,), ILocalPortletAssignmentManager)
        for category in (GROUP_CATEGORY, CONTENT_TYPE_CATEGORY,CONTEXT_CATEGORY,USER_CATEGORY):
            assignable.setBlacklistStatus(category, 1)

Note: this code is inspired by the plone.app.portlet manage view

Edit 19/08/2011: included fixes as suggested by @will in my untested code...so now is tested

始终不够 2024-12-12 04:29:38

通过 Sitesetup(控制面板)-> 在站点上实时分配您的门户类型类型-> “管理分配给该内容类型的 portlet”。

然后通过ZMI导出配置->门户_设置->导出选项卡 ->选择“Portlet”->单击底部的“导出”。

提取 types/YourType.xml 文件并将相关部分复制到包的 profile/default/types/YourType.xml 中。

Do the assignment to your portaltype live on a site via Sitesetup (controlpanel) -> Types -> "Manage portlets assigned to this content type".

Then export the configuration via ZMI -> portal_setup -> Export-Tab -> select 'Portlets' -> click 'export' on bottom.

Extract the types/YourType.xml-file and copy the relevant parts in your package's profiles/default/types/YourType.xml.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文