[TransWarp] New interfaces
Oleg Broytmann
phd at work.phd.pp.ru
Wed May 14 13:47:33 EDT 2003
On Wed, May 14, 2003 at 01:12:46PM -0400, Phillip J. Eby wrote:
> At 06:33 PM 5/14/03 +0400, Oleg Broytmann wrote:
> > if _factory.__dict__.has_key("__implements__"):
> > _provides = _factory.__implements__
> >
> > How can I do this now?
>
> You don't. We're specifically deprecating interface introspection. Use
> adaptation instead. In other words, every place in PEAK where we used to
> do this:
>
> if IFoo.isImplementedBy(ob):
> spamFoo(ob)
> elif IBar.isImplementedBy(ob):
> spamBar(ob)
> ...
>
> We now do this:
>
> adapt(ob,ISpam).spam()
[skip]
> If you have code that accesses __implements__ in order to examine an
> object's interfaces as metadata
No, I did it to register the object as a provider:
if _factory.__dict__.has_key("__implements__"):
_provides = _factory.__implements__
[skip]
# if the component provides something, register provider
if _provides:
self.__class_provides__.register(_provides, _cname)
Now confg.findUtility() can find the object by its interface. How should I
register providers now?
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the PEAK
mailing list