Changeset 3201
- Timestamp:
- 06/24/06 23:24:15 (2 years ago)
- Files:
-
- django/trunk/django/core/management.py (modified) (2 diffs)
- django/trunk/django/db/models/loading.py (modified) (3 diffs)
- django/trunk/django/db/models/options.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management.py
r3195 r3201 804 804 self.outfile = outfile 805 805 806 def add(self, opts, error):807 self.errors.append(( opts, error))808 self.outfile.write(style.ERROR("%s .%s: %s\n" % (opts.app_label, opts.module_name, error)))806 def add(self, context, error): 807 self.errors.append((context, error)) 808 self.outfile.write(style.ERROR("%s: %s\n" % (context, error))) 809 809 810 810 def get_validation_errors(outfile, app=None): … … 815 815 """ 816 816 from django.db import models 817 from django.db.models.loading import get_app_errors 817 818 from django.db.models.fields.related import RelatedObject 818 819 819 820 e = ModelErrorCollection(outfile) 821 822 for (app_name, error) in get_app_errors().items(): 823 e.add(app_name, error) 824 820 825 for cls in models.get_models(app): 821 826 opts = cls._meta django/trunk/django/db/models/loading.py
r3195 r3201 11 11 # Each value is a dictionary of model name: model class 12 12 # Applabel and Model entry exists in cache when individual model is loaded. 13 _app_errors = {} # Dictionary of errors that were experienced when loading the INSTALLED_APPS 14 # Key is the app_name of the model, value is the exception that was raised 15 # during model loading. 13 16 _loaded = False # Has the contents of settings.INSTALLED_APPS been loaded? 14 17 # i.e., has get_apps() been called? … … 23 26 try: 24 27 load_app(app_name) 25 except ImportError: 26 pass # Assume this app doesn't have a models.py in it. 27 # GOTCHA: It may have a models.py that raises ImportError. 28 except AttributeError: 29 pass # This app doesn't have a models.py in it. 28 except Exception, e: 29 # Problem importing the app 30 _app_errors[app_name] = e 30 31 return _app_list 31 32 … … 40 41 def load_app(app_name): 41 42 "Loads the app with the provided fully qualified name, and returns the model module." 43 global _app_list 42 44 mod = __import__(app_name, '', '', ['models']) 43 45 if mod.models not in _app_list: 44 46 _app_list.append(mod.models) 45 47 return mod.models 48 49 def get_app_errors(): 50 "Returns the map of known problems with the INSTALLED_APPS" 51 global _app_errors 52 get_apps() # Run get_apps() to populate the _app_list cache. Slightly hackish. 53 return _app_errors 46 54 47 55 def get_models(app_mod=None): django/trunk/django/db/models/options.py
r3113 r3201 88 88 def __repr__(self): 89 89 return '<Options for %s>' % self.object_name 90 90 91 def __str__(self): 92 return "%s.%s" % (self.app_label, self.module_name) 93 91 94 def get_field(self, name, many_to_many=True): 92 95 "Returns the requested field by name. Raises FieldDoesNotExist on error."
