[TransWarp] New interfaces

Oleg Broytmann phd at work.phd.pp.ru
Thu May 15 09:46:42 EDT 2003


Ok, I see. Thank you.

On Thu, May 15, 2003 at 09:34:43AM -0400, Phillip J. Eby wrote:
> Why not use the [Provide Utilities] section instead, e.g.:
> 
> [Provide Utilities]
> 
> myApp.interfaces.IUiFrontEnd = 
> config.provideInstance('myApp.UiFrontEnd.BaseHTTPD')
> ...
> 
> (assuming 'myApp' is your package prefix, of course.)  In other words, why 
> not just register these under the interface you want to find them by?
> 
> If you do as I suggest above, PEAK will instantiate and cache an instance 
> of each component upon request for a utility of that instance.  The 
> component that the config file was loaded into, will be used as the parent 
> component of the created components.
> 
> So, if you want these components loaded somewhere besides the configuration 
> root, just use config.loadConfigFile() to load a specific configuration 
> file into a specific component.

> >   BTW, AFAIU this can be shortened to
> >
> >    ui_server = binding.bindTo(interfaces.IUiServer)
> >
> >   right?
> 
> Yes.  Also, you can say 'binding.bindTo(interfaces.IUiServer, 
> provides=interfaces.IUiServer)', if you want to then also publish the 
> component to children of the current component, under that interface.  In 
> fact, that's a common enough desire that I created a shortcut for 
> it.  'binding.Acquire(foo)' is equivalent to 
> 'binding.bindTo(foo,provides=foo)'.

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