Code review comment for lp:~allenap/maas/lazy-module-loading

Revision history for this message
Mike Pontillo (mpontillo) wrote :

I think this is a novel way to solve the problem, and I think it could be a step in the right direction.

However, I'm not sure we should land it this late in 1.9. It seems risky to introduce the extra logic now. It seems you are creating "proxy" objects, and I don't fully understand how all of the proxying logic works. For example, do the objects returned by the lazy importer obey "normal" python conventions, such as returning the appropriate type when isinstance() is called?

It seems that another way to solve the circular import problem would be to import modules rather than functions at the top level, so that the specific dependencies we need aren't resolved until the correct time. But that would lead to code like:

from maasserver.models import fabric

...

def foo():
    f = fabric.Fabric()
    # or...
    Fabric = fabric.Fabric
    f = Fabric()

... which seems less than ideal. (but perhaps no worse than the extra 'import' line we have now, or writing a few hundred lines of lazy-importing code!)

review: Needs Information

« Back to merge proposal