Ticket #496: generic-imports.patch

File generic-imports.patch, 981 bytes (added by jafo@…, 19 years ago)

Patch implementing the changes proposed.

  • __init__.py

     
    6868    return ', '.join(output)
    6969
    7070def get_module(app_label, module_name):
    71     return __import__('%s.%s.%s' % (MODEL_PREFIX, app_label, module_name), '', '', [''])
     71    try:
     72        return __import__('%s.%s.%s' % (MODEL_PREFIX, app_label, module_name), '', '', [''])
     73    except ImportError, e:
     74        try:
     75            app =  __import__('%s.%s' % (MODEL_PREFIX, app_label), '', '', [''])
     76        except ImportError, e:
     77            raise ImportError('Unable to import app_label "%s": %s'
     78                    % ( app_label, str(e) ))
     79        raise ImportError('Unable to import module_name "%s": '
     80                '%s (available choices: %s)'
     81                    % ( module_name, str(e), str(dir(app)) ))
    7282
    7383def get_app(app_label):
    7484    return __import__('%s.%s' % (MODEL_PREFIX, app_label), '', '', [''])
Back to Top