Re: Decoupling between projects and app in 4-part tutorial.

2009-01-13 Thread felix
this was for me also a slight trick to learn.  I got more from blog posts
than the docs
(and I love the django docs)

the trick is that your PYTHONPATH (and don't forget the python path of your
deployment server)
should point to the dir above your project dir and the dir above your apps
dir.


I have
echo $PYTHONPATH
/Users/crucial/Sites/gitpo.git/djapps:/Users/crucial/Sites/gitpo.git/pluggables

djapps
   app1
   app2
pluggables
   thirdpartyapp1
   thirdpartyapp2

site1
   manage.py
site2
   manage.py

site1www
   images


so in development when I run site1, due to PYTHONPATH I also have djapps and
pluggables in my path

from app1.models import *



(I agree keeping the intro tutorial very simple is best.
perhaps it could then link to a best practices of folder layout so that you
can grow
  when I try out a system I am really on a first date.
I don't want to know about the maintenance issues. )




On Sun, Jan 11, 2009 at 10:41 PM, dahpgjgamgan wrote:

>
> Hi,
>
> In the 4-part tutorial on Django's main site, there's a lot of advice
> on how to decouple apps and projects, but when I look at the import
> statements in most of the tutorial's files, it's always "from
> projectname.appname import ." - not very decoupled for me. Am
> I missing something, is there a good reason why those imports look
> like that and not simply "from appname... import ..."?
>
> Thanks!
>
> >
>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Decoupling between projects and app in 4-part tutorial.

2009-01-13 Thread Malcolm Tredinnick

On Tue, 2009-01-13 at 08:53 -0800, dahpgjgamgan wrote:
[...]
> > People experienced in Python realise that import statements are
> > flexible, so what's written in the tutorial is only a guide. People
> > needing to follow every line of code in the tutorial and just learning
> > Python don't need the extra baggage of worrying about that stuff in the
> > first tutorial they do.
> 
> So making the imports don't include project name would make them more
> worried?

No. It will make precisely no difference. Which is why claims about how
terrible this all is are such low-value.

Malcolm



--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Decoupling between projects and app in 4-part tutorial.

2009-01-13 Thread dahpgjgamgan

On Jan 13, 1:51 am, Malcolm Tredinnick 
wrote:

> [...]
>
> Look, if you aren't going to be moving the applications around, the
> imports in the tutorial aren't horrible. It's the beginner's tutorial.

That's a big if, regarding that tutorial does stress decoupling
between project and apps on several occasions.

> People experienced in Python realise that import statements are
> flexible, so what's written in the tutorial is only a guide. People
> needing to follow every line of code in the tutorial and just learning
> Python don't need the extra baggage of worrying about that stuff in the
> first tutorial they do.

So making the imports don't include project name would make them more
worried?

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Decoupling between projects and app in 4-part tutorial.

2009-01-12 Thread Malcolm Tredinnick

On Sun, 2009-01-11 at 16:53 -0800, Greg Aumann wrote:
[...]
> I am wondering why the tutorial teaches this bad practice when there
> is so much emphasis in Django on reusable apps.

When you could instead be wondering if it really is truly bad practice
or just alternative practice and a reasonable compromise for an
introductory process. Or, you know, just learning Django and not
sweating the little stuff.

Look, if you aren't going to be moving the applications around, the
imports in the tutorial aren't horrible. It's the beginner's tutorial.
People experienced in Python realise that import statements are
flexible, so what's written in the tutorial is only a guide. People
needing to follow every line of code in the tutorial and just learning
Python don't need the extra baggage of worrying about that stuff in the
first tutorial they do.

Every single instructional document you read contains compromises.

Regards,
Malcolm


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Decoupling between projects and app in 4-part tutorial.

2009-01-11 Thread Greg Aumann

On Jan 12, 5:41 am, dahpgjgamgan  wrote:
> In the 4-part tutorial on Django's main site, there's a lot of advice
> on how to decouple apps and projects, but when I look at the import
> statements in most of the tutorial's files, it's always "from
> projectname.appname import ." - not very decoupled for me.

You can leave the mysite off various things. So in the settings file
the INSTALLED_APPS you can put polls instead of mysite.polls. The same
for the import statements. This works because the code is run in the
mysite directory and python automatically finds modules in the
directory the code is running in. In other words python considers the
current working directory to be on the python path.

> Am I missing something, is there a good reason why those imports look
> like that and not simply "from appname... import ..."?

I am wondering why the tutorial teaches this bad practice when there
is so much emphasis in Django on reusable apps. It seems to me that
teaching the better way of leaving off the site directory requires no
code change but only a documentation change to the tutorial.

Even better would be making the backwards incompatible change of
removing the project directory from the python path to encourage
better practice.

But I also am just learning Django so probably have failed to consider
something important.

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---