[Zope3-Users] Complex Adapter Requirements - Named Adapters?

James Allwyn jamesallwyn at gmail.com
Mon Nov 14 05:03:35 EST 2005


On 12/11/05, Stephan Richter <srichter at cosmos.phy.tufts.edu> wrote:
> On Sunday 30 October 2005 14:16, James Allwyn wrote:
> > One thought I had, was creating an interface IStandard, with
> > attributes like "meetsstandard" and "nameofstandard", and then
> > subclass this, e.g. to IAccreditationScheme and INationalCode (where
> > "Accreditation Scheme" and "National Code" are the names of two of the
> > standards). But I get a little stuck conceptually at the point where I
> > try to handle, for example, the fact that for some ISharedHouse
> > objects, IAccreditationScheme would be suitable, whilst for others it
> > wouldn't, because of their location. In fact it's likely that in the
> > future we will need to recognise two or more standards for a
> > particular accommodation type (so IAccreditationScheme and IHouseCheck
> > chould both apply to ISharedHouse objects, in differect areas).
>
> This is not such a complex case as you think.
>
> If you register an adapter from ISharedHouse to IAccreditationScheme then it
> will be only available for this interface and not for IAccommodation in
> general. I would even write a specific IAccreditationScheme for every scheme
> you support; thus you do not even need named adapters.

OK, so by targeting the registration of the adapter I can make sure
each adapter is not available for types of accommodation object that
it would not apply to. I'm with you on that.

My thoughts about named adapters were related to the 'other side of
the coin', where I have more than one scheme (and hence adapter) that
would apply to one type of accommodation (for example the schemes
represented by IAccreditationScheme and IHouseCheck would both apply
to ISharedHouses). I guess what I want is to have both IHouseCheck and
IAccreditationScheme available for ISharedHouses *in general*, and to
select either (or none) for a given *instance* of ISharedHouse.

Are named adapters the way to go for this requirement, or am I not
understanding some mechanism in Stephan's suggestion that makes this
possible without invoking that level of complexity?

Thanks for the guidance so far.
James


More information about the Zope3-users mailing list