======================== Object Introspector View ======================== The "Introspector" view provides access to information about the current obejct, the context of the introspector view. When in `devmode`, the introspector is simply available as follows: >>> from zope.testbrowser.testing import Browser >>> browser = Browser() >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw') >>> browser.handleErrors = False >>> browser.open('http://localhost/manage') >>> browser.getLink('Introspector').click() The page starts with telling you the class/type >>> browser.getLink('zope.app.folder.folder.Folder').url 'http://localhost/++apidoc++/Code/zope/app/folder/folder/Folder/index.html' and the name of the object: >>> '<no name>' in browser.contents True Of course, the root folder does not have a name. As you can see the type links directly to the API documentation of the class. The next section lists all directly provided interfaces. The root folder directly provides the ``ISite`` and ``IRootFolder`` interface, so we should see those: >>> browser.getLink('zope.app.component.interfaces.ISite').url '.../++apidoc++/Interface/zope.app.component.interfaces.ISite/index.html' >>> browser.getLink('zope.app.folder.interfaces.IRootFolder').url '...apidoc++/Interface/zope.app.folder.interfaces.IRootFolder/index.html' The next two section, the implemented interfaces and the base classes, are not instance specific pieces of information, but they are still nice to see at this point. For example, a ``Folder`` instance provides the following interfaces: >>> browser.getLink('zope.app.folder.interfaces.IFolder').url '.../++apidoc++/Interface/zope.app.folder.interfaces.IFolder/index.html' >>> browser.getLink('persistent.interfaces.IPersistent').url '.../++apidoc++/Interface/persistent.interfaces.IPersistent/index.html' >>> browser.getLink('zope.app.component.interfaces.IPossibleSite').url '.../Interface/zope.app.component.interfaces.IPossibleSite/index.html' >>> browser.getLink('zope.app.container.interfaces.IContained').url '...doc++/Interface/zope.app.container.interfaces.IContained/index.html' The base classes of the ``Folder`` are as follows: >>> browser.getLink('persistent.Persistent').url 'http://localhost/++apidoc++/Code/persistent/Persistent/index.html' >>> browser.getLink('zope.app.component.site.SiteManagerContainer').url '...apidoc++/Code/zope/app/component/site/SiteManagerContainer/index.html' >>> browser.getLink('zope.app.container.contained.Contained').url '.../++apidoc++/Code/zope/app/container/contained/Contained/index.html' Now that we described the component and class level of the object, the view dives into some details. First it lists the attributes/properties of the object, including the value of the attribute. This is information can be very useful when debugging an application. The only attribute of the folder is the data attribute: >>> print browser.contents Attributes/Properties
... There are, however, several methods since the full mapping interface is implemented. Like for the class method documentation, the method's signature, doc string, permissions and the interface the method is declared in. Here an example: >>> print browser.contents Methods
... Towards the bottom of the page, there are some optional sections. Some objects, for example our root folder, are inheritely mappings or sequences. Their data then is often hard to see in the attributes section, so they are provided in a aseparate section. To see anything useful, we have to add an object to the folder first: >>> import re >>> browser.getLink(re.compile('^File$')).click() >>> import cStringIO >>> browser.getControl('Data').value = cStringIO.StringIO('content') >>> browser.getControl(name='add_input_name').value = 'file.txt' >>> browser.getControl('Add').click() >>> browser.getLink('Introspector').click() Now the introspector will show the file and allow you to click on it: >>> print browser.contents Mapping Items
... The final section of the introspector displays the annotations that are declared for the object. The standard annotation that almost every object provides is the Dublin Core: >>> print browser.contents Annotations
... As you can see you can click on the annotation to discover it further: >>> browser.getLink('annotatableadapter.ZDCAnnotationData').click() >>> print browser.contents Attributes/Properties
... That's it! The introspector view has a lot more potential, but that's for someone else to do.