Reputation: 3437
I have a other.package
registering a view my_view
. Then I'm trying to replace this view with a view defined in mine this.package
.
<browser:page
for="other.package.interfaces.IBarClass"
name="my_view"
class="this.package.views.FooClass"
permission="zope2.View"
layer="this.package.interfaces.IThisPackageContentLayer"
/>
For some reason my_view
is not overrided. I think its about layers priority maybe, but I have no idea how to fix it. Any suggestion?
If I rename the view (name="my_view_new"
) it is working as expected. But if the same name is used, the original one seems to have priority. How can I change this?
UPDATE: It's about layer priority:
(Pdb) self.request.__provides__.__iro__[13]
<InterfaceClass other.package.interfaces.layer.IOriginalLayer>
(Pdb) self.request.__provides__.__iro__[14]
<InterfaceClass this.package.content.interfaces.IThisPackageContentLayer>
You can check the activated layers from HTTP request object by looking at self.request.provides.iro. Layers are evaluated from zero index (highest priority) the last index (lowest priority). (source)
So, the problem is how can I prioritize a layer?
Upvotes: 0
Views: 101
Reputation: 610
Another way is, to use ZCML-Overrides with the same browser layer. That should also override the original, but the solution with sub classing the original layer is a bit nice ;).
Upvotes: 2