[TransWarp] New interfaces

Oleg Broytmann phd at work.phd.pp.ru
Thu May 15 07:40:42 EDT 2003


On Wed, May 14, 2003 at 06:52:10PM -0400, Phillip J. Eby wrote:
> Ah, I think maybe I see what you're doing.  It sounds like you're trying to 
> register things as utility providers, for whatever interfaces the class 
> implements.  But I don't understand *why* you're doing it.  PEAK did this a 
> long time ago, and it turned out to be a bad idea, because it led to 
> unexpected consequences.  Just because you have a component, doesn't mean 
> you want to provide it to all your children as an implementation of 
> whatever things it does.

   To siblings, not children.

> Perhaps you could explain your use case a bit more, so I can tell whether 
> there is an existing capability for what you need, or if perhaps I have 
> overlooked a use case?  Thanks.

   There is a number of components listed in the config file:

[app]
components = "db", "s_server", "ui", "httpd", "asyncore"

component.db = "DataServer.DataServer"
component.s_server = "ScenarioServer.ScenarioServer"
component.ui = "UiServer.HtmlServer"
component.httpd = "UiFrontend.BaseHTTPD"
component.asyncore = "AsyncCore.AsyncCore"

   There is a loader that loads components and registers their interfaces (the
code that I posted was from the loader).

   Components try to lookup each other. For example, BaseHTTPD tries to lookup
UiServer by its IUiServer interface:

class BaseHTTPD(Component):

    implements(interfaces.IUiFrontend)

    # link to UiServer
    ui_server = binding.Once(
        lambda s, d, a: config.findUtility(s, interfaces.IUiServer),
        doc="HTML-based UI Server handling HTTP requests")

   Now this fails - config.findUtility cannot find the interface because it
was not registered.

   BTW, AFAIU this can be shortened to

    ui_server = binding.bindTo(interfaces.IUiServer)

   right?

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