[Zope-dev] adapting to None

Chris Withers chris at simplistix.co.uk
Sat Dec 13 05:18:27 EST 2008


Dieter Maurer wrote:
> 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?

That's exactly what returning None indicates...

>> 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 

...indeed, however, I really do want to return None here.

cheers,

Chris

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


More information about the Zope-Dev mailing list