[Pulp-list] API Circular Dependencies

Jay Dobies jason.dobies at redhat.com
Mon Dec 20 14:32:29 UTC 2010


-----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.

- -- 
Jay Dobies
RHCE# 805008743336126
Freenode: jdob
http://pulpproject.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJND2j9AAoJEOMmcTqOSQHCJ8sH/i+l8gQonAo+vgurzrraz44c
TZpgjr6jmjrkVK4PaumXH6OrbboBYgIZmVeT6NZWPYejPA+nTAO32TY947hyKsZL
qs+C2mnjQtv4mTYo4mnuBTZZvpGwC0zIOzGVVHY0uwXabXS6+8mvGQEDoRa+ncFl
IPcIQZx7TkT8EOgyWs5E1cQWWDolf2KvY2izJqgoAYpAapWihwTbuFVVUeVFbZ7d
/liwQzx6+KSzAk8p+WkqKNJGw9seeFcy4o5USiZvYT68zmiHEqF/s9566T4DLXfY
hxrw+z9npkOUcXsnMwie7fYVxa+6oyqghk74i7+R7DuBXxxzKvaVHlU/D87soIo=
=5sYR
-----END PGP SIGNATURE-----




More information about the Pulp-list mailing list