[Python-Dev] PEP 246, redux
James Y Knight
foom at fuhm.net
Fri Jan 14 03:41:13 CET 2005
On Jan 13, 2005, at 12:46 PM, Clark C. Evans wrote:
> My current suggestion to make 'transitive adaption' easy for a
> application builder (one putting togeher components) has a few
> small parts:
>
> - If an adaptation is not found, raise an error, but list in
> the error message two additional things: (a) what possible
> adaptation paths exist, and (b) how to register one of
> these paths in their module.
>
> - A simple method to register an adaption path, the error message
> above can even give the exact line needed,
>
> adapt.registerPath(from=A,to=C,via=B)
I'd just like to note that this won't solve my use case for transitive
adaptation. To keep backwards compatibility, I can't depend on the
application developer to register an adapter path from A through
IResource to INewResource. Trying to adapt A to INewResource needs to
just work. I can't register the path either, because I (the framework
author) don't know anything about A.
A solution that would work is if I have to explicitly declare the
adapter from IResource to INewResource as 'safe', as long as I don't
also have to declare the adapter from A to IResource as 'safe'. (That
is, I suppose -- in a transitive adapter chain, all except one adapter
in the chain would have to be declared 'safe').
I don't know whether or not it's worthwhile to have this encoded in the
framework, as it is clearly possible to do it on my own in any case.
I'll leave that for others to debate. :)
James
More information about the Python-Dev
mailing list