[Zope3-dev] Re: adapter registration question
Chris Withers
chris at simplistix.co.uk
Thu Nov 16 02:47:32 EST 2006
Philipp von Weitershausen wrote:
> >>> IZopeDublinCore(obj)
>
> is a flexible version of
>
> >>> ZDCAnnotatableAdapter(obj)
>
> Flexible, because a different implementation that ZDCAnnotatableAdapter
> might be used. That's dispatched through the adapter registry.
Right, exactly.
>> IZopeDublinCore(myobj) does an adapter lookup based on the type of
>> 'myobj'
>
> That's the lookup in the registry (part 1 of the adapter call)
>
>> and returns an adapter instance with myobj as context, ready to be used.
>
> That's the instantiation a la str(123) (part 2 of the adapter call)
Ah, I think this is becoming clearer...
So, as another example, I could register the following as a factory for
turning instances of DateTime instances into datetime instances:
def convert_dates(date):
return datetime(year=date.Year(),month=date.Month(),day=date.Month())
The important thing here, for me, is that the adapted value is not an
instance of the adapter factory.
Am I getting this now?
cheers,
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the Zope3-dev
mailing list