Ticket #3591: app_labels.4.diff
File app_labels.4.diff, 29.4 KB (added by , 18 years ago) |
---|
-
django/bin/make-messages.py
=== modified file 'django/bin/make-messages.py'
129 129 print "errors happened while running msguniq" 130 130 print errors 131 131 sys.exit(8) 132 # Try importing the local settings. This will work if you're 133 # in the project directory 134 sys.path.insert(0, '.') 135 try: 136 import settings 137 apps = settings.INSTALLED_APPS 138 except (ImportError, AttributeError): 139 apps = [] 140 del sys.path[0] 141 # Now look for all applications which have a verbose name 142 # which is different from the default. If different, add 143 # an internationalization string. 144 for app in apps: 145 if (not isinstance(app, basestring)) and (app.verbose_name != app.path.split('.')[-1]): 146 s = '\nmsgid "%s"\nmsgstr ""\n' % app.verbose_name 147 msgs += s 132 148 open(potfile, 'w').write(msgs) 133 149 if os.path.exists(pofile): 134 150 (stdin, stdout, stderr) = os.popen3('msgmerge -q "%s" "%s"' % (pofile, potfile), 'b') -
django/conf/__init__.py
=== modified file 'django/conf/__init__.py'
97 97 # of all those apps. 98 98 new_installed_apps = [] 99 99 for app in self.INSTALLED_APPS: 100 if app.endswith('.*'): 100 if not isinstance(app, basestring) or not app.endswith('.*'): 101 new_installed_apps.append(app) 102 else: 101 103 appdir = os.path.dirname(__import__(app[:-2], {}, {}, ['']).__file__) 102 104 for d in os.listdir(appdir): 103 105 if d.isalpha() and os.path.isdir(os.path.join(appdir, d)): 104 106 new_installed_apps.append('%s.%s' % (app[:-2], d)) 105 else:106 new_installed_apps.append(app)107 107 self.INSTALLED_APPS = new_installed_apps 108 108 109 109 if hasattr(time, 'tzset'): … … 147 147 return gettext(*args) 148 148 149 149 __builtins__['_'] = first_time_gettext 150 151 class app(object): 152 """Configuration directive for specifying an app.""" 153 def __init__(self, path, app_label=None, verbose_name=None): 154 self.path = path 155 # if name isn't specified, get the last part of the Python dotted path 156 self.label = app_label or path.split('.')[-1] 157 self.verbose_name = verbose_name or self.label 158 self.app_module = None # will be filled in by loading.py 159 self.models_module = None # will be filled in by loading.py 160 161 def __repr__(self): 162 return "<app: %s>" % self.path 163 164 def get_installed_app_paths(): 165 "Return the paths of all entries in settings.INSTALLED_APPS." 166 rv = [] 167 for a in settings.INSTALLED_APPS: 168 if isinstance(a, basestring): 169 rv.append(a) 170 else: 171 rv.append(a.path) 172 return rv -
django/contrib/admin/templatetags/adminapplist.py
=== modified file 'django/contrib/admin/templatetags/adminapplist.py'
18 18 app_models = get_models(app) 19 19 if not app_models: 20 20 continue 21 app_label = app _models[0]._meta.app_label21 app_label = app.label 22 22 23 23 has_module_perms = user.has_module_perms(app_label) 24 24 … … 49 49 model_list = [x for key, x in decorated] 50 50 51 51 app_list.append({ 52 'name': app_label.title(),52 'name': _(app.verbose_name).title(), 53 53 'has_module_perms': has_module_perms, 54 54 'models': model_list, 55 55 }) -
django/contrib/admin/views/doc.py
=== modified file 'django/contrib/admin/views/doc.py'
159 159 160 160 # Get the model class. 161 161 try: 162 app _mod= models.get_app(app_label)162 app = models.get_app(app_label) 163 163 except ImproperlyConfigured: 164 164 raise Http404, _("App %r not found") % app_label 165 165 model = None 166 for m in models.get_models(app _mod):166 for m in models.get_models(app): 167 167 if m._meta.object_name.lower() == model_name: 168 168 model = m 169 169 break -
django/contrib/auth/management.py
=== modified file 'django/contrib/auth/management.py'
3 3 """ 4 4 5 5 from django.dispatch import dispatcher 6 from django.db.models import get_models, signals 7 from django.contrib.auth import models as auth_app 6 from django.db.models import get_models, signals, find_app 8 7 9 8 def _get_permission_codename(action, opts): 10 9 return '%s_%s' % (action, opts.object_name.lower()) … … 46 45 break 47 46 48 47 dispatcher.connect(create_permissions, signal=signals.post_syncdb) 49 dispatcher.connect(create_superuser, sender= auth_app, signal=signals.post_syncdb)48 dispatcher.connect(create_superuser, sender=find_app('django.contrib.auth'), signal=signals.post_syncdb) -
django/contrib/sites/management.py
=== modified file 'django/contrib/sites/management.py'
3 3 """ 4 4 5 5 from django.dispatch import dispatcher 6 from django.db.models import signals 6 from django.db.models import signals, find_app 7 7 from django.contrib.sites.models import Site 8 from django.contrib.sites import models as site_app9 8 10 9 def create_default_site(app, created_models, verbosity): 11 10 if Site in created_models: … … 14 13 s = Site(domain="example.com", name="example.com") 15 14 s.save() 16 15 17 dispatcher.connect(create_default_site, sender= site_app, signal=signals.post_syncdb)16 dispatcher.connect(create_default_site, sender=find_app('django.contrib.sites'), signal=signals.post_syncdb) -
django/core/management.py
=== modified file 'django/core/management.py'
368 368 from django.conf import settings 369 369 370 370 opts = model._meta 371 app_dir = os.path.normpath(os.path.join(os.path.dirname(models.get_app(model._meta.app_label). __file__), 'sql'))371 app_dir = os.path.normpath(os.path.join(os.path.dirname(models.get_app(model._meta.app_label).models_module.__file__), 'sql')) 372 372 output = [] 373 373 374 374 # Some backends can't execute more than one SQL statement at a time, … … 396 396 output = [] 397 397 398 398 app_models = get_models(app) 399 app_dir = os.path.normpath(os.path.join(os.path.dirname(app. __file__), 'sql'))399 app_dir = os.path.normpath(os.path.join(os.path.dirname(app.models_module.__file__), 'sql')) 400 400 401 401 for model in app_models: 402 402 output.extend(get_custom_sql_for_model(model)) … … 456 456 from django.dispatch import dispatcher 457 457 # Emit the post_sync signal for every application. 458 458 for app in models.get_apps(): 459 app_name = app. __name__.split('.')[-2]459 app_name = app.label 460 460 if verbosity >= 2: 461 461 print "Running post-sync handlers for application", app_name 462 462 dispatcher.send(signal=models.signals.post_syncdb, sender=app, … … 466 466 def syncdb(verbosity=1, interactive=True): 467 467 "Creates the database tables for all apps in INSTALLED_APPS whose tables haven't already been created." 468 468 from django.db import connection, transaction, models, get_creation_module 469 from django.conf import settings 469 from django.conf import settings, get_installed_app_paths 470 470 471 471 disable_termcolors() 472 472 … … 475 475 476 476 # Import the 'management' module within each installed app, to register 477 477 # dispatcher events. 478 for app_name in settings.INSTALLED_APPS:478 for app_name in get_installed_app_paths(): 479 479 try: 480 480 __import__(app_name + '.management', {}, {}, ['']) 481 481 except ImportError: … … 496 496 497 497 # Create the tables for each model 498 498 for app in models.get_apps(): 499 app_name = app. __name__.split('.')[-2]499 app_name = app.label 500 500 model_list = models.get_models(app) 501 501 for model in model_list: 502 502 # Create the model's database table, if it doesn't already exist. … … 519 519 # Create the m2m tables. This must be done after all tables have been created 520 520 # to ensure that all referred tables will exist. 521 521 for app in models.get_apps(): 522 app_name = app. __name__.split('.')[-2]522 app_name = app.label 523 523 model_list = models.get_models(app) 524 524 for model in model_list: 525 525 if model in created_models: … … 539 539 # Install custom SQL for the app (but only if this 540 540 # is a model we've just created) 541 541 for app in models.get_apps(): 542 app_name = app. __name__.split('.')[-2]542 app_name = app.label 543 543 for model in models.get_models(app): 544 544 if model in created_models: 545 545 custom_sql = get_custom_sql_for_model(model) … … 556 556 else: 557 557 transaction.commit_unless_managed() 558 558 559 # Install SQL indic ies for all newly created models559 # Install SQL indices for all newly created models 560 560 for app in models.get_apps(): 561 app_name = app. __name__.split('.')[-2]561 app_name = app.label 562 562 for model in models.get_models(app): 563 563 if model in created_models: 564 564 index_sql = get_sql_indexes_for_model(model) … … 635 635 "Executes the equivalent of 'get_sql_reset' in the current database." 636 636 from django.db import connection, transaction 637 637 from django.conf import settings 638 app_name = app. __name__.split('.')[-2]638 app_name = app.label 639 639 640 640 disable_termcolors() 641 641 … … 676 676 677 677 def flush(verbosity=1, interactive=True): 678 678 "Returns all tables in the database to the same state they were in immediately after syncdb." 679 from django.conf import settings 679 from django.conf import settings, get_installed_app_paths 680 680 from django.db import connection, transaction, models 681 681 from django.dispatch import dispatcher 682 682 … … 687 687 688 688 # Import the 'management' module within each installed app, to register 689 689 # dispatcher events. 690 for app_name in settings.INSTALLED_APPS:690 for app_name in get_installed_app_paths(): 691 691 try: 692 692 __import__(app_name + '.management', {}, {}, ['']) 693 693 except ImportError: … … 1293 1293 from django.db.models import get_app, get_apps 1294 1294 1295 1295 if len(app_labels) == 0: 1296 app_list = get_apps()1296 app_list = [app.models_module for app in get_apps()] 1297 1297 else: 1298 app_list = [get_app(app_label) for app_label in app_labels]1298 app_list = [get_app(app_label).models_module for app_label in app_labels] 1299 1299 1300 1300 test_path = settings.TEST_RUNNER.split('.') 1301 1301 # Allow for Python 2.5 relative paths … … 1340 1340 transaction.enter_transaction_management() 1341 1341 transaction.managed(True) 1342 1342 1343 app_fixtures = [os.path.join(os.path.dirname(app.__file__),'fixtures') for app in get_apps()] 1343 app_fixtures = [] 1344 for app in get_apps(): 1345 if app.models_module: 1346 app_fixtures.append(os.path.join(os.path.dirname( 1347 app.models_module.__file__),'fixtures')) 1344 1348 for fixture_label in fixture_labels: 1345 1349 parts = fixture_label.split('.') 1346 1350 if len(parts) == 1: … … 1619 1623 from django.db import models 1620 1624 validate(silent_success=True) 1621 1625 try: 1622 mod_list = [models.get_app(app_label) for app_label in args[1:]]1626 app_list = [models.get_app(app_label) for app_label in args[1:]] 1623 1627 except ImportError, e: 1624 1628 sys.stderr.write(style.ERROR("Error: %s. Are you sure your INSTALLED_APPS setting is correct?\n" % e)) 1625 1629 sys.exit(1) 1626 if not mod_list:1630 if not app_list: 1627 1631 parser.print_usage_and_exit() 1628 1632 if action not in NO_SQL_TRANSACTION: 1629 1633 print style.SQL_KEYWORD("BEGIN;") 1630 for mod in mod_list:1634 for app in app_list: 1631 1635 if action == 'reset': 1632 output = action_mapping[action]( mod, options.interactive)1636 output = action_mapping[action](app, options.interactive) 1633 1637 else: 1634 output = action_mapping[action]( mod)1638 output = action_mapping[action](app) 1635 1639 if output: 1636 1640 print '\n'.join(output) 1637 1641 if action not in NO_SQL_TRANSACTION: -
django/db/models/__init__.py
=== modified file 'django/db/models/__init__.py'
2 2 from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured 3 3 from django.core import validators 4 4 from django.db import backend, connection 5 from django.db.models.loading import get_apps, get_app, get_models, get_model, register_models 5 from django.db.models.loading import get_apps, get_app, get_models, get_model, register_models, find_app 6 6 from django.db.models.query import Q 7 7 from django.db.models.manager import Manager 8 8 from django.db.models.base import Model, AdminOptions -
django/db/models/base.py
=== modified file 'django/db/models/base.py'
8 8 from django.db.models.options import Options, AdminOptions 9 9 from django.db import connection, backend, transaction 10 10 from django.db.models import signals 11 from django.db.models.loading import register_models, get_model 11 from django.db.models.loading import register_models, get_model, get_app_label 12 12 from django.dispatch import dispatcher 13 13 from django.utils.datastructures import SortedDict 14 14 from django.utils.functional import curry … … 42 42 new_class._meta.parents.append(base) 43 43 new_class._meta.parents.extend(base._meta.parents) 44 44 45 46 45 if getattr(new_class._meta, 'app_label', None) is None: 47 # Figure out the app_label by looking one level up. 48 # For 'django.contrib.sites.models', this would be 'sites'. 49 model_module = sys.modules[new_class.__module__] 50 new_class._meta.app_label = model_module.__name__.split('.')[-2] 46 # Figure out the app_label. 47 new_class._meta.app_label = get_app_label(new_class) 51 48 52 49 # Bail out early if we have already created this class. 53 50 m = get_model(new_class._meta.app_label, name, False) -
django/db/models/loading.py
=== modified file 'django/db/models/loading.py'
1 1 "Utilities for loading models and the modules that contain them." 2 2 3 from django.conf import settings 3 from django.conf import settings, app 4 4 from django.core.exceptions import ImproperlyConfigured 5 5 import sys 6 6 import os … … 18 18 _loaded = False # Has the contents of settings.INSTALLED_APPS been loaded? 19 19 # i.e., has get_apps() been called? 20 20 21 _app_map = {} # Map of app instances keyed by app_label. 22 _mod_map = {} # Map of app instances keyed by app module names. 23 _apps = [] # List of app instances. Shadows _app_list. 24 25 _set_apps = None # what INSTALLED_APPS was when _loaded was set to True 26 21 27 def get_apps(): 22 "Returns a list of all installed modules that contain models."28 "Returns a list of all loaded applications." 23 29 global _app_list 24 30 global _loaded 25 if not _loaded: 31 global _app_map 32 global _mod_map 33 global _set_apps 34 global _apps 35 36 changed = (_set_apps != settings.INSTALLED_APPS) 37 if changed or not _loaded: 38 if changed: 39 _apps = [] 40 _app_map = {} 41 _mod_map = {} 26 42 _loaded = True 27 for app_name in settings.INSTALLED_APPS: 43 _set_apps = settings.INSTALLED_APPS[:] 44 # We first loop through, setting up the app instances and 45 # the relevant maps so that we can find the instances by app_label 46 # or app module name. These need to be ready because we need to be 47 # able to get the app_label e.g. for applying to model classes. 48 # If a model class is loaded indirectly without being in an 49 # installed app, the app_label used will be what it is now - the 50 # last part of the app module name. 51 # Note that _app_map and _mod_map will contain entries even 52 # when an app cannot be loaded by load_app. 53 for app_entry in settings.INSTALLED_APPS: 54 if isinstance(app_entry, basestring): 55 the_app = app(app_entry) 56 else: 57 the_app = app_entry 58 _app_map[the_app.label] = the_app 59 _mod_map[the_app.path] = the_app 60 61 for app_entry in settings.INSTALLED_APPS: 62 if isinstance(app_entry, basestring): 63 the_app = _mod_map[app_entry] 64 else: 65 the_app = app_entry 66 app_name = the_app.path 28 67 try: 29 68 load_app(app_name) 69 _apps.append(the_app) 30 70 except Exception, e: 31 71 # Problem importing the app 32 72 _app_errors[app_name] = e 33 return _app_list 73 return _apps 74 75 def get_app_label(model_class): 76 "Returns the app label to be used for a model class." 77 global _mod_map 78 key = model_class.__module__ 79 i = key.rfind('.') 80 assert i > 0, "Model class must be defined in a package sub-module" 81 key = key[:i] 82 if key in _mod_map: 83 rv = _mod_map[key].label 84 else: 85 i = key.rfind('.') 86 if i < 0: 87 rv = key 88 else: 89 rv = key[i + 1:] 90 return rv 91 92 def find_app(app_path): 93 "Find an app instance, given the application path." 94 get_apps() 95 return _mod_map[app_path] # _mod_map.get(app_path, None) 34 96 35 97 def get_app(app_label, emptyOK=False): 36 "Returns the module containing the modelsfor the given app_label. If the app has no models in it and 'emptyOK' is True, returns None."98 "Returns the app instance for the given app_label. If the app has no models in it and 'emptyOK' is True, returns None." 37 99 get_apps() # Run get_apps() to populate the _app_list cache. Slightly hackish. 38 for app_name in settings.INSTALLED_APPS: 39 if app_label == app_name.split('.')[-1]: 40 mod = load_app(app_name) 41 if mod is None: 42 if emptyOK: 43 return None 44 else: 45 return mod 100 if app_label not in _app_map: 101 rv = None 102 else: 103 rv = _app_map[app_label] 104 if emptyOK or rv is not None: 105 return rv 46 106 raise ImproperlyConfigured, "App with label %s could not be found" % app_label 47 107 48 108 def load_app(app_name): 49 "Loads the app with the provided fully qualified name, and returns the model module."109 "Loads the app with the provided fully qualified name, and returns the models module." 50 110 global _app_list 111 global _app_map 112 global _mod_map 113 global _apps 51 114 mod = __import__(app_name, {}, {}, ['models']) 115 if app_name in _mod_map: 116 the_app = _mod_map[app_name] 117 else: 118 # An app can be loaded by load_app even before get_apps is 119 # called. In this case, we just make a new app and add it to the maps. 120 the_app = app(app_name) 121 _app_map[the_app.label] = the_app 122 _mod_map[app_name] = the_app 123 _apps.append(the_app) 124 the_app.app_module = mod 52 125 if not hasattr(mod, 'models'): 53 return None 54 if mod.models not in _app_list: 55 _app_list.append(mod.models) 56 return mod.models 126 rv = None 127 else: 128 rv = mod.models 129 if rv not in _app_list: 130 _app_list.append(rv) 131 the_app.models_module = rv 132 return rv 57 133 58 134 def get_app_errors(): 59 135 "Returns the map of known problems with the INSTALLED_APPS" … … 61 137 get_apps() # Run get_apps() to populate the _app_list cache. Slightly hackish. 62 138 return _app_errors 63 139 64 def get_models( app_mod=None):140 def get_models(the_app=None): 65 141 """ 66 Given a module containing models, returns a list of themodels. Otherwise67 returns a list of all installed models.142 Given an app instance, returns a list of its models. Otherwise 143 returns a list of all loaded models. 68 144 """ 69 app_list =get_apps() # Run get_apps() to populate the _app_list cache. Slightly hackish.70 if app_mod:71 return _app_models.get( app_mod.__name__.split('.')[-2], {}).values()145 get_apps() # Run get_apps() to populate the _app_list cache. Slightly hackish. 146 if the_app: 147 return _app_models.get(the_app.label, {}).values() 72 148 else: 73 149 model_list = [] 74 for app_mod in app_list:75 model_list.extend(get_models( app_mod))150 for the_app in _apps: 151 model_list.extend(get_models(the_app)) 76 152 return model_list 77 153 78 154 def get_model(app_label, model_name, seed_cache=True): -
django/db/models/options.py
=== modified file 'django/db/models/options.py'
1 from django.conf import settings 1 from django.conf import settings, get_installed_app_paths 2 2 from django.db.models.related import RelatedObject 3 3 from django.db.models.fields.related import ManyToManyRel 4 4 from django.db.models.fields import AutoField, FieldDoesNotExist … … 36 36 37 37 def contribute_to_class(self, cls, name): 38 38 cls._meta = self 39 self.installed = re.sub('\.models$', '', cls.__module__) in settings.INSTALLED_APPS39 self.installed = re.sub('\.models$', '', cls.__module__) in get_installed_app_paths() 40 40 # First, construct the default values for these options. 41 41 self.object_name = cls.__name__ 42 42 self.module_name = self.object_name.lower() -
django/template/loaders/app_directories.py
=== modified file 'django/template/loaders/app_directories.py'
1 1 # Wrapper for loading templates from "template" directories in installed app packages. 2 2 3 from django.conf import settings 3 from django.conf import settings, get_installed_app_paths 4 4 from django.core.exceptions import ImproperlyConfigured 5 5 from django.template import TemplateDoesNotExist 6 6 import os 7 7 8 8 # At compile time, cache the directories to search. 9 9 app_template_dirs = [] 10 for app in settings.INSTALLED_APPS:10 for app in get_installed_app_paths(): 11 11 i = app.rfind('.') 12 12 if i == -1: 13 13 m, a = app, None -
django/template/loaders/eggs.py
=== modified file 'django/template/loaders/eggs.py'
6 6 resource_string = None 7 7 8 8 from django.template import TemplateDoesNotExist 9 from django.conf import settings 9 from django.conf import settings, get_installed_app_paths 10 10 11 11 def load_template_source(template_name, template_dirs=None): 12 12 """ … … 16 16 """ 17 17 if resource_string is not None: 18 18 pkg_name = 'templates/' + template_name 19 for app in settings.INSTALLED_APPS:19 for app in get_installed_app_paths(): 20 20 try: 21 21 return (resource_string(app, pkg_name), 'egg:%s:%s ' % (app, pkg_name)) 22 22 except: -
django/templatetags/__init__.py
=== modified file 'django/templatetags/__init__.py'
1 from django.conf import settings 1 from django.conf import settings, get_installed_app_paths 2 2 3 for a in settings.INSTALLED_APPS:3 for a in get_installed_app_paths(): 4 4 try: 5 5 __path__.extend(__import__(a + '.templatetags', {}, {}, ['']).__path__) 6 6 except ImportError: -
django/test/client.py
=== modified file 'django/test/client.py'
2 2 import sys 3 3 from cStringIO import StringIO 4 4 from urlparse import urlparse 5 from django.conf import settings 5 from django.conf import settings, get_installed_app_paths 6 6 from django.contrib.auth import authenticate, login 7 7 from django.contrib.sessions.models import Session 8 8 from django.contrib.sessions.middleware import SessionWrapper … … 128 128 129 129 def _session(self): 130 130 "Obtain the current session variables" 131 if 'django.contrib.sessions' in settings.INSTALLED_APPS:131 if 'django.contrib.sessions' in get_installed_app_paths(): 132 132 cookie = self.cookies.get(settings.SESSION_COOKIE_NAME, None) 133 133 if cookie: 134 134 return SessionWrapper(cookie.value) … … 228 228 are incorrect, or if the Sessions framework is not available. 229 229 """ 230 230 user = authenticate(**credentials) 231 if user and 'django.contrib.sessions' in settings.INSTALLED_APPS:231 if user and 'django.contrib.sessions' in get_installed_app_paths(): 232 232 obj = Session.objects.get_new_session_object() 233 233 234 234 # Create a fake request to store login details … … 251 251 return True 252 252 else: 253 253 return False 254 255 No newline at end of file 254 -
django/utils/translation/trans_real.py
=== modified file 'django/utils/translation/trans_real.py'
107 107 if t is not None: 108 108 return t 109 109 110 from django.conf import settings 110 from django.conf import settings, get_installed_app_paths 111 111 112 112 # set up the right translation class 113 113 klass = DjangoTranslation … … 160 160 if projectpath and os.path.isdir(projectpath): 161 161 res = _merge(projectpath) 162 162 163 for appname in settings.INSTALLED_APPS:163 for appname in get_installed_app_paths(): 164 164 p = appname.rfind('.') 165 165 if p >= 0: 166 166 app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]), appname[p+1:]) -
django/views/i18n.py
=== modified file 'django/views/i18n.py'
1 1 from django import http 2 2 from django.utils.translation import check_for_language, activate, to_locale, get_language 3 3 from django.utils.text import javascript_quote 4 from django.conf import settings 4 from django.conf import settings, get_installed_app_paths 5 5 import os 6 6 import gettext as gettext_module 7 7 … … 104 104 packages = ['django.conf'] 105 105 if type(packages) in (str, unicode): 106 106 packages = packages.split('+') 107 packages = [p for p in packages if p == 'django.conf' or p in settings.INSTALLED_APPS]107 packages = [p for p in packages if p == 'django.conf' or p in get_installed_app_paths()] 108 108 default_locale = to_locale(settings.LANGUAGE_CODE) 109 109 locale = to_locale(get_language()) 110 110 t = {} -
docs/settings.txt
=== modified file 'docs/settings.txt'
469 469 470 470 Default: ``()`` (Empty tuple) 471 471 472 A tuple of strings designating all applications that are enabled in this Django 473 installation. Each string should be a full Python path to a Python package that 474 contains a Django application, as created by `django-admin.py startapp`_. 472 A tuple of entries designating all applications that are enabled in this Django 473 installation. Each entry should be one of the following: 474 475 * A string which is a full Python path to a Python package that contains a 476 Django application, as created by `django-admin.py startapp`_. 477 * A string which is a full Python path to a Python package which contains 478 multiple applications, with an appended ``.*``. This entry is replaced 479 by entries for the contained applications. For example, a wildcard 480 entry of the form ``django.contrib.*`` would be replaced by 481 multiple entries for ``django.contrib.admin``, ``django.contrib.auth`` 482 etc. 483 * An ``app`` configuration directive (to use it, you need to add 484 ``from django.conf import app`` to your ``settings`` file). This takes 485 the form ``app(path, label=None, verbose_name=None)``. The ``path`` 486 argument must specify the full Python path to a Python package that 487 contains a Django application. The ``label`` argument, if specified, 488 provides a unique application label (used to disambiguate different 489 third-party applications with conflicting default label values). If this 490 value is not specified, the last portion of the application path is used 491 as the default label. The ``verbose_name`` argument, if specified, is 492 used to provide a descriptive name for the application in the admin 493 screens. If this value is not specified, the last portion of the 494 application path is used as the default value. 475 495 476 496 .. _django-admin.py startapp: ../django-admin/#startapp-appname 477 497 -
tests/runtests.py
=== modified file 'tests/runtests.py'
2 2 3 3 import os, sys, traceback 4 4 import unittest 5 from django.conf import app 5 6 6 7 MODEL_TESTS_DIR_NAME = 'modeltests' 7 8 REGRESSION_TESTS_DIR_NAME = 'regressiontests' … … 13 14 14 15 ALWAYS_INSTALLED_APPS = [ 15 16 'django.contrib.contenttypes', 16 'django.contrib.auth', 17 #We need to use the same app label, otherwise fixtures will break... 18 app('django.contrib.auth', 'auth', 'Authentication'), 17 19 'django.contrib.sites', 18 20 'django.contrib.flatpages', 19 21 'django.contrib.redirects', … … 48 50 49 51 def runTest(self): 50 52 from django.core import management 51 from django.db.models.loading import load_app 53 from django.db.models.loading import load_app, find_app 52 54 from cStringIO import StringIO 53 55 54 56 try: 55 57 module = load_app(self.model_label) 56 58 except Exception, e: 57 self.fail('Unable to load invalid model module')59 self.fail('Unable to load invalid application %s: %s' % (self.model_label, e)) 58 60 59 61 s = StringIO() 60 count = management.get_validation_errors(s, module)62 count = management.get_validation_errors(s, find_app(self.model_label)) 61 63 s.seek(0) 62 64 error_log = s.read() 63 65 actual = error_log.split('\n')