How can I programmatically get the registration information of a view?

How can I programmatically get the registration information of a view?

In my example (see below) I get the overview-controlpanel view from into my obj variable.

From it I can get the name, the configure.zcml file and the position of the declaration in it ( and

I assume that obj.required gives me a tuple with the for attribute in its first element. Is this right?

But how can I get the class and the permission?

obj.factory gives a hint to Products.Five.browser.metaconfigure.OverviewControlPanel but not to Products.CMFPlone.controlpanel.browser.overview.OverviewControlPanel as defined in configure.zcml.

>>> from import registration
>>> from zope.publisher.interfaces.browser import IBrowserRequest
>>> import pprint

>>> obj = [view
...           for view
...           in registration.getViews(IBrowserRequest)
...           if in ['overview-controlpanel']
...           ][0]

>>> with open(, 'r') as f:
...     zcml_string = f.readlines()[]
>>> zcml_string
>>> obj.required
(<InterfaceClass plone.base.interfaces.siteroot.IPloneSiteRoot>,
    <InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>),
>>> obj.factory
<class 'Products.Five.browser.metaconfigure.OverviewControlPanel'>

Check obj.factory.__bases__ or obj.factory.__mro__ (when you customize a view using, it generates a subclass of the original view class).

The permissions end up on the view class's __ac_permissions__ attribute, if I recall correctly.

neither obj.__mro__ nor obj.__bases__ give me Products.CMFPlone.controlpanel.browser.overview.OverviewControlPanel :

>>> obj.factory.__mro__
(<class 'Products.Five.browser.metaconfigure.SiteControlPanel'>,
 <class ''>,
 <class ''>,
 <class 'plone.z3cform.layout.FormWrapper'>,
 <class 'Products.Five.browser.BrowserView'>,
 <class 'Products.Five.browser.metaconfigure.simple'>,
 <class 'zope.browserpage.metaconfigure.simple'>,
 <class 'zope.publisher.browser.BrowserView'>,
 <class 'zope.location.location.Location'>,
 <class 'object'>)

>>> obj.factory.__bases__
(<class ''>,
 <class 'Products.Five.browser.metaconfigure.simple'>)

Are you sure you're looking at the same one as before? This looks like the site control panel rather than the overview.

Sorry. You're right I was looking at another view. The __mro__ was the right hint. Thank you!

>>> zcml_string
['  <browser:page\n',
 '      name="overview-controlpanel"\n',
 '      for="plone.base.interfaces.IPloneSiteRoot"\n',
 '      class=".overview.OverviewControlPanel"\n',
 '      permission=""\n',
 '      />\n']


>>> obj.factory.__mro__[1]
<class 'Products.CMFPlone.controlpanel.browser.overview.OverviewControlPanel'>

>>> obj.factory.__mro__[0].__ac_permissions__
(('Plone Site Setup: Overview', ('', '__call__')),)

... but how do I get the for element?

obj.required[0] gives me plone.base.interfaces.siteroot.IPloneSiteRoot (note siteroot) but in configure.zcml the for element is plone.base.interfaces.IPloneSiteRoot (without siteroot)

>>> obj.required
(<InterfaceClass plone.base.interfaces.siteroot.IPloneSiteRoot>,
    <InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>)

and last but not least: where do I get the class from (('Plone Site Setup: Overview', ('', '__call__')),)?

plone.base.interfaces.siteroot.IPloneSiteRoot and plone.base.interfaces.IPloneSiteRoot are the same object. plone.base.interface's imports the interface from plone.base/ at main · plone/plone.base · GitHub is the zope 3 permission name and Plone Site Setup: Overview is the zope 2 permission name. I don't recall how to convert from one to the other.

The file ./Products/CMFPlone/controlpanel/permissions.zcml has title and id of the declared permission (see below).

Any hint where in code this file is loaded and what happens with it?

Somewhere must title and id be related to each other and maybe able to be queried ???

  <permission id=""
              title="Plone Site Setup: Overview">
    <role name="Manager"/>
    <role name="Site Administrator"/>

Both app.get_permissions() and AccessControl.Permission.getPermissions() give me tuples with the titles of the permissions but not the ids.