You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by David Lutterkort <lu...@redhat.com> on 2012/12/03 05:13:02 UTC

Re: [PATCH core 1/6] CIMI: Initial support for persisting attributes in database

On Fri, 2012-11-30 at 10:10 +0100, Michal Fojtik wrote:
> On 11/29, David Lutterkort wrote:
> > 
> > > +      def current_provider
> > > +        Thread.current[:provider] || ENV['API_PROVIDER'] || 'default'
> > > +      end
> > 
> > Ugh .. this introduces nasty dependencies on how we are running things.
> > It might be time to write the driver/provider into every
> > Deltacloud::Model (or CIMI::Model) object.
> 
> What you mean with nasty dependencies? We use this in views too
> (api.xml.haml, etc). I think the best place for this method will be
> 'drivers.rb.

For views, I have an easier time with depending on global variables like
Thread.current or ENV, as they are really only useful after you've gone
through the whole machinery of handling a request. But if you also
depend on global vars deep down in code that stores in the DB, it feels
we've introduced a dependency on how request handling is done, and what
it sets up, into code that should be far removed from request handling.

I am not sure if my model suggestion will be enough to clean up this
dependeny, but it's worth thinking about that some more.

David