Ticket #3420: db.models.loading.diff
File db.models.loading.diff, 1.2 KB (added by , 18 years ago) |
---|
-
models/loading.py
4 4 from django.core.exceptions import ImproperlyConfigured 5 5 import sys 6 6 import os 7 import traceback 7 8 8 9 __all__ = ('get_apps', 'get_app', 'get_models', 'get_model', 'register_models') 9 10 … … 29 30 load_app(app_name) 30 31 except Exception, e: 31 32 # Problem importing the app 32 _app_errors[app_name] = e33 _app_errors[app_name] = format_exception(e) 33 34 return _app_list 34 35 36 def format_exception(exception): 37 "Adds traceback information to the exception to assist debugging." 38 filename, line_number, function_name, text = traceback.extract_tb(sys.exc_info()[-1])[-1] 39 return "%s\n\tFile %s, line %s, in %s\n\t\t%s" % (exception, filename, line_number, function_name, text) 40 35 41 def get_app(app_label, emptyOK=False): 36 42 "Returns the module containing the models for the given app_label. If the app has no models in it and 'emptyOK' is True, returns None." 37 43 get_apps() # Run get_apps() to populate the _app_list cache. Slightly hackish.