On Jul 31, 5:24 pm, Giorgio Salluzzo <[EMAIL PROTECTED]> wrote: > I know very well this problem because in my company we had the same > some months ago. > > I investigated a lot also on modpython list and it is a known "bug| > strange behavior", you can find threads really old about it.
Huh. What bug, strange behaviour in mod_python? What old threads? Older versions of mod_python did have some module importing issues but the OP is using latest version. Looking again at the original error, the problem possibly turns out to be more subtle. What it may come down to is a bad choice of site name. The name they have chosen is 'syslog' which clashes with a standard Python module of the same name. The result of this may be the same as saying: >>> import syslog >>> import syslog.settings Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: No module named settings If mod_python has indirectly caused the standard 'syslog' module to be imported even before sys.path is adjusted, when Django goes to import 'syslog.settings', Python will see that 'syslog' is already imported and try to import 'settings' as a sub module from the 'syslog'. Problem is it will not exist and 'syslog' isn't a package so it would also fail in attempt to import 'settings' from a package directory for standard 'syslog' module. Thus, I'd probably suggest a different name be chosen for the site than 'syslog'. > Because of it we changed to the fastest and "problems free" modwsgi. In this case mod_wsgi may not have helped. If the recipe in the mod_wsgi documentation was followed and site parent directory was appended to sys.path then the standard Python 'syslog' module would again have been found rather that the user package. Same problem would then ensue as standard 'syslog' module doesn't obviously have a submodule called 'settings'. The mod_wsgi recipe could be changed to use: sys.path.insert(0, "/some/path") On still has to be very careful about the name chosen for a site though and reversing the directory search order could cause problems in itself as any code wanting the standard 'syslog' module would now accidentally pick up the site package. This raises a general question of whether one should always put additional module directories at the start or end of sys.path. It may be worthwhile for the Django documentation to state that one should never choose a site name which clashes with any standard Python module or common third party software. This could be a source of a lot of strange problems otherwise. Graham > www.modwsgi.org > > In the wiki page you can find also a Django page. > > On Jul 30, 3:18 pm, stereoit <[EMAIL PROTECTED]> wrote: > > > Hi, I'm having problem with mod_python. > > > EnvironmentError: Could not import settings 'syslog.settings' (Is it > > on sys.path? Does it have syntax errors?): No module named settings > > <<<< > > > I've developed small app for viewing syslog messages and it runs fine > > with following commands: > > > cd /srv/code/syslog/ > > export DJANGO_SETTINGS_MODULE=syslog.settings > > export PYTHONPATH=/srv/code/ > > /srv/code/python/bin/python manage.py runserver > > > I then tried to followhttp://www.djangoproject.com/documentation/modpython/ > > but I do not understand the concept of mysite and projects. Anyway > > here is what is in my virtualhost: > > > <Location "/"> > > SetHandler mod_python > > PythonHandler django.core.handlers.modpython > > SetEnv DJANGO_SETTINGS_MODULE syslog.settings > > PythonPath "['/srv/code'] + sys.path" > > PythonDebug On > > </Location> > > > Additional info: > > > ls /srv/code/syslog/ > > accounts filters frontend __init__.py __init__.pyc manage.py > > media settings.py settings.pyc site_media templates urls.py > > urls.pyc > > > Since this is running on RedHat4 I downloaded and compiled python > > 2.4.4 with > > ./configure --prefix=/srv/code/python/ > > mod_python with: > > ./configure --with-python=/srv/code/python/bin/python > > and copied django to > > cp -r django/ /srv/code/python/lib/python2.4/site-packages/ > > > I can run following just fine: > > $ export PYTHONPATH=/srv/code/ > > $ /srv/code/python/bin/python > > Python 2.4.4 (#1, Jul 30 2007, 11:43:39) > > [GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2 > > Type "help", "copyright", "credits" or "license" for more information. > > > >>> from django.core.handlers import modpython > > >>> from syslog import settings > > > I made sure everything is readable by chmod o+r -R syslog > > > Am I missing something? > > > Complete error listing: > > > MOD_PYTHON ERROR > > > ProcessId: 19772 > > Interpreter: 'syslog.telecom.dhl.com' > > > ServerName: 'syslog.telecom.dhl.com' > > DocumentRoot: '/srv/www/syslog.telecom.dhl.com/htdocs' > > > URI: '/' > > Location: '/' > > Directory: None > > Filename: '/srv/www/syslog.telecom.dhl.com/htdocs/' > > PathInfo: '' > > > Phase: 'PythonHandler' > > Handler: 'django.core.handlers.modpython' > > > Traceback (most recent call last): > > > File "/srv/code/python/lib/python2.4/site-packages/mod_python/ > > importer.py", line 1537, in HandlerDispatch > > default=default_handler, arg=req, silent=hlist.silent) > > > File "/srv/code/python/lib/python2.4/site-packages/mod_python/ > > importer.py", line 1229, in _process_target > > result = _execute_target(config, req, object, arg) > > > File "/srv/code/python/lib/python2.4/site-packages/mod_python/ > > importer.py", line 1128, in _execute_target > > result = object(arg) > > > File "/srv/code/python/lib/python2.4/site-packages/django/core/ > > handlers/modpython.py", line 177, in handler > > return ModPythonHandler()(req) > > > File "/srv/code/python/lib/python2.4/site-packages/django/core/ > > handlers/modpython.py", line 145, in __call__ > > self.load_middleware() > > > File "/srv/code/python/lib/python2.4/site-packages/django/core/ > > handlers/base.py", line 22, in load_middleware > > for middleware_path in settings.MIDDLEWARE_CLASSES: > > > File "/srv/code/python/lib/python2.4/site-packages/django/conf/ > > __init__.py", line 28, in __getattr__ > > self._import_settings() > > > File "/srv/code/python/lib/python2.4/site-packages/django/conf/ > > __init__.py", line 55, in _import_settings > > self._target = Settings(settings_module) > > > File "/srv/code/python/lib/python2.4/site-packages/django/conf/ > > __init__.py", line 83, in __init__ > > raise EnvironmentError, "Could not import settings '%s' (Is it on > > sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, > > e) > > > EnvironmentError: Could not import settings 'syslog.settings' (Is it > > on sys.path? Does it have syntax errors?): No module named settings --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---