[Grok-dev] Adapter lookup problem
Sebastian Ware
sebastian at urbantalk.se
Wed Sep 10 10:31:51 EDT 2008
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
More information about the Grok-dev
mailing list