如何将库存portlet(从plone.app.portlets)添加到我的自定义portlet管理器?

时间:2011-08-16 14:42:15

标签: plone

使用plone.org上的documentation以及论坛中的一些内容,我能够在Plone 4.0.8中的内容下面获得一个自定义portlet管理器。实际上,目标是在仪表板之外安排4个自定义管理器。

无论如何,我的经理只允许我添加静态和集合portlet。在查看代码后,我发现当系统填充“添加新portlet”下拉列表时,它会循环遍历所有portlet。然后,它遍历每个portlet的'for_'属性检查,以查看接口是否由self-my portlet manager提供。

def getAddablePortletTypes(self):
    addable = []
    for p in getUtilitiesFor(IPortletType):
        # BBB - first condition, because starting with Plone 3.1                                                                                                                                  
        #every p[1].for_ should be a list                                                                                                                                                         
        if not isinstance(p[1].for_, list):
            logger.warning("Deprecation Warning ..." % p[1].addview)
            if p[1].for_ is None or p[1].for_.providedBy(self):
                addable.append(p[1])
        elif [i for i in p[1].for_ if i.providedBy(self)]:
            addable.append(p[1])
    return addable

如何将我的经理界面添加到每个portlet的'for_'接口列表中?

1 个答案:

答案 0 :(得分:6)

你的comment可能是最好的方法。这里的关键是portlet本身被注册到portlet管理器接口,以及上下文,层等的其他接口。例如,另一种方法是在profiles / default / portlets.xml中添加其他注册。将文件发送到您想要添加的每个portlet的portlet管理器界面:

<portlet
  addview="portlets.News"
  title="News"
  description="A portlet which can render a listing of recent news"
  i18n:attributes="title;
                   description"
  >
  <for interface="your.package.IYourPortletManager" />
</portlet>

然而,你的方式可能是最好的,因为听起来你正在创建一个柱状portlet管理器。但是,您可以从基类中删除IPortletManager,因为IColumn已经将它子类化了。

相关问题