On 8/6/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> On Sun, 2006-08-06 at 07:05 +0800, limodou wrote:
> > If I write my own scripts which will use models and deal with them,
> > but I also need to set PYTHONPATH and DJANGO_SETTING_MODULE evn
> > variables. I know manage.py can do this thing, and I think why cann't
> > I use it to run my scripts which need these env variables setting. So
> > If I can run my scripts just like:
> >
> > manage.py run myscripts.py
>
> Rather than adding another feature to manage.py, I moved the environment
> setup lines out into their own function (in r3527). Now, if you want to
> write a script that operates in the same environment as manage.py would
> set up, you call
>
>         django.core.management.setup_environ()
>
> early on in your main method and it should work seamlessly.
>
> This is probably more natural development practice in any case, since it
> means that you run the "natural" program (myscripts.py) when using your
> code, rather than having to remember to call some other program with
> your program's filename, etc. It leaves myscripts.py in charge of
> things, pulling in pieces from other places as required. Easier to debug
> (tracebacks have two or three less levels), too.
>
> Regards,
> Malcolm
>
Wonderful!


-- 
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to