[英]Zope3 browser:page multiple interfaces
Let's say I have the following code in my configure.zcml file. 假设我的configure.zcml文件中有以下代码。 I want my class to be implemented for another interface too, let's say
Interface2
我希望我的类也可以用于另一个接口,比如说
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" />
How do I declare this in my zcml file? 如何在我的zcml文件中声明这个?
So long I tried the folowing: 这么久我尝试了下面的内容:
<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" />
and 和
<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" />
You will have to register it twice, once for each interface. 您必须为每个接口注册两次,每次一次。
The name can be the same, without getting a ConfigurationConflictError , since a browserview is a named multi-adapter that adapts both an object providing a specific interface (ie Interface1 or Interface2 ) and the request. 名称可以相同,但不会获得ConfigurationConflictError ,因为browserview是一个命名的多适配器,它同时适应提供特定接口(即Interface1或Interface2 )的对象和请求。
So if the interface that the object is supposed to provide is different for each browserview registration, then there is no conflict. 因此,如果对象应该为每个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" />
Conversely, you can have two browserview registrations, for the same object interface (and with the same name), but with the discerning criteria being an interface provided by the request. 相反,对于相同的对象接口(并且具有相同的名称),您可以有两个浏览器视图注册,但是识别标准是请求提供的接口。 That's what the layer attribute is for.
这就是图层属性的用途。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.