[TransWarp] Finding an object that provides the interface

Oleg Broytmann phd at work.phd.pp.ru
Wed May 21 13:27:39 EDT 2003


On Wed, May 21, 2003 at 12:34:15PM -0400, Phillip J. Eby wrote:
> >class ScenarioServer(Runnable.Runnable):
> >    protocols.advise(instancesProvide=[interfaces.IScenarioServer])
> >
> >class HtmlServer(ThreadRunnable.ThreadRunnable):
> >    protocols.advise(instancesProvide=[interfaces.IUiServer])
> >
> >    # link to ScenarioServer
> >    s_server = binding.Once(
> >        lambda s, d, a: config.findUtility(s, interfaces.IScenarioServer),
> >        doc="Main application server (ScenarioServer)")
> 
> Note that the above can be replaced with:
> 
>     s_server = binding.bindTo(interfaces.IScenarioServer)
> 

   I know.

> >   Why findUtility does not find already created instance of
> >ScenarioServer?
> 
> Probably because you didn't register it using registerProvider.

   Aha, it is not enough to declare interface. Ok, next bunch of questions:
How can I list interfaces declared by protocols.advise? (That was the
question I asked already long ago, remember?) What is the component to call
registerProvider() upon? and what is the provdier? i.e. in the call
c.registerProvider(iface, provider) what is c and what is provider? Well,
provider is probably the instance of my class that I want to be found by
findUtility.

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