[Zope3-checkins]
SVN: Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.
Revert r65753. It broke other tests and I don't think I'm
gonna need this anyways.
Philipp von Weitershausen
philikon at philikon.de
Thu Mar 2 21:26:43 EST 2006
Log message for revision 65763:
Revert r65753. It broke other tests and I don't think I'm gonna need this anyways.
Changed:
U Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.py
U Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.txt
-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.py 2006-03-03 02:26:25 UTC (rev 65762)
+++ Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.py 2006-03-03 02:26:42 UTC (rev 65763)
@@ -118,10 +118,10 @@
return iface
-def getViews(iface, type=IRequest, context=None):
+def getViews(iface, type=IRequest):
"""Get all view registrations for a particular interface."""
- sm = zapi.getSiteManager(context)
- for reg in sm.registrations():
+ gsm = zapi.getGlobalSiteManager()
+ for reg in gsm.registrations():
if (isinstance(reg, AdapterRegistration) and
len(reg.required) > 0 and
reg.required[-1] is not None and
Modified: Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.txt 2006-03-03 02:26:25 UTC (rev 65762)
+++ Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.txt 2006-03-03 02:26:42 UTC (rev 65763)
@@ -240,8 +240,8 @@
presentation type to be an `IBrowserRequest`.
-`getViews(iface, type=IRequest, context=None)`
-----------------------------------------------
+`getViews(iface, type=IRequest)`
+--------------------------------
This function retrieves all available view registrations for a given interface
and presentation type. The default argument for the presentation type is
@@ -279,43 +279,10 @@
[AdapterRegistration(('Interface', 'IHTTPRequest'), 'Interface',
'bar', None, '')]
-We can also pass a ``context`` parameter to get registration objects
-from a local site manager. First we create a fake context object:
- >>> class MyContext(object):
- ... pass
- >>> context = MyContext()
+`filterViewRegistrations(regs, iface, level=SPECIFC_INTERFACE_LEVEL)`
+---------------------------------------------------------------------
-Now we create a local component registration (a.k.a. site manager) and
-register an adapter that finds it:
-
- >>> import zope.interface
- >>> import zope.component.globalregistry
- >>> import zope.component.interfaces
- >>> sm = zope.component.globalregistry.BaseGlobalComponents()
-
- >>> @zope.component.adapter(MyContext)
- ... @zope.interface.implementer(zope.component.interfaces.IComponentLookup)
- ... def contextToComponentLookup(context):
- ... return sm
- >>> zope.component.provideAdapter(contextToComponentLookup)
-
-Now we register a local view and see that ``getViews()`` with the
-appropriate context gives us an according AdapterRegistration:
-
- >>> class LocalView(object):
- ... pass
- >>> sm.registerAdapter(LocalView, (Interface, IBrowserRequest),
- ... Interface, name=u'localview.html')
-
- >>> list(presentation.getViews(Interface, IBrowserRequest, context))
- [AdapterRegistration(('Interface', 'IBrowserRequest'), 'Interface',
- u'localview.html', 'LocalView', u'')]
-
-
-`filterViewRegistrations(regs, iface, level=SPECIFIC_INTERFACE_LEVEL)`
-----------------------------------------------------------------------
-
Oftentimes the amount of views that are being returned for a particular
interface are too much to show at once. It is then good to split the view into
categories. The `filterViewRegistrations()` function allows you to filter the
More information about the Zope3-Checkins
mailing list