[PEAK] "Component Factories" suggestion
Phillip J. Eby
pje at telecommunity.com
Fri Dec 17 11:23:53 EST 2004
At 04:43 PM 12/17/2004 +0100, Radek Kanovsky wrote:
>Hi Phillip,
>
>I would welcome small change in config.CreateViaFactory implementation.
>What I exactly want to do is to specify factory function in "Component
>Factories" section. This factory should look up some config data and
>create instance of some class. Class of returned instance can vary
>according to configuration. It is not possible now, because factory
>doesn't receive any context:
The factory doesn't, but the expression that specifies the factory does;
'propertyMap' will be the configuration context that the defining .ini file
is being loaded into. So, trivially, you can define a factory like
'lambda: realFactory(propertyMap)' to do this.
I don't recall whether there was any specific reason why the factories
needed to be created the way they were; I'd have to take a look at the
code. But I do recall that there was some kind of problem with passing
arguments to the factory, and I think it was because I needed to be able to
support factories that weren't component factories. I'll look into this
more when I get back in town. In the meantime though, you have a simple
workaround.
More information about the PEAK
mailing list