On Dec 5, 2007 4:00 PM, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote: > It's *extremely* useful to be able to inspect settings files *without* > triggering imports of all INSTALLED_APPS -- I've got at least a dozen > utilities that operate on multiple sites by introspecting various > settings modules. > > IOW, settings modules should always be importable, even if some > particular app referenced is broken.
Not only that, but there are logistical problems with importing an app directly. For starters, importing the app-level module itself offers little benefit. Its namespace wouldn't have access to any modules inside the app (such as models, urls and views), so we'd end up just having to use its __name__ attribute and import those by hand the way we do now, so it would just add an extra step to the process. On top of that, what if an app's module makes a decision based on a particular setting? It would have to import settings, and if it's being imported from settings already, that's a potentially nasty circular import just waiting to happen. Worse yet, if we solve the first problem by importing the 'models' module directly, and use that as the app's module (as Django already does internally), we're *guaranteed* to have circular imports, as the "from django.db import models" line at the top of all 'models' modules triggers a check for settings.DATABASE_ENGINE (at least). And, of course, there's the ugliness of having all the 'models' modules having to be renamed at the top of your settings file: from django.contrib.auth import models as auth from django.contrib.sessions import models as sessions from django.contrib.admin import models as admin from django.contrib.comments import models as comments I just see a great many problems, and no real benefits. -Gul --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---