adaptation
Bryan
belred1 at yahoo.com
Tue Nov 16 20:13:31 EST 2004
Terry Reedy wrote:
>>example?
>
>
> The example used in the Zope3 programmer tutorial:
>
> You have database of (USA) Buddy objects, each with firstname, lastname,
> streetaddress, zipcode, and email fields. You want to use them in a
> context that requires the (redundant) city and state fields. So you write
> a zip to city/state lookup function and then an ExpandedBuddy adapter that
> gets the zip from the adapted Buddy, calls city_state(zip), and packages
> the result together as needed in the usage context.
>
> Terry J. Reedy
>
>
>
thanks carlos, alex, terry...
the part i was missing was that adapt() retrieves a registered customized adapter from a registry. so, i see that this
would completely decouple code which wants objects of protocol Y from code that created objects with different protocols
X[n]. this seems to be the basic adapter pattern, but with the added feature of the registry lookup. i'm sure there
are some other dynamic benifits you get by using python. i'll read the links the links that were posted and catch
up... thanks,
bryan
More information about the Python-list
mailing list