用于Plone主题和five.grok开发者的视图和视图辅助模块
项目描述
简介
collective.fastview为Plone视图和模板管理提供框架级辅助代码。它旨在用于解决Zope 3和five.grok视图辅助框架的一些边缘问题。
安装
将collective.fastview添加到buildout.cfg eggs列表中
eggs = ... collective.fastview
在模板中直接渲染视图辅助
您可以使用视图辅助遍历器直接将视图辅助调用放入任何页面模板代码中。collective.fastview注册了一个名为@@viewlets的视图,您可以使用它遍历来渲染任何视图辅助代码
<div id="header"> <div tal:replace="structure context/@@viewlets/plone.logo" /> </div>
请注意,您仍然需要针对某些(任何)视图辅助管理器注册视图辅助,但可以是一个虚拟的,它永远不会使用语法渲染
<div tal:replace="structure provider:myarghyetanotherviewletmanagername" />
虚拟视图辅助管理器的示例
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)
修复Grok 1.0模板继承问题
这修复了Grok 1.0的问题,即视图和视图辅助模板在包之间不可继承。例如,如果您子类化一个视图,您需要手动复制视图模板。
我们希望在未来解决这个问题。
见
示例
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)
示例
此代码主要用于与gomobiletheme.basic包一起使用,以提供无需围绕每个视图辅助构建视图辅助管理器的简单移动主题。
这些Python包使用此代码
源代码仓库
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 已自行解决问题
为 viewlet 通过名称找不到的情况添加了特殊的异常类型。返回 NotFound 是一个坏主意,因为 Zope 为此异常赋予了特殊含义(你得到 404)
0.1
初始发布
项目详情
关闭
collective.fastview-0.2.2.zip 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 90df40831d3cd95863a31c3afebd2a063fb9c26096850ce16b8314295ab97bcf |
|
MD5 | f0390053400d2c04e9c6db23a06bca24 |
|
BLAKE2b-256 | 3dc0e61fcad0d35a4be12bbf2dfd280e267ee254f5001c58c040c8875b3eed7f |