Malcolm Tredinnick schrieb: > On Wed, 2008-03-05 at 15:32 +0100, Thomas Guettler wrote: > [...] > >> No, it gets imported more then once: (Answer of Malcolm): >> http://www.mail-archive.com/[EMAIL PROTECTED]/msg39061.html >> > > Read that carefully and you'll see the answer I have was "maybe, I'm not > sure" and it's only in some circumstances. I haven't done the analysis > to work out if we do reimport as part of the modpython path, although I > can't think why it would be reimporting. > I had this problem when I used mod_python. Now I use mod_wsgi and it does not happen. But if I run a test it still happens.
The first time __name__ is 'settings' and the second time it is 'myproj_foo.settings' ''' # added to settings.py import datetime import traceback fd=open('/tmp/import-settings.log', 'a') fd.write('%s settings gets imported __name__: %s\n%s' % (datetime.datetime.now(), __name__, ''.join(traceback.format_stack()))) fd.close() ''' # Command: ./manage.py test myproj.ModifyTest.testFoo ### output: 2008-03-05 16:38:39.945759 settings gets imported __name__: settings File "./manage.py", line 4, in <module> import settings # Assumed to be in the same directory. File "/localhome/modw/myproj_foo/settings.py", line 148, in <module> fd.write('%s settings gets imported __name__: %s\n%s' % (datetime.datetime.now(), __name__, ''.join(traceback.format_stack()))) 2008-03-05 16:38:39.950503 settings gets imported __name__: myproj_foo.settings File "./manage.py", line 11, in <module> execute_manager(settings) File "/localhome/modw/myproj_foo/django/core/management/__init__.py", line 272, in execute_manager utility.execute() File "/localhome/modw/myproj_foo/django/core/management/__init__.py", line 219, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/localhome/modw/myproj_foo/django/core/management/__init__.py", line 172, in fetch_command app_name = get_commands(self.user_commands, self.project_directory)[subcommand] File "/localhome/modw/myproj_foo/django/core/management/__init__.py", line 86, in get_commands for app_name in settings.INSTALLED_APPS: File "/localhome/modw/myproj_foo/django/conf/__init__.py", line 28, in __getattr__ self._import_settings() File "/localhome/modw/myproj_foo/django/conf/__init__.py", line 59, in _import_settings self._target = Settings(settings_module) File "/localhome/modw/myproj_foo/django/conf/__init__.py", line 85, in __init__ mod = __import__(self.SETTINGS_MODULE, {}, {}, ['']) File "/localhome/modw/myproj_foo/settings.py", line 148, in <module> fd.write('%s settings gets imported __name__: %s\n%s' % (datetime.datetime.now(), __name__, ''.join(traceback.format_stack()))) to Patryk: Look at your code again, it will never raise: ''' imported = False if imported: raise Exception, "already imported!" ... ''' -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---