plone theme和five.grok开发人员的view和viewlet助手模块
collective.fastview的Python项目详细描述
内容
Introduction
collective.fastview为plone视图和模板管理提供了框架级的帮助程序代码。 它是用来给一些工作区一些粗糙的角落在这些Zope 3 以及five.grokviewlet框架。
Render viewlets directly anywhere in the template
您可以直接在viewlet中调用任何页面模板代码 使用viewlet遍历器。collective.fastview寄存器 名为@@viewlets的视图,可用于遍历 要呈现任何viewlet代码:
<div id="header"> <div tal:replace="structure context/@@viewlets/plone.logo" /> </div>
注意,您仍然需要对某些(任何)viewlet管理器注册viewlet, 但它可以是一个虚拟的,从来没有使用语法来呈现:
<div tal:replace="structure provider:myarghyetanotherviewletmanagername" />
虚拟Viewlet管理器示例:
class MainViewletManager(grok.ViewletManager): """ This viewlet manager is responsible for all gomobiletheme.basic viewlet registrations. Viewlets are directly referred in main_template.pt by viewlet name, thus overriding Plone behavior to go through ViewletManager render step. """ grok.name('gomobiletheme.basic.viewletmanager') # Set viewlet manager default to all following viewlets grok.viewletmanager(MainViewletManager)
Fix Grok 1.0 template inheritance
这解决了grok 1.0中的问题,即视图和viewlets模板不能在包之间继承。 例如,如果您将视图划分为子类,则还需要手动复制视图模板。
我们希望将来能解决这个问题。
请参见:
示例:
from collective.fastview.utilities import fix_grok_template_inheritance from gomobiletheme.basic import viewlets as base from gomobiletheme.basic.viewlets import MainViewletManager from plonecommunity.app.interfaces import IThemeLayer # Viewlets are on all content by default. grok.context(Interface) # Use templates directory to search for templates. grok.templatedir("templates") # Viewlets are active only when gomobiletheme.basic theme layer is activated grok.layer(IThemeLayer) grok.viewletmanager(MainViewletManager) class Head(base.Head): """ My inherited viewlet. """ # Fix for grok 1.0 template inheritance # https://bugs.launchpad.net/grok/+bug/255005 # This will force Head viewlet to use its parent class template fix_grok_template_inheritance(Head, base.Head)
0.2.1 - 0.2.2
- 修正了代码[miohtama]中的调试语句
0.2 - 0.2.1
- 如果viewlet在update()或render()[miohtama]上引发异常,请尝试更智能地处理这种情况
- 清理了一些文档[miohtama]
0.1 - 0.2
- plone 4兼容性
- 删除了全局定义特殊处理程序-它们用于plone 3, 但是plone 4现在已经解决了问题本身
- 按名称找不到为cases viewlet添加的特殊异常类型。 返回notfound是个坏主意,因为zope对于 这个异常(你得到404)。
0.1
- 初始版本