Hash 如何获取为自定义portlet管理器分配的日历portlet的portlet哈希css类?

Hash 如何获取为自定义portlet管理器分配的日历portlet的portlet哈希css类?,hash,calendar,portlet,plone,Hash,Calendar,Portlet,Plone,我正在尝试修复为自定义portlet管理器分配的日历portlet的月份导航。此管理器是从特定的浏览器页面模板调用的,该模板具有: 不幸的是,管理器没有为我呈现带有散列的包装器,因此我试图手动将kssattr portlethash css类附加到上面的标记中,以使月份导航正常工作(refreshPortlet()需要它)。我试过这个: 从plone.portlets.utils导入hashPortletInfo 类节HomeView(浏览视图): “”“SectionHome浏览器视图”

我正在尝试修复为自定义portlet管理器分配的日历portlet的月份导航。此管理器是从特定的浏览器页面模板调用的,该模板具有:


不幸的是,管理器没有为我呈现带有散列的包装器,因此我试图手动将kssattr portlethash css类附加到上面的
标记中,以使月份导航正常工作(refreshPortlet()需要它)。我试过这个:

从plone.portlets.utils导入hashPortletInfo
类节HomeView(浏览视图):
“”“SectionHome浏览器视图”
"""
实现(ISectionHomeView)
定义初始化(自身、上下文、请求):
self.context=context
self.request=请求
@财产
def getHash(self):
info=dict(manager='my.custom.portletmanager',
类别='上下文',
key='/my section',
名称='mycalendar',
)
返回hashPortletInfo(信息)
使用这段代码我确实得到了一个散列,但日历导航仍然不起作用如何访问portlet信息,如经理、类别、键和名称,以便正确计算它?


我希望我拥有plone.app.portlets.browser.templates中column.pt描述的行为及其类ColumnPortletManagerRenderer(portlets/manager.py),但我不知道如何让我的自定义管理器提供这些行为(即:像默认管理器那样).

您需要确保安装了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')
其中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>

您能否提供一些代码,让我们知道在哪里可以帮助您?