开发者

How can I use zope 3 / ztk layers without having a zope 2 skin layer in Plone 4?

We're trying to develop our Plone 4.1 product using only ZTK (Zope 3) views and hence haven't defined a portal s开发者_运维百科kin. 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'
    """


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:

<?xml version="1.0"?>
<!-- Register the package-specific browser layer, so that it will be activated
when this product is installed. -->
<layers>
    <layer name="my.package.browserlayer" 
           interface="my.package.browser.interfaces.IThemeSpecific" />
</layers>

After that you can use the layer attribute as always:

<browser:page
    name="my-view"
    for="*"
    layer="my.package.browser.interfaces.IThemeSpecific"
    />

Just remember to restart zope and reinstall you product to apply the new genericsetup configuration.

That's all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜