On Nov 27, 1:06 am, Flo Ledermann <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> my name is flo, i am relatively new to django but would consider
> myself an experienced web developer. I am sorry if this has been asked
> hundreds of times, but after doing somewhat extensive research i still
> would like to gain some insight into the design decisions involved in
> how manage.py and the project path structure is set up by django. I
> found that django is a very well-designed toolkit in every aspect i
> researched so far, but this is the only area where i still scratch my
> head and miss the clarity and state-of-the-art-ness found in all other
> areas of django.
>
> If i get it right, manage.py adds the parent path of its location in
> the file system to the pythonpath (actually this is done in
> django.core.management.setup_environ() by calling sys.path.append
> (os.path.join(project_directory, os.pardir))). This results in a
> comfortable initial way of experimenting with django. However, i found
> that it does not actuall give me a full pythonpath in the parent
> folder - if i add additional packages there, i have to explicitly set
> the --pythonpath parameter when calling manage.py to the parent dir of
> manage.py.

I analysed this a long time ago and posted it but cant find post to
reference. Although it puts parent in sys.path, it does it only long
enough to import site package root. It then removes parent from
sys.path again. Thus why sibling directories can't be imported
normally.

> Furthermore, another feature that supposedly should help newbies makes
> things even more complicated: the folder that manage.py is in is also
> somehow treated as a part of pythonpath, so that packages can be
> referenced in the source starting from the root package (mysite.myapp)
> or as a relative path (myapp).

Directory manage.py is in is a source for modules because when Python
command line is run it will use current working directory implicitly
for module imports.

> This "helps" local development for a
> kick start, but mayhem breaks loose once you transfer your code to a
> different environment where the project is not launched through
> manage.py. Another strange side effect is that i cannot name my source
> directory (the one above "mysite") "django" (which would be my
> personal preference) because, for some reasons i could not clearly
> resolve, this causes a conflict with the main django namespace,
> although the pythonpath should start *inside* this folder.
>
> It would be great if somebody more experienced (which i guess most of
> you are) could fill me in with the reasons for this design and clarify
> the concepts working under the hood so that i can build a clear mental
> model of how pythonpath et al.

I'd like to hear the explanation as well. I have always found it quite
odd and this odd behaviour always causes issues when people then try
and run same stuff under mod_python/mod_wsgi.

Although the documentation talks about needing to add both directories
explicitly to PythonPath for mod_python, I still personally don't feel
it is explained clearly enough. And yes I have raised the issue of
clarity of the documentation before within discussions of tickets
related to the problem, but it was felt by others to be adequate. Yet
every week there are still questions about how to setup PythonPath
properly which one sees the same old people having to answer again and
again. :-(

Graham

> is set up - on the local development
> machine and on a server environment. In the case that all this is not
> following a concept as clear as the rest of django, i would personally
> vote for refactoring the setup in a way that hints newbies in a more
> deployment-friendly way of setting up their projects from the
> beginning, instead of causing refactoring troubles later on.
>
> All the best and thanks to creators and contributors for a great
> framework!
>
> flo ledermannhttp://www.floledermann.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to