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)

Yay, as expected...

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

Good, still works...

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

Oh dear, what have I done wrong here?



Simplistix - Content Management, Zope & Python Consulting

Zope3-dev mailing list

Reply via email to