假设我的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" />我如何在我的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" />和
<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" />发布于 2012-01-21 03:29:57
您必须注册它两次,每个接口一次。
名称可以是相同的,但不需要获取ConfigurationConflictError,,因为浏览器视图是一个命名的多适配器,它适应提供特定接口(即Interface1或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" />
<browser:page
for="Interface2"
class="plone.app.content.browser.reviewlist.FullReviewListView"
name="full_review_list"
template="document_full_review_list.pt"
permission="cmf.ReviewPortalContent" />相反,对于相同的对象接口(具有相同的名称),您可以有两个browserview注册,但识别标准是请求提供的接口。这就是layer属性的用途。
https://stackoverflow.com/questions/8941292
复制相似问题