Florian Lindner wrote:
> I have the following situation.
> an ICentershockSkin derived from Rotterdam:
> class ICentershockSkin(zope.app.rotterdam.Rotterdam):
> an IContentItem that works as base interface for all items:
> class IContentItem(Interface):
> an ILink that is such an item:
> class ILink(IContentItem):
> the ILink has an edit view on the default layer:
> menu="zmi_views" title="Edit"
> intended only for use withing the ZMI.
> The IContentItem has also registered a view called edit.html on the
> another interface derived from IContentItem is the IContentFolder which has
> edit view registered for the ZMI (on the default layer).
> The goal:
> All objects derived from IContentItem should use the edit.html registered for
> IContentItem unless they want to provide their own view. (all request are for
> the ICentershockSkin)
> The problem:
> This works fine when I call the edit view on a IContentFolder, which has no
> edit view registered on the default layer.
> However is does not work for the ILink, the edit view defined by IContentItem
> on the ICentershockSkin is never called.
You have two pages, they are registered as multiadapters:
* (ILink, IDefaultBrowserLayer), name='edit.html'
* (IContentItem, ICenterShockSkin), name='edit.html'
Now, when looking up the page for the combination of (ILink,
ICenterShockSkin) objects, the adapter machinery will find that there is
no exact match. The best match it finds is that the *first* object
matches ILink, even though the second object doesn't match exactly.
That's still the "better" solution than matching the second object
better than the first one.
> The solution
> 1) Rename edit.html to something else to avoid this name clash
> 2) Do not derive ICentershockSkin from Rotterdam instead only from Interface.
> That caused TraversalErrors here.
I don't think it has to do with deriving ICenterShockSkin from anything
else. You'll always have the problem with the first object taking the
precedence when mathcing interfaces.
I would rather suggestion you make a new skin for ZMI views and register
all your non-centershock views for that one, instead of just for the
By the way, layer interfaces are *NOT* derived from Interface. They are
derived from at least IBrowserRequest, though it is recommended to
derive them from IDefaultBrowserLayer. Otherwise you won't get a single
view in your skin that is registered for the default layer.
> 3) ???
> Is this intended behavior? (that Skin inheritance is over Interface
> intheritance) or is the behavior undefined?
As said, these are standard multiadapter lookups. When there's no exact
match, the first object is matched best, then the second, then the
Zope3-users mailing list