Dav*_*ima 5 hash portlet calendar plone
我正在尝试修复为自定义portlet管理器分配的日历portlet的月份导航.从特定的浏览器页面模板调用此管理器:
<div id="calendar"
tal:content="structure provider:my.custom.portletmanager" />
Run Code Online (Sandbox Code Playgroud)
不幸的是,管理器没有为我呈现带有哈希的包装器,所以我试图手动将kssattr-portlethash css类附加到上面的<div>标签,以使月导航工作(refreshPortlet()需要它).我试过这个:
from plone.portlets.utils import hashPortletInfo
class SectionHomeView(BrowserView):
"""SectionHome browser view
"""
implements(ISectionHomeView)
def __init__(self, context, request):
self.context = context
self.request = request
@property
def getHash(self):
info = dict(manager = 'my.custom.portletmanager',
category = 'context',
key = '/my-section',
name = 'mycalendar',
)
return hashPortletInfo(info)
Run Code Online (Sandbox Code Playgroud)
使用此代码我得到一个哈希,但日历导航仍然无法正常工作.如何才能访问portlet信息,例如经理,类别,密钥和名称,以便正确计算?
我希望我有来自plone.app.portlets.browser.templates的column.pt及其类ColumnPortletManagerRenderer(portlets/manager.py)所描述的行为,但我不知道如何让我的自定义管理器提供那些(即:like默认经理做).
您需要确保安装了知道渲染哈希值的 PortletManagerRenderer 和 EditPortletManagerRenderer,例如:
class MyCustomPortletManagerRenderer(ColumnPortletManagerRenderer) :
""" This custom version of ColumnPortletManagerRenderer points to a new
template so that HTML can be customised.
"""
adapts(Interface, IThemeSpecific, IBrowserView, IMyCustomPortletManager)
template = ViewPageTemplateFile('column.pt')
def can_manage_portlets(self):
context = self._context()
if not ILocalPortletAssignable.providedBy(context):
return False
mtool = getToolByName(context, 'portal_membership')
return mtool.checkPermission("Portlets: Manage portlets", context)
class MyCustomEditPortletManagerRenderer(ContextualEditPortletManagerRenderer):
"""To allow edit support of the above.
"""
adapts(Interface, IThemeSpecific, IManageContextualPortletsView, IMyCustomPortletManager)
template = ViewPageTemplateFile('edit-column.pt')
Run Code Online (Sandbox Code Playgroud)
其中column.pt 看起来像:
<tal:block repeat="portlet options/portlets">
<div tal:attributes="class string:portletWrapper kssattr-portlethash-${portlet/hash};"
tal:content="structure python:view.safe_render(portlet['renderer'])" />
</tal:block>
Run Code Online (Sandbox Code Playgroud)