Zope3浏览器:页面多个接口

bog*_*tan 3 zope interface zcml zope3

假设我的configure.zcml文件中有以下代码.我希望我的课程也可以用于另一个界面,让我们说吧Interface2

<browser:page
        for="Interface1"
        class="plone.app.content.browser.reviewlist.FullReviewListView"
        name="full_review_list"
        template="document_full_review_list.pt"
        permission="cmf.ReviewPortalContent" />
Run Code Online (Sandbox Code Playgroud)

如何在我的zcml文件中声明这个?

这么久我尝试了下面的内容:

<browser:page
       for="Interface1 Interface2"
       class="plone.app.content.browser.reviewlist.FullReviewListView"
       name="full_review_list"
       template="document_full_review_list.pt"
       permission="cmf.ReviewPortalContent" />
Run Code Online (Sandbox Code Playgroud)

<browser:page
       for="Interface1"
       allowed_interface="Interface2"
       class="plone.app.content.browser.reviewlist.FullReviewListView"
       name="full_review_list"
       template="document_full_review_list.pt"
       permission="cmf.ReviewPortalContent" />
Run Code Online (Sandbox Code Playgroud)

JC *_*and 6

您必须为每个接口注册两次,每次一次.

名称可以相同,但不会获得ConfigurationConflictError,因为browserview是一个命名的多适配器,它同时适应提供特定接口(即Interface1Interface2)的对象和请求.

因此,如果对象应该为每个browserview注册提供的接口不同,那么就没有冲突.

<browser:page
        for="Interface1"
        class="plone.app.content.browser.reviewlist.FullReviewListView"
        name="full_review_list"
        template="document_full_review_list.pt"
        permission="cmf.ReviewPortalContent" />

<browser:page
        for="Interface2"
        class="plone.app.content.browser.reviewlist.FullReviewListView"
        name="full_review_list"
        template="document_full_review_list.pt"
        permission="cmf.ReviewPortalContent" />
Run Code Online (Sandbox Code Playgroud)

相反,对于相同的对象接口(并且具有相同的名称),您可以有两个浏览器视图注册,但是识别标准是请求提供的接口.这就是图层属性的用途.