[Grok-dev] Re: Getting a view from within a REST layer
janwijbrand at gmail.com
Mon Dec 10 15:20:49 EST 2007
Peter Bengtsson wrote:
> getMultiAdapter((context, request), name="Nameofview")
> doesn't work inside my REST layer which I built thanks to this tutorial:
> This is the error I get:
> raise ComponentLookupError(objects, interface, name)
> ComponentLookupError: ((<snapatom.app.snapatom object at 0x8b7f6ac>,
> <InterfaceClass zope.interface.Interface>), <InterfaceClass
> zope.interface.Interface>, 'bloglist')
> Am I doing it completely wrong or is it a bug?
> I basically want to render a view and spit out its result in the method
> GET() of my REST layer.
The thing I do not really understand about the error message you get is,
that getMultiAdapter() is looking for a component adapting the
combination of <snapatom.app.snapatom> and <zope.interface.Interface>...
somehow the request object you obtain seems not to provide any useful
interface for the lookup.
A wild guess, but what happens if you do:
from zope.interface import alsoProvides
# ugly hack to test the lookup
view = getMultiAdapter((context, request), name="bloglist")
Mind though, even if this does work, it is basically "lying" to the
component system - I would have guessed too that the request object you
get in the REST context could be used for view lookups. But the REST
stuff is a bit misty to me...
More information about the Grok-dev