[Zope3-dev] Ranking adapters

Shane Hathaway shane at zope.com
Tue Sep 30 13:46:06 EDT 2003


Shane Hathaway wrote:
> My intuition ranks location before the interface being adapted.  A 
> location may be a complete, constrained application, and I don't want 
> sitewide policies to override local policies.

Ok, I talked with Jim about this.  I agree that in most cases, you want 
the interface being adapted to be more important than the location.  I 
think this is because most applications want to be unconstrained and 
integrate all available features from the environment.  But sometimes 
you want to build a tightly constrained application.

Let's get more specific.  Say the photo developing kiosk wants to let 
people see metadata about images.  Let's also say that some future Zope 
includes many image classes: JPEGImage, PNGImage, etc. (since each image 
format supports different capabilities.)  The global registry includes 
IMetadata adapters for each of IJPEGImage, IPNGImage, etc.  The local 
kiosk application provides its own adapter from IImage to IMetadata, but 
in order for that adapter to ever get used, it also has to register the 
adapter for each of the more specific image interfaces.

I see two solutions:

1. Allow a local adapter registration to specify that it overrides 
global registrations, even if the global registry provides a more 
specific adapter.

2. When a local application needs to tightly constrain something, it 
should use an interface that is not available globally.  For example, 
the kiosk application could define IKioskMetadata, register an adapter 
that adapts from IImage to IKioskMetadata, then look for adapters that 
provide IKioskMetadata interface instead of IMetadata.

The second solution already works.  Maybe it's the right answer.

Shane




More information about the Zope3-dev mailing list