[Zope3-Users] Re: "dumping" a component registry
Stephan Richter
srichter at cosmos.phy.tufts.edu
Sat Sep 15 21:20:18 EDT 2007
On Saturday 15 September 2007 19:04, Philipp von Weitershausen wrote:
> >>> from zope.component import getSiteManager
> >>> reg = getSiteManager()
> >>> from pprint import pprint
> >>> for info in reg.registeredAdapters():
> ... pprint((info.required, info.provided, info.factory, info.name))
> ...
>
> This will probably drown you with information, though. One step would be
> to constrain the output only to browser views, in other words, 2-way
> multi-adapters whose second required interface is or extends
> IBrowserRequest:
>
> >>> from zope.publisher.interfaces.browser import IBrowserRequest
> >>> for info in reg.registeredAdapters():
> ... if (len(info.required) == 2 and
> ... info.required[1].isOrExtends(IBrowserRequest)):
> ... pprint((info.required, info.provided, info.factory,
> ... info.name))
> ...
>
> For better findability, you might want to search by name now. This is
> left up to the skilled reader as an exercise ;)
For more specific searches on global site managers, you can use the apidoc
apis. They implement a lot of the searches that are commonly interesting:
>>> from zope.app.apidoc import presentation
>>> for reg in presentation.getViews(IFolder):
... print reg.required, reg.provided, reg.factory, reg.name
There are a lot more helpful functions there and they are all well-documented.
Regards,
Stephan
--
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
More information about the Zope3-users
mailing list