在 Plone 4 中没有 zope 2 皮肤层的情况下如何使用 zope 3 / ztk 层?
我们正在尝试仅使用 ZTK (Zope 3) 视图来开发 Plone 4.1 产品,因此尚未定义门户皮肤。我正在尝试覆盖来自不同包的视图,并且过去曾使用图层属性来执行此操作。
plone.theme 允许您使用当前选定皮肤的“层”界面来标记请求。如果安装了我的产品,我想用“层”界面标记请求,而不创建皮肤层。我该怎么做?
我已经在 zcml 中定义了接口
<interface
interface=".interfaces.IThemeSpecific"
type="zope.publisher.interfaces.browser.IBrowserSkinType"
name="My Theme"
/>
并声明了
from zope.interface import Interface
class IThemeSpecific(Interface):
"""Marker interface for skins part of 'My Theme'
"""
We're trying to develop our Plone 4.1 product using only ZTK (Zope 3) views and hence haven't defined a portal skin. I'm trying to override a view from a different package and in the past have used the layer attribute to do this.
plone.theme allows you to mark the request with a "layer" interface conditional on the currently selected skin. I'd like to mark requests with a "layer" interface if my product is installed, without creating a skin layer. How do I do that?
I have my interface defined already in zcml
<interface
interface=".interfaces.IThemeSpecific"
type="zope.publisher.interfaces.browser.IBrowserSkinType"
name="My Theme"
/>
and declared
from zope.interface import Interface
class IThemeSpecific(Interface):
"""Marker interface for skins part of 'My Theme'
"""
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用浏览器层。
因此,如果您不需要它做其他事情,您可以删除 zcml 接口声明并仅保留 python 接口(也许您可以将其重命名为更具体的名称,例如 IMyPackageLayer)。然后在您的通用设置配置文件中添加一个文件 browserlayer.xml,如下所示:
之后您可以像往常一样使用图层属性:
只需记住重新启动 zope 并重新安装您的产品以应用新的 genericsetup 配置。
就这样。
You have to use a browserlayer.
So, if you don't need it for something else, you can remove the zcml interface declaration and keep only the python interface (maybe you can rename it something more specific like IMyPackageLayer). Then add a file browserlayer.xml in your generic setup profile with this:
After that you can use the layer attribute as always:
Just remember to restart zope and reinstall you product to apply the new genericsetup configuration.
That's all.