[Zope3-dev] Re: adapter registration question
Chris Withers
chris at simplistix.co.uk
Tue Nov 14 03:41:21 EST 2006
Philipp von Weitershausen wrote:
> Chris Withers wrote:
>> Christian Theune wrote:
>>> The problem you have is to provide a specification for the 'str'
>>> interface.
>>
>> There are a couple of problems here...
>>
>> 1. str is both a "function" and a "class"
>
> Nope. It's a class since Python 2.2.
...hence the quotes. It's a "function" in that I want to use it as an
adapter that doesn't need to be instantiated by a factory before being used.
> Right, as an *input* of the adaption it's ok just to specify a class.
> But the output obviously always has to be specified by an interface.
> Otherwise the whole point of using of adaption is perverted...
Not really. It's the ability to register the adapter, and change which
adapter you choose to use that's important for me here. I think it
should be fine to adapt to a class if you can adapt from a class. Is
there anything in the implementation that actually prevents this?
(which I, for one, would consider a bug)
>> should be:
>>
>> provide="str"
>
> Wtf? Then why do you need an adapter?
See above.
> I thought you wanted to say
> IString(1) instead of str(1) to be more flexible...?
Hmm, I see your point, but there are other ways to get an adapter than
by calling an interface ;-)
(and I think I'd need to use those here, since there is no interface)
>> ...and factory="str" is wrong for the reasons given above, or, put
>> differently, because str()(1) will tell you that strings aren't
>> callable ;-)
>
> Huh? You got that wrong. IString(1) will call str(1) if
> provideAdapter(str, (int,), IString).
right, but factory="" registers and adapter factory, not an adapter and
provideAdapter registers an adapter directly, correct?
cheers,
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the Zope3-dev
mailing list