Ticket #19048: django_core_management_find_management_module.patch

File django_core_management_find_management_module.patch, 1.0 KB (added by Rémy Hubscher, 12 years ago)

Patch to look at all pkg_resources

  • django/core/management/__init__.py

    a b def find_management_module(app_name):  
    4444    parts.reverse()
    4545    part = parts.pop()
    4646    path = None
     47    paths = []
    4748
    4849    # When using manage.py, the project module is added to the path,
    4950    # loaded, then removed from the path. This means that
    def find_management_module(app_name):  
    6061        if f:
    6162            f.close()
    6263
     64    paths.append(path)
     65
     66    for sys_path in sys.path:
     67        try:
     68            f, path, descr = imp.find_module(part, [sys_path])
     69        except ImportError:
     70            pass
     71        else:
     72            if f:
     73                f.close()
     74            if path not in paths:
     75                paths.append(path)
     76
    6377    while parts:
    6478        part = parts.pop()
    65         f, path, descr = imp.find_module(part, path and [path] or None)
     79        f, path, descr = imp.find_module(part, paths or None)
     80        paths.append(path)
    6681        if f:
    6782            f.close()
    6883    return path
Back to Top