[Zope3-dev] Ranking adapters
Jim Fulton
jim at zope.com
Tue Sep 30 11:12:45 EDT 2003
I'm noodling some adapter lookup issues as part of adaptergeddon.
Here's a hypothetical situation:
We have 5 interfaces:
class F0(interface): pass
class F1(F0): pass
class B0(interface): pass
class B1(B0): pass
class B2(B1): pass
We have two locations/sites, L1 and L2, such that L2 is contained in
(is a subsite of) L1.
We have the following adapter definitions in L1:
A110 from F1 to B0
A111 from F1 to B1
A112 from F1 to B2
We have the following adapter definitions in L1:
A200 from F0 to B0
A212 from F1 to B2
(It helps to make a picture, but I can't attach one.)
Now, suppose that we need an adapter from F1 to B.
We can use any of the adapters above. How would we rank
the above adapters? I suggest:
A212
A110
A111
A110
A200
The rational?
The most important factor is the interface being adapted.
The second most important factor is location.
The third most important factor is the interface being adapted to.
If we want a B, we don't really care much whether we get a B, a B1,
or a B2. It's fairly important to be able to override things locally,
but it's not as important as getting an adapter tailored to the object.
Thoughts? Comments?
Jim
--
Jim Fulton mailto:jim at zope.com Python Powered!
CTO (540) 361-1714 http://www.python.org
Zope Corporation http://www.zope.com http://www.zope.org
More information about the Zope3-dev
mailing list