#15084: Unnecessary imports lead to ImportError
------------------------------------+---------------------------------------
          Reporter:  vanschelven    |         Owner:  nobody
            Status:  new            |     Milestone:        
         Component:  Uncategorized  |       Version:  1.2   
        Resolution:                 |      Keywords:        
             Stage:  Unreviewed     |     Has_patch:  0     
        Needs_docs:  0              |   Needs_tests:  0     
Needs_better_patch:  0              |  
------------------------------------+---------------------------------------
Comment (by vanschelven):

 This is my 'works for me' solution, I can imagine it has some hairy
 consequences (Jython?)

 {{{
 def get_apppath(appname):
     def get(base, parts):
         l0 = [base] + parts + ["__init__.py"]
         l1 = [base] + parts + ["__init__.pyc"]
         if not (os.path.isfile(os.path.join(*l0)) or
 os.path.isfile(os.path.join(*l1))):
             return None
         return os.path.join(l0[:-1])

     import sys
     import os
     parts = appname.split(".")
     for base in sys.path:
         result = get(base, parts)
         if not get(base, parts) is None:
             return os.path.join(base, *parts)
     raise Exception("No such app: %s" % appname)

 }}}

 Combined, obviously, with a call to get_apppath instead of import_module
 in trans_real.py

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15084#comment:2>
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