[PEAK] Using config.FactoryFor

Phillip J. Eby pje at telecommunity.com
Thu Dec 18 09:18:54 EST 2003


At 02:38 AM 12/18/03 -0800, John Landahl wrote:
>Just started using the new "component factories" feature(s)... this is 
>*really* great stuff.
>
>In some cases the standard factory itself is needed (e.g. to be able to 
>pass data to the constructor, to be able to create objects on the fly, 
>etc.), so it seems that config.FactoryFor() is the right tool for the 
>job.  Is this a correct way of making the factory itself a binding?
>
>     myFactory = binding.Make(
>         lambda self: importObject(
>             self.lookupComponent(config.FactoryFor(ISomeInterface))
>         )
>     )

Well, that would work, but it seems it would be simpler to just do:

     myFactory = binding.Obtain( config.FactoryFor(ISomeInterface) )

But then the factory needs to be specified with importString() in the 
config file.

Hm.  Maybe I should rework that so that the [Component Factories] section 
handler does that for you.  It doesn't really ever make sense to have a 
string as a factory object, so it'd be reasonable.  I'll take a look at that.




More information about the PEAK mailing list