On Apr 15, 7:34 am, Ivan Sagalaev <man...@softwaremaniacs.org> wrote: > import logging > > import settings > from django.core.management import setup_environ > setup_environ(settings) > > from django.test.client import RequestFactory > > factory = RequestFactory() > factory.get('/') > logger = logging.getLogger('django.request') > logger.error('Error') > > The message doesn't show up in the console. Here's what's happening here: > > 1. setup_environ creates a lazy setting object > > 2. importing RequestFactory triggers import of django.core.handlers.wsgi > that creates a logger 'django.request' > > 3. after some time settings object is accessed for the first time and > gets initialized
I have been using setup_environ in my projects, and the lazy initialization in can cause some weird problems, for example if you do manual timing using: start = datetime.now() access settings print 'Used %s' % (datetime.now() - start) You might get weird results as accessing settings can change your timezone. Would it be wise that setup_environ() would access the settings so that they are no more lazy? Or does this cause other problems? - Anssi -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.