[Zope-dev] adapting to None
Dieter Maurer
dieter at handshake.de
Sat Dec 13 05:17:59 EST 2008
Chris Withers wrote at 2008-12-13 02:17 +0000:
>I have a need to be able to adapting certain objects to None, eg:
>
>def some_adapter(obj):
> if something:
> return None
> return somethingelse
Your use case seems to abuse adaptation:
Adaptation to an interface must always return an object which provides
the interface.
"None", by default, only provides very few interfaces (not sure
whether you can extend this set with 'alsoProvides').
I think that in some cases, it would be useful for an adapter factory
to say 'I cannot handle this case' and then the adapter lookup
is continued. Maybe, this is already supported?
Then, maybe, you can use it?
--
Dieter
More information about the Zope-Dev
mailing list