#10966: Management module imports project_module, considered evil
----------------------------+-----------------------------------------------
 Reporter:  patrys          |       Owner:  nobody    
   Status:  new             |   Milestone:            
Component:  Core framework  |     Version:  1.0       
 Keywords:                  |       Stage:  Unreviewed
Has_patch:  0               |  
----------------------------+-----------------------------------------------
 I think Django's {{{core.management.setup_environ}}} should stop trying to
 import the project dir as if it was a module.

 Currently lines 337-341 read:
 {{{
 # Import the project module. We add the parent directory to PYTHONPATH to
 # avoid some of the path errors new users can have.
 sys.path.append(os.path.join(project_directory, os.pardir))
 project_module = import_module(project_name)
 sys.path.pop()
 }}}

 There is no explanation as to why it's useful to treat the project as a
 module. Also it assumes that:

  * there is no and will never be a python module using the same name in
 any of the current {{{sys.path}}} directories;
  * the directory name is a valid python module

 I see no value in treating a mere container dir as a module. If there is
 one, it could be clarified in the comment, currently it just states what
 the code does while not really explaining why.

 I actually have projects where the dir only contains settings.py and an
 empty {{{__init__.py}}} just to keep Django from crashing. If you don't
 import apps using your project name as a prefix, the {{{__init__.py}}}
 file is useless and you should be free to use any directory name you want.
 If you do use the project prefix, Python will already happily parse the
 top-level {{{__init__.py}}} for you and I see no point in importing it
 earlier in {{{core.management}}}.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/10966>
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