Problem solved: Turns out that I had a import django.core.files.storage
line in my settings.py which triggered the initialization of default_storage before my own settings.py was parsed. Obviously, the development server has a different import order than modpython ... /Raik On Jan 12, 7:54 pm, raik <raik.gruenb...@crg.es> wrote: > Hi there, > > I first posted this to the user list but this now looks more and more > like a bug -- please correct me if I am wrong. > > I am using a FileField to store user-uploaded files on the server. My > setup works with the development server but raises a > SuspiciousOperation error when I switch to apache2. Here is my setup: > > settings.py: > MEDIA_ROOT = '/var/www/static/' > MEDIA_URL = '/static/' > ... > > /etc/apache2/httpd.conf: > <Location "/"> > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE brickit.settings > PythonDebug On > PythonOption django.root > PythonPath "['/home/raik/data/py'] + sys.path" > </location> > <location "/media"> > SetHandler None > </location> > <location "/static"> > SetHandler None > </location> > > The error occurs in /home/raik/data/py/django/core/file/storage.py in > line 207. The code fragment is: > def path(self, name): > try: > path = safe_join(self.location, name) > except ValueError: > raise SuspiciousOperation("...") > return os.path.normpath(path) > > I traced the problem to the value of default_storage.location in core/ > files/storage.py. In the development server, location points to > settings.MEDIA_ROOT '/var/www/static' as expected. Yet, in the apache > process, location points to an empty string "". The weird thing is > that, at the time of initialization of storage py, settings.MEDIA_ROOT > is indeed "". However, the django debug screen later reports the > correct settings.MEDIA_ROOT = '/var/www/static'. Looks to me as if > django only finds and reads my settings.py *after* storage.py is > initialized. That's why it looks like a bug to me. Shall I post it? > Any ideas for a workaround? > > Thanks in advance! > Raik --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---