[Zope3-dev] Re: adapter registration question

Jean-Marc Orliaguet jmo at ita.chalmers.se
Wed Nov 15 14:51:16 EST 2006


Philipp von Weitershausen wrote:
> Dieter Maurer wrote:
>> Philipp von Weitershausen wrote at 2006-11-15 20:34 +0100:
>>> Dieter Maurer wrote:
>>>> Philipp von Weitershausen wrote at 2006-11-15 15:08 +0100:
>>>>> ...
>>>>>> def myStrAdapter(something):
>>>>>>    return str(something)
>>>>> It instantiates a 'str' object. The 'str' object is the adapter 
>>>>> for 'something'.
>>>> Huh? This would be a severe terminology abuse:
>>> I agree, it's bending the terminology a lot. It wasn't me who came 
>>> up with the 'str' and 'int' example.
>>>
>>>>   An adapter should adapt something to something else *BUT*
>>>>   an "str" object does not adapt anything (it does not operate on
>>>>   another object).
>>> Well, imagine
>>>
>>>   >>> str(123)
>>>   '123'
>>>
>>> Here '123' is the 'str' adapter of the integer 123. It's 
>>> conceptually the same if you do
>>
>> That's the terminology abuse:
>>
>>    '123' is not an adapter because it does not do the adaption.
>>
>>    '123' is the *result* of adapting 123 to 'str'.
>>
>>    You may call '123' the 'str' adaption of the integer 123.
>>>   >>> IZopeDublinCore(myobj)
>>>
>>> except that in the str(123) case, you call the class directly 
>>> instead of using the Component Architecture's registry as a flexible 
>>> dispatch.
>>
>> With appropriate terminology use, you would call "IZopeDublinCore"
>> the adapter and "IZopeDublinCore(myobj)" the ZopeDublinCore
>> adaption (maybe adaptation) of "myobj".
>>
>> Again "IZopeDublinCore(myobj)" is not an adapter but an adapted value.
>
> Not sure what "official" terminology glossary you're basing this on, 
> but we often refer to "IZopeDublinCore(myobj)" as the "IZopeDublinCore 
> adapter" of myobj". Whatever is called to instantiate that object we 
> call the "adapter factory" or "adapter implementation". The whole 
> zope.component API (both registration and lookup) reflects this use of 
> the terminology.
>
>

str(123) has the same syntax as IZopeDublinCore(myobj), but semantically 
there is nothing in common between the two expressions.

IZopeDublinCore(myobj) does an adapter lookup based on the type of 
'myobj' and returns an adapter instance with myobj as context, ready to 
be used.

but what problem is all this supposed to solve? are you guys writing a 
PhD or something .-) ?

/JM



More information about the Zope3-dev mailing list