[Zope-dev] adapting to None
Chris Withers
chris at simplistix.co.uk
Sat Dec 13 05:42:09 EST 2008
Dieter Maurer wrote:
> Then, use something different from adaptation (as adaptation does
> not fit your wishes).
This is what I'm trying to do with subclassing, and my question was why
that subclassing wasn't working...
> I expect that your adapter factory can raise "ComponentLookupError"
> when it cannot handle the adaptation and then the "default" argument
> of the adapter lookup will take effect.
>
> adapter = IMyInterface(obj, None)
...which might work, except I'd want that None to be the default and
with no need to specify it.
The pythonic way to do this would be to make IMyInterface a subclass of
Interface (which it is) and tweak the implementation of whatever
implements IMyInterface(...), which is exactly what I'm trying to do.
From looking at the python implementation of Interface, __call__ is
indicated to be the method to override, but with the C-based Interface,
this has no effect. Why is that?
*That's* what I'm looking for help with, not judgement on whether
adapting to None is a good idea or not ;-)
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the Zope-Dev
mailing list