Is there any simple way in zope component system to list all views (and their names), which were registered for specific interface (eg IMyInterface):
<browser:page
name="content-item-plain"
for=".interfaces.IMyInterface"
class=".content_item.MyView"
permission="zope2.View"
layer="my.model.browser.interfaces.IMyModelLayer"
template="templates/content_item_plain.pt"
/>
class MyView(BrowserView):
implements(ISomeInterface)
Or, even better, those, which implement certain interface (ISomeInterface)?
The result should be list/tuple of classes (MyView, MyView1, …) and/or names (“content-item-plain”, …).
There is no problem to add classImplements/classProvides to the MyView class, if it helps.
Many things tried so far. The nearest is this:
from zope.component import getGlobalSiteManager
gsm = getGlobalSiteManager()
gsm.adapters.lookupAll((IMyInterface, IMyModelLayer), provided=Interface))
but it gives too many results and changing provided to something more specific makes it return empty tuple.
With results it should be possible to lookup view class attributes.
Yes.
Get the list:
http://docs.plone.org/develop/plone/views/browserviews.html#listing-available-views
And filter it out in a way you wish.