[Checkins]
SVN: zope.introspector/trunk/src/zope/introspector/registry.
added some more tests to registry.
Martin Lundwall
martin at webworks.se
Sun Jun 22 16:21:51 EDT 2008
Log message for revision 87654:
added some more tests to registry.
Changed:
U zope.introspector/trunk/src/zope/introspector/registry.py
U zope.introspector/trunk/src/zope/introspector/registry.txt
-=-
Modified: zope.introspector/trunk/src/zope/introspector/registry.py
===================================================================
--- zope.introspector/trunk/src/zope/introspector/registry.py 2008-06-22 17:10:23 UTC (rev 87653)
+++ zope.introspector/trunk/src/zope/introspector/registry.py 2008-06-22 20:21:50 UTC (rev 87654)
@@ -75,9 +75,8 @@
for eachRegistration in self.getAllRegistrations():
reg = IRegistrySearch(eachRegistration)
interfacePaths = reg.getInterfaces()
- import pprint;
- #pprint.pprint(interfacePaths)
+
for eachInterface in interfacePaths:
registrations = self._dicter(registrations,
eachInterface.split('.'),
Modified: zope.introspector/trunk/src/zope/introspector/registry.txt
===================================================================
--- zope.introspector/trunk/src/zope/introspector/registry.txt 2008-06-22 17:10:23 UTC (rev 87653)
+++ zope.introspector/trunk/src/zope/introspector/registry.txt 2008-06-22 20:21:50 UTC (rev 87654)
@@ -3,9 +3,64 @@
:Test-Layer: functional
-We provide a utility that implements ``IRegistryInfo``::
+zope.interface provides the ``RegistryInfoUtility`` to search for and list all registered Utilities,
+Adapters, Handlers and SubscriptionAdapters. To list all registered Utilities::
>>> from zope.introspector.interfaces import IRegistryInfo
>>> from zope.component import getUtility
- >>> getUtility(IRegistryInfo)
- <zope.introspector.registry.RegistryInfoUtility object at 0x...>
+ >>> registryUtil = getUtility(IRegistryInfo)
+ >>> registryUtil.getAllUtilities()
+ [UtilityRegistration...]
+
+The same thing can be done for Adapters::
+
+ >>> registryUtil.getAllAdapters()
+ [AdapterRegistration...]
+
+For Handlers::
+
+ >>> registryUtil.getAllHandlers()
+ [HandlerRegistration...]
+
+And for SubscriptionAdapters::
+
+ >>> registryUtil.getAllSubscriptionAdapters()
+ [...]
+
+So far this has been empty.
+Or you can get all registrations::
+
+ >>> registryUtil.getAllRegistrations()
+ [AdapterRegistration...]
+
+However if you are looking for something special you can do a search in the registry to see if it registered.
+So first we will create a Dummy utility so we have something to find when we search::
+
+ >>> from zope.interface import Interface, implements
+ >>> from zope.component import provideUtility
+ >>> class IDummy(Interface):
+ ... pass
+ >>> class Dummy(object):
+ ... implements(IDummy)
+
+Now provide the Utility globaly::
+
+ >>> provideUtility(Dummy, IDummy)
+
+And use the RegistryInfoUtility to search for it::
+
+ >>> registryUtil.getRegistrationsForInterface("Dummy")
+ [UtilityRegistration(<BaseGlobalComponents base>, IDummy, u'', Dummy, u'')...]
+
+Depending on what type of Registration that is searched different things are examined.
+Utilites you can search for either name of utility or provided interface.
+Adapters you can search for name, provided interfaces, factory or required interfaces.
+Handlers you can search for name, factory, or required interfaces.
+
+There is also a way to get all registrations in a dictionary ordered by package name.
+
+ >>> registryUtil.getAllInterfaces()
+ {...: {...: {...: {...: [...Registration...]}...}...}...}
+
+This is mainly useful for browsing the complete component registry if you are not
+really sure what you are looking for.
\ No newline at end of file
More information about the Checkins
mailing list