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

2005-11-14 Thread James Allwyn
On 12/11/05, Stephan Richter [EMAIL PROTECTED] 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
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


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

2005-11-12 Thread Stephan Richter
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.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics  Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


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

2005-10-30 Thread James Allwyn
Hi,

My project has an IAccommodation object type, representing a generic
housing unit, from which we subclass several types of housing
(ISharedHouse, IFamilyHouse, ILargerDevelopment,...).

Now, we need to recognise various standards in relation to these
accommodation units -  these are standards that have been defined by
various local councils etc, and an accommodation unit typically has to
meet certain conditions before it can be deemed to meet that standard.
A property that meets a standard is deemed to be better than one that
doesn't.

However, there is a degree of complexity to these standards...

* Different standards will apply to different accommodation types.
* Some accommodation types will have no relevant standard.
* Some standards will apply to an accommodation type in some
geographic areas but not other areas.

One reason we want to handle these standards is to be able to rate the
accommodation. E.g., a house that wasn't part of the Accreditation
Scheme standard could appear lower in search results than one that
was. Naturally, where there is no relevant standard for an
accommodation to live up to, we do not want to penalise it in this way
(or possibly would want it to appear below those that do meet a
standard, and those that don't meet a standard but could...)

Now, I believe I should be defining an interface or interfaces for
standards and using adapters to adapt my Accommodation Objects to the
'standards' interface(s).

My question is, how best to handle the complexity I've outlined above?

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).

I recalled reading in Philipp's book about Named Adapters, but
looking back I can only find brief references to them. A 'search'
through the PDF of Stephan's book reveals no instances of the phrase
named adapter (or variations). Are these something I should be
looking into, and if so, where can I read up on them?

Or does anyone have any other suggestions on handling this?

Many thanks,
James
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users