On Mon, 2007-11-05 at 10:46 +0100, Thomas Güttler wrote:
> Hi,
> 
> settings.py gets imported twice. This is bad, if you want to
> set up the logging module, since you register the handler twice
> and you get all log messages twice.
[...]

It's actually fairly hard to avoid this for a variety of reasons. I
think we used to import it more than twice in some situations. Maybe we
still do. User-defined commands and processing the --settings option
becomes more fiddly, for example. So the answer is "don't rely on it
only being imported once".

If you need something to be only done once, no matter how many times it
is imported, you will need to set a flag somewhere. For example, you
could set a global variable that indicates you have already set up your
logging. Or set an indicator on some other class.

For logging, I would think that a call to getLogger('name') would
probably do the trick. If it returns nothing, you still need to do the
setup.

Regards,
Malcolm

-- 
If it walks out of your refrigerator, LET IT GO!! 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
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