#15084: Unnecessary imports lead to ImportError
---------------------------+------------------------------------------------
 Reporter:  vanschelven    |       Owner:  nobody    
   Status:  new            |   Milestone:            
Component:  Uncategorized  |     Version:  1.2       
 Keywords:                 |       Stage:  Unreviewed
Has_patch:  0              |  
---------------------------+------------------------------------------------
 django/utils/translation/trans_real.py contains

 {{{
          for appname in settings.INSTALLED_APPS:
             app = import_module(appname)
             apppath = os.path.join(os.path.dirname(app.__file__),
 'locale')
 }}}

 As you can see, the only reason apps are imported here is to determine
 their location so a locale path can be tucked on. However, importing apps
 comes at a cost. There are cases in which this import leads to a circular
 reference, leading to the inability of the application to load.

 There may be more locations where this particular loop over INSTALLED_APPS
 leads to problems, though I have not encountered them.

 On a somewhat related note, I don't think Django provides us with an easy
 way to loop over the installed apps. We have models.get_apps, but that
 doesn't work for modelless apps. This might lead to issues such as the one
 I reported here:
 https://github.com/jezdez/django-staticfiles/issues#issue/2

 I'll try to reproduce the negative consequences (the ImportError) in a few
 moments and post the results here. I also have some kind of patch for this
 running in production, but I can imagine it's not really core-proof.
 Evaluation is appreciated.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15084>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to