如果视图是这样注册的,则使用zcml中的模板定义:
<browser:page
name="original-view"
class=".original_view.View"
permission="zope2.View"
for="*"
template="original_template.pt"
/>
Run Code Online (Sandbox Code Playgroud)
我想在我的产品中只定制他的课程,有没有办法在不定制模板的情况下做到这一点?
你必须包装浏览器:page by <configure package='XXXX'>
这意味着你在这个包装的范围内.
例:
<configure package="original.package.browser">
<!-- custom view -->
<browser:page
name="original-view"
class="your.package.browser.View" <!-- Full dotted name to you custom view class -->
permission="zope2.View"
for="*"
layer="your.package.interfaces.IYourPackageLayer" <!-- You should provide a browserlayer, otherwise you got a configuration conflict -->
template="original_template.pt" <!-- template from original.package.browser -->
/>
</configure>
Run Code Online (Sandbox Code Playgroud)
编辑:
正如@sdupton所提到的,我更新了使用图层剪切的示例代码如果你不能使用图层(BrowserLayer),你可以将代码,没有图层属性放入 overrides.zcml
您还可以Interface在for属性中指定更精确的值