[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Pulp-list] API Circular Dependencies




----- Original Message -----
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> The CdsApi uses methods in the RepoApi and vice-versa. I originally
> thought that was causing an issue in __init__ on the construction of
> the
> *Api classes, but it's happening earlier than that at the import
> level.
> 
> I'd really rather not refactor out the methods so that they both rely
> on
> some third class; that's just ugly. And I don't think it's a far
> stretch
> to assume our Api classes will use each other.
> 
> I didn't see an example of doing this in our code today, but I can't
> imagine this is the last time we'll see it. So I'm looking for the
> proper python way to do it. From what I can tell, there's two
> approaches:
> 
> - - Move the import (and thus the instantiation of the other-Api
> class) to
> the method where it is used. That way the initial load of the module
> can
> finish without causing the recursive load of the dependent Api module.
> 
> - - Move the imports of those dependent modules to the end of the
> file. I
> haven't tried this, but I heard that it will work given the way python
> loads modules.
> 
> This seems like a pretty generic need, so I wanted to know if anyone
> had
> encountered this before and felt strongly about an approach we can
> use.
> 

I'm also interested in the "right" way to fix this. I've run into this between repo api and repo_sync.
  


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]