[Zope3-checkins]
SVN: Zope3/branches/jim-adapter/src/zope/app/apidoc/
Updated to reflect new registration reprs and constructors.
Jim Fulton
jim at zope.com
Sun Apr 2 12:59:26 EDT 2006
Log message for revision 66304:
Updated to reflect new registration reprs and constructors.
Changed:
U Zope3/branches/jim-adapter/src/zope/app/apidoc/component.txt
U Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.txt
-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/apidoc/component.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/apidoc/component.txt 2006-04-02 16:59:23 UTC (rev 66303)
+++ Zope3/branches/jim-adapter/src/zope/app/apidoc/component.txt 2006-04-02 16:59:25 UTC (rev 66304)
@@ -44,10 +44,16 @@
>>> regs = list(component.getRequiredAdapters(IFoo))
>>> regs.sort()
>>> regs
- [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''),
- AdapterRegistration(('IFoo',), 'IResult', '', None, ''),
- HandlerRegistration(('IFoo',), u'', 'stubFactory', '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBar], ISpecialResult, '', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo], IResult, '', None, u''),
+ HandlerRegistration(<BaseGlobalComponents base>,
+ [IFoo], u'', 'stubFactory', u'')]
+
+
+
Note how the adapter requiring an `IRequest` at the end of the required
interfaces is neglected. This is because it is recognized as a view and views
are not returned by default. But you can simply turn this flag on:
@@ -55,27 +61,37 @@
>>> regs = list(component.getRequiredAdapters(IFoo, withViews=True))
>>> regs.sort()
>>> regs
- [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''),
- AdapterRegistration(('IFoo', 'IRequest'), 'ISpecialResult', '', None, ''),
- AdapterRegistration(('IFoo',), 'IResult', '', None, ''),
- HandlerRegistration(('IFoo',), u'', 'stubFactory', '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBar], ISpecialResult, '', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IRequest], ISpecialResult, '', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo], IResult, '', None, u''),
+ HandlerRegistration(<BaseGlobalComponents base>,
+ [IFoo], u'', 'stubFactory', u'')]
+
+
The function will also pick up registrations that have required interfaces the
specified interface extends:
>>> regs = list(component.getRequiredAdapters(IFoo))
>>> regs.sort()
>>> regs
- [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''),
- AdapterRegistration(('IFoo',), 'IResult', '', None, ''),
- HandlerRegistration(('IFoo',), u'', 'stubFactory', '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBar], ISpecialResult, '', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo], IResult, '', None, u''),
+ HandlerRegistration(<BaseGlobalComponents base>,
+ [IFoo], u'', 'stubFactory', u'')]
And all of the required interfaces are considered, of course:
>>> regs = list(component.getRequiredAdapters(IBar))
>>> regs.sort()
>>> regs
- [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBar], ISpecialResult, '', None, u'')]
`getProvidedAdapters(iface, withViews=False)`
@@ -88,24 +104,30 @@
>>> regs = list(component.getProvidedAdapters(ISpecialResult))
>>> regs.sort()
>>> regs
- [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBar], ISpecialResult, '', None, u'')]
And by specifying the `withView` flag, we get views as well:
>>> regs = list(component.getProvidedAdapters(ISpecialResult, withViews=True))
>>> regs.sort()
>>> regs
- [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''),
- AdapterRegistration(('IFoo', 'IRequest'), 'ISpecialResult', '', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBar], ISpecialResult, '', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IRequest], ISpecialResult, '', None, u'')]
We can of course also ask for adapters specifying `IResult`:
>>> regs = list(component.getProvidedAdapters(IResult, withViews=True))
>>> regs.sort()
>>> regs
- [AdapterRegistration(('IFoo', 'IBar'), 'ISpecialResult', '', None, ''),
- AdapterRegistration(('IFoo', 'IRequest'), 'ISpecialResult', '', None, ''),
- AdapterRegistration(('IFoo',), 'IResult', '', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBar], ISpecialResult, '', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IRequest], ISpecialResult, '', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo], IResult, '', None, u'')]
`getClasses(iface)`
@@ -167,16 +189,17 @@
>>> regs = list(component.getFactories(IFooBar))
>>> regs.sort()
>>> regs
- [UtilityRegistration('IFactory', 'MyFooBar',
- <Factory for <class 'zope.app.apidoc.doctest.MyFooBar'>>, '')]
+ [UtilityRegistration(<BaseGlobalComponents base>,
+ IFactory, 'MyFooBar',
+ <Factory for <class 'zope.app.apidoc.doctest.MyFooBar'>>, u'')]
>>> regs = list(component.getFactories(IFoo))
>>> regs.sort()
>>> regs
- [UtilityRegistration('IFactory', 'MyFoo',
- <Factory for <class 'zope.app.apidoc.doctest.MyFoo'>>, ''),
- UtilityRegistration('IFactory', 'MyFooBar',
- <Factory for <class 'zope.app.apidoc.doctest.MyFooBar'>>, '')]
+ [UtilityRegistration(<BaseGlobalComponents base>, IFactory, 'MyFoo',
+ <Factory for <class 'zope.app.apidoc.doctest.MyFoo'>>, u''),
+ UtilityRegistration(<BaseGlobalComponents base>, IFactory, 'MyFooBar',
+ <Factory for <class 'zope.app.apidoc.doctest.MyFooBar'>>, u'')]
`getUtilities(iface)`
@@ -196,16 +219,16 @@
>>> regs = list(component.getUtilities(IFooBar))
>>> regs.sort()
>>> regs #doctest:+ELLIPSIS
- [UtilityRegistration('IFooBar', '',
- <zope.app.apidoc.doctest.MyFooBar object at ...>, '')]
+ [UtilityRegistration(<BaseGlobalComponents base>, IFooBar, '',
+ <zope.app.apidoc.doctest.MyFooBar object at ...>, u'')]
>>> regs = list(component.getUtilities(IFoo))
>>> regs.sort()
>>> regs #doctest:+ELLIPSIS
- [UtilityRegistration('IFoo', '',
- <zope.app.apidoc.doctest.MyFoo object at ...>, ''),
- UtilityRegistration('IFooBar', '',
- <zope.app.apidoc.doctest.MyFooBar object at ...>, '')]
+ [UtilityRegistration(<BaseGlobalComponents base>, IFoo, '',
+ <zope.app.apidoc.doctest.MyFoo object at ...>, u''),
+ UtilityRegistration(<BaseGlobalComponents base>, IFooBar, '',
+ <zope.app.apidoc.doctest.MyFooBar object at ...>, u'')]
`getRealFactory(factory)`
@@ -305,7 +328,7 @@
... implements(IResult)
>>> from zope.component.registry import AdapterRegistration
- >>> reg = AdapterRegistration((IFoo, IBar), IResult, 'FooToResult',
+ >>> reg = AdapterRegistration(None, (IFoo, IBar), IResult, 'FooToResult',
... MyResult, 'doc info')
And now get the info dictionary:
@@ -328,7 +351,7 @@
>>> from zope.interface import classImplements
>>> classImplements(MyResultType, IResult)
- >>> reg = AdapterRegistration((IFoo, IBar), IResult, 'FooToResult',
+ >>> reg = AdapterRegistration(None, (IFoo, IBar), IResult, 'FooToResult',
... MyResultType, 'doc info')
>>> pprint(component.getAdapterInfoDictionary(reg))
{'doc': 'doc info',
@@ -345,7 +368,7 @@
see how the function handles subscriptions:
>>> from zope.component.registry import HandlerRegistration
- >>> reg = HandlerRegistration((IFoo, IBar), '', MyResult, 'doc info')
+ >>> reg = HandlerRegistration(None, (IFoo, IBar), '', MyResult, 'doc info')
>>> pprint(component.getAdapterInfoDictionary(reg))
{'doc': 'doc info',
Modified: Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.txt 2006-04-02 16:59:23 UTC (rev 66303)
+++ Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.txt 2006-04-02 16:59:25 UTC (rev 66304)
@@ -266,18 +266,18 @@
>>> regs = list(presentation.getViews(IFoo))
>>> regs.sort()
>>> regs #doctest:+ELLIPSIS
- [AdapterRegistration(('IFoo', 'IBrowserRequest'), 'Interface',
- 'blah', None, ''),
- AdapterRegistration(('IFoo', 'IHTTPRequest'), 'Interface',
- 'foo', None, ''),
- AdapterRegistration(('Interface', 'IHTTPRequest'), 'Interface',
- 'bar', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IBrowserRequest], Interface, 'blah', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFoo, IHTTPRequest], Interface, 'foo', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [Interface, IHTTPRequest], Interface, 'bar', None, u'')]
>>> regs = list(presentation.getViews(Interface, IHTTPRequest))
>>> regs.sort()
>>> regs #doctest:+ELLIPSIS
- [AdapterRegistration(('Interface', 'IHTTPRequest'), 'Interface',
- 'bar', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [Interface, IHTTPRequest], Interface, 'bar', None, u'')]
`filterViewRegistrations(regs, iface, level=SPECIFC_INTERFACE_LEVEL)`
@@ -329,24 +329,24 @@
... regs, IFile, level=presentation.SPECIFIC_INTERFACE_LEVEL))
>>> result.sort()
>>> result
- [AdapterRegistration(('IFile', 'IHTTPRequest'), 'Interface',
- 'view.html', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFile, IHTTPRequest], Interface, 'view.html', None, u'')]
>>> result = list(presentation.filterViewRegistrations(
... regs, IFile, level=presentation.EXTENDED_INTERFACE_LEVEL))
>>> result.sort()
>>> result
- [AdapterRegistration(('IContent', 'IHTTPRequest'), 'Interface', 'edit.html',
- None, ''),
- AdapterRegistration(('IContent', 'IHTTPRequest'), 'Interface', 'view.html',
- None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IContent, IHTTPRequest], Interface, 'edit.html', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IContent, IHTTPRequest], Interface, 'view.html', None, u'')]
>>> result = list(presentation.filterViewRegistrations(
... regs, IFile, level=presentation.GENERIC_INTERFACE_LEVEL))
>>> result.sort()
>>> result
- [AdapterRegistration(('Interface', 'IHTTPRequest'), 'Interface', 'view.html',
- None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [Interface, IHTTPRequest], Interface, 'view.html', None, u'')]
You can also specify multiple levels at once using the Boolean OR operator,
since all three levels are mutually exclusive.
@@ -356,22 +356,22 @@
... presentation.EXTENDED_INTERFACE_LEVEL))
>>> result.sort()
>>> result
- [AdapterRegistration(('IContent', 'IHTTPRequest'), 'Interface',
- 'edit.html', None, ''),
- AdapterRegistration(('IContent', 'IHTTPRequest'), 'Interface',
- 'view.html', None, ''),
- AdapterRegistration(('IFile', 'IHTTPRequest'), 'Interface',
- 'view.html', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IContent, IHTTPRequest], Interface, 'edit.html', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IContent, IHTTPRequest], Interface, 'view.html', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [IFile, IHTTPRequest], Interface, 'view.html', None, u'')]
>>> result = list(presentation.filterViewRegistrations(
... regs, IFile, level=presentation.SPECIFIC_INTERFACE_LEVEL |
... presentation.GENERIC_INTERFACE_LEVEL))
>>> result.sort()
>>> result
- [AdapterRegistration(('IFile', 'IHTTPRequest'), 'Interface',
- 'view.html', None, ''),
- AdapterRegistration(('Interface', 'IHTTPRequest'), 'Interface',
- 'view.html', None, '')]
+ [AdapterRegistration(<BaseGlobalComponents base>,
+ [IFile, IHTTPRequest], Interface, 'view.html', None, u''),
+ AdapterRegistration(<BaseGlobalComponents base>,
+ [Interface, IHTTPRequest], Interface, 'view.html', None, u'')]
`getViewInfoDictionary(reg)`
@@ -385,7 +385,7 @@
Let's first create a registration:
>>> from zope.component.registry import AdapterRegistration
- >>> reg = AdapterRegistration((IFile, Interface, IHTTPRequest),
+ >>> reg = AdapterRegistration(None, (IFile, Interface, IHTTPRequest),
... Interface, 'view.html', Factory, 'reg info')
>>> pprint(presentation.getViewInfoDictionary(reg))
More information about the Zope3-Checkins
mailing list