如何将 Stock Portlet(来自 plone.app.portlets)添加到我的自定义 Portlet 管理器?
使用 plone.org 上的文档与论坛中的一些内容一起,我能够在 Plone 4.0.8 中的内容下方获得自定义 portlet 管理器。实际上,目标是在内容下方有 4 个自定义管理器,如仪表板一样排列。
不管怎样,我的经理只允许我添加静态和集合 portlet。查看代码后,我发现当系统填充“添加新 portlet”下拉列表时,它会循环遍历所有 portlet。然后,它循环检查每个 portlet 的“for_”属性,以查看接口是否由我的 portlet 管理器自己提供。
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_”接口列表中?
Using the documentation on plone.org along with some in the forum, I was able to get a custom portlet manager below my content in Plone 4.0.8. The goal, actually, is to have 4 custom managers below the content arranged like the dashboard.
Anyway, my manager only allows me to add static and collection portlets. After looking around in the code, I found that when the system goes to populate that 'Add new portlet' dropdown, it loops through all of the portlets. Then, it loops through each portlet's 'for_' attribute checking to see if the interfaces are provided by 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
How do I add my manager's interface to each portlet's 'for_' list of interfaces?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 评论可能是最好的方法。这里的关键是 portlet 本身注册到 portlet 管理器接口,以及上下文、层等的其他接口。例如,另一种方法是在 profile/default/portlets.xml 中添加额外的注册。将每个您想要添加的 portlet 文件添加到您的 portlet 管理器界面:
不过,您的方式可能是最好的,因为听起来您正在创建一个柱状 portlet 管理器。但是,您可以从基类中删除 IPortletManager,因为 IColumn 已经对其进行了子类化。
Your comment is probably the best way to do this. The crux here is that portlets themselves are registered to a portlet manager interface, among other interfaces for contexts, layers, etc.. Another way to do this, for example, would be to add additional registrations in your profiles/default/portlets.xml file to your portlet manager interface for each of the portlets you want addable:
Your way is probably best, however, since it sounds like you are creating a columnar portlet manager. You could remove IPortletManager from the base classes, however, since IColumn already subclasses it.