[Interface-dev] Proposal: define meaning of None return from an
adapter factory
Jim Fulton
jim at zope.com
Fri Sep 3 07:30:19 EDT 2004
Currently, an adapter factory can return None. This usually makes it
look as if an adapter is not defined. For example, it would make
a call like IFoo(ob) raise a TypeError. However, if you did IFoo(ob, 42)
and an adapter factory was found and returned None, then IFoo(ob, 42)
would return None, not 42.
I'd like to change the adapter-registry API so that a None return
from an adapter factory is defined to mean that there is no adapter.
This allows:
- preventing adaptation, when desired
- an adapter factory to determine whether adaptation is
possible based on the state of the object being adapted.
This change would primarily cause a change to the documentation
and tests. There would be a minor change to the querying APIs to
return a passed default value if an factory returns None.
Any objections?
Jim
--
Jim Fulton mailto:jim at zope.com Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
More information about the Interface-dev
mailing list