[Grok-dev] MultiAdapter doc bug?

Tim Terlegård tim.terlegard at valentinewebsystems.se
Tue Jun 24 01:56:34 EDT 2008


On Jun 24, 2008, at 5:22 AM, Graham Stratton wrote:

> The documentation in http://svn.zope.org/grok/tags/0.13/doc/reference/components.rst 
>  implies that you can get a multiadapter like this:
>
> >>> home = IHome(cave, fireplace)
>
> I'm pretty sure this doesn't work. It certainly isn't how we do the  
> lookup in our tests:

The second arument is like the second argument in dictx.get(...), it  
specifies
what the adaption should return if it can't find any matches during  
lookup. So
you can say IHome(cave, None) if you want to return None instead of  
getting
a component lookup error.

This however should work:

     >>> home = IHome((cave, fireplace))


> To be honest I don't understand why you wouldn't want to specify the  
> interface you're adapting to.

Well, you do specify the interface, that's why you write IHome(...).

/Tim


More information about the Grok-dev mailing list