[Zope3-dev] should the view lookup machinery call getAdapter?

R. David Murray bitz@bitdance.com
Fri, 29 Mar 2002 20:01:47 -0500 (EST)


This may all be a result of my misunderstanding how things
currently work, but:

I noticed on the checkins list that Casey did the following:

> <browser:view name="RolePermissionsManagement"
>               for="Zope.App.OFS.Memento.IAttributeMementoStorable."
>               factory="Zope.App.Security.RolePermissionView." />

It seems to me that the goal would be that this view would work for
any object that supports the IMementoBag interface.  If I understand
correctly, you would currently accomplish this by removing the 'for'
attribute entirely, and having the view do a getAdapter on the
content object to get the IMementoBag.  Of course, it would have
to handle the case of there being no adapter available.

It seems to me that a case could be made that when the view machinery
is looking for a view for an object and comes up empty, it could
try calling getAdapter for the view's registered interface.  If it
got None, it would behave as it does now, otherwise it would call
the view with the adapted object.

I talked with Stephen Richter about this, and we came up with two
main concerns: (1) the traversal code needs to stay as lean as
possible and (2) this might be too magical.

Unless I'm missing something I think (1) is not much of an issue,
since this getAdapter would be done only at a point where the
traversal would otherwise fail.  As for (2), it seems like a universal
view that does a getAdapter would be just as magical, and the fact
that only *some* views did this (and you couldn't tell from looking
at the config file which universal views were looking for which
interfaces) might actually be more magical.

Thoughts?

--RDM