[PEAK] peak.naming question
Phillip J. Eby
pje at telecommunity.com
Thu Dec 23 12:47:59 EST 2004
At 11:34 AM 12/23/04 -0500, Andy Gross wrote:
>>The idea here is that a *name* (like "foo") is translated by a naming
>>service to a *reference* which designates a *factory* and one or more
>>*addresses*. Addresses (URL schemes) are supposed to be reusable for a
>>variety of purposes. So, even though there is a default factory
>>associated with URL schemes, you do not subclass the URL scheme just to
>>get a different factory. Instead, just create a reference to bind the
>>desired factory to the appropriate addresses. Then, so that code doesn't
>>need to know the details, just use the configuration system or a
>>name-based context to map from a symbolic name (like "foo") to the reference.
>
>Thanks for the tips. I was able to refactor out 2 URL subclasses - I'm
>working on a Context now to provide the name resolution/expansion.
Note that a trivial way is just to use properties like:
[irc.hosts]
foo = naming.Reference("somemod.some_factory", ["irc://bar.foo",
"irc://baz.foo",...])
And then bind to PropertyName("irc.hosts.foo"), or "config:irc.hosts.foo/"
(don't forget the trailing "/").
More information about the PEAK
mailing list