[Grok-dev] Adapter lookup problem (is this a bug?)
Sebastian Ware
sebastian at urbantalk.se
Thu Sep 11 03:31:41 EDT 2008
After some experimenting I can confirm that the code bellow (minus
typos) works as expected.
The problem I had was because I gave the two adapters the same class
name (in two different files of course). Is this a bug, or a feature,
in the adapter registry?
Mvh Sebastian
10 sep 2008 kl. 16.31 skrev Sebastian Ware:
> I am stuck with an adapter lookup problem. I have an adapter for the
> context of my base class...
>
> module.py:
>
> class IAdaptIt(Interfaces):
> ...
>
> class MyBase(Object):
> ...
>
> class MyBaseAdapter(grok.Adapter):
> grok.context(MyBase)
> grok.provides(IAdaptIt)
>
> ...
>
> And then I want to override it for an subclass...
>
> special.py
>
> class MySpecialised(module.MyBase):
> ...
>
> class MyExtendedAdapter(grok.Adapter):
> grok.context(MySpecialised)
> grok.provides(module.IAdaptIt)
>
> ...
>
> But when I try to adapt an object of type [MySpecialised] I keep on
> getting [MyBaseAdapter] instead of [MyExtendedAdapter]. Something like
> this...
>
>>>> obj = special.MySpecialised()
>>>> adapter = module.IAdaptIt(obj)
>>>> adapter
> [module.MyBaseAdapter]
>
> But I want adapter to return [MyExtendedAdapter].
>
> Is there anything obviously wrong? How do I debug adapter lookup
> order?
>
> Mvh Sebastian
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev
More information about the Grok-dev
mailing list