On Aug 8, 2014, at 7:22 PM, Devananda van der Veen <devananda....@gmail.com> wrote:
> On Fri, Aug 8, 2014 at 12:41 PM, Doug Hellmann <d...@doughellmann.com> wrote: >> >> That’s right. The preferred approach is to put the register_opt() in >> *runtime* code somewhere before the option will be used. That might be in >> the constructor for a class that uses an option, for example, as described >> in >> http://docs.openstack.org/developer/oslo.config/cfg.html#registering-options >> >> Doug > > Interesting. > > I've been following the prevailing example in Nova, which is to > register opts at the top of a module, immediately after defining them. > Is there a situation in which one approach is better than the other? The approach used in Nova is the “old” way of doing it. It works, but assumes that all of the application code is modifying a global configuration object. The runtime approach allows you to pass a configuration object to a library, which makes it easier to mock the configuration for testing and avoids having the configuration options bleed into the public API of the library. We’ve started using the runtime approach in new Oslo libraries that have configuration options, but changing the implementation in existing application code isn’t strictly necessary. Doug > > Thanks, > Devananda > > _______________________________________________ > OpenStack-dev mailing list > OpenStack-dev@lists.openstack.org > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev _______________________________________________ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev