Alec Mitchell wrote:
>> class IFieldType(Interface):
>> def __call__(self,*args,**kw):
>> r = Interface.__call__(*args,**kw)
>> if r is empty:
>> return None
>> return r
>> I suspect this would work with the python implementation of Interface,
>> but it certainly doesn't with the C implementation.
>> What am I doing wrong and how can I achieve what I'm after?
> If the result of an adaptation is None, it means something very specific to
> the CA.
Indeed, which is why I'm trying to subclass this interface so that its
subclasses behave slightyl differently...
> That TypeError is specifically a 'Could not adapt' TypeError, which
> is similar to a ComponentLookupError but with a slightly different
> meaning (not sure why the CA doesn't use a custom exception for this).
...because it provides more information about what went wrong, which is
> This feature allows you to create an adapter which is capable of inspecting
> its arguments and determining that it's not capable of adapting those
> particular objects. Because an adapter that returns None has this specific
> meaning, you can't actually adapt something to None. You'll have to use
> queryAdapter or explicitly handle the exception.
Yeah, except that creates duplicate code expressions all over the place.
Why doesn't subclassing work? (this is the one and only question I've
been looking to get an answer to for the whole of this thread ;-) )
Simplistix - Content Management, Zope & Python Consulting
Zope-Dev maillist - Zope-Dev@zope.org
** No cross posts or HTML encoding! **
(Related lists -