如何将库存portlet(从plone.app.portlets)添加到自定义portlet管理器中?
使用plone.org上的和论坛中的一些工具,我能够在plone 4.0.8中我的内容下面获得一个定制的portlet管理器。实际上,我们的目标是在内容下方设置4个自定义管理器,就像仪表板一样 无论如何,我的管理器只允许我添加静态和集合portlet。在查看代码之后,我发现当系统填充“AddNewPortlet”下拉列表时,它会遍历所有portlet。然后,它循环检查每个portlet的“for_”属性检查,以查看接口是否由self——我的portlet管理器提供如何将库存portlet(从plone.app.portlets)添加到自定义portlet管理器中?,plone,Plone,使用plone.org上的和论坛中的一些工具,我能够在plone 4.0.8中我的内容下面获得一个定制的portlet管理器。实际上,我们的目标是在内容下方设置4个自定义管理器,就像仪表板一样 无论如何,我的管理器只允许我添加静态和集合portlet。在查看代码之后,我发现当系统填充“AddNewPortlet”下拉列表时,它会遍历所有portlet。然后,它循环检查每个portlet的“for_”属性检查,以查看接口是否由self——我的portlet管理器提供 def getAddableP
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”接口列表中?这可能是最好的方法。这里的关键是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已经对它进行了子类化。我将我的管理器接口从
类IBottomPortletManager(IPortletManager)
更改为类IBottomPortletManager(IPortletManager,IColumn)
IColumn是在plone.app.portlet中定义的,因此,这些portlet已经为提供IColumn的管理器注册。现在,这是实现这一点的理想方法吗?出于好奇,我如何向我的manager界面添加其他注册?假设我只使用IPortletManager作为基础,但我还需要新闻Portlet。如何将我的manager界面添加到新闻portlet注册?我一直在plone.app.portlets中四处寻找,试图弄清楚这些portlet是如何注册接口的,但运气不好。用一个例子更新了我的答案。