Marius Gedminas wrote:
Now when you try to adapt anything to ITest, zope.component will call
your ``adapter`` function and then check the return value.  A return
value of None means "the adapter is not available", and results in a
TypeError you see here:

Yes, apologies, both you and Philipp are correct, I was trying to show a simple version of a problem and oversimplified.

Here's what I really meant:

>>> from zope.component import provideAdapter
>>> from zope.interface import Interface
>>> from zope.component import getMultiAdapter
>>> class ITest(Interface): pass
...
>>> def adapter(*args): return args
...

>>> provideAdapter(adapter,adapts=(None,),provides=ITest)
>>> ITest(1)
(1,)

Yay, as expected...

>>> getMultiAdapter((1,),ITest)
(1,)

Good, still works...

>>> provideAdapter(adapter,adapts=(None,None),provides=ITest)
>>> getMultiAdapter((1,1),ITest)
Traceback (most recent call last):
...
zope.component.interfaces.ComponentLookupError:
 ((1, 1), <InterfaceClass __main__.ITest>, u'')

Oh dear, what have I done wrong here?

cheers,

Chris

--
Simplistix - Content Management, Zope & Python Consulting
           - http://www.simplistix.co.uk

_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to