I'm using Django 1.0.3, Apache 2.2, Python 2.5 and Ubuntu 9.04 (a
recent upgrade).

When I try to delete an image (specifically I'm deleting an instance
of a photo model that contains an imagefield) I get an OSError,
"[Errno 1] Operation not permitted"

The first thing I tried was checking the permissions in Ubuntu,
they're set to allow write access for everyone.

I tried to deleting the image file from an Ubuntu command line and
discovered that I could do so.

I tried deleting the image file from python using os.remove, that
worked fine.

I tried using 'python manage.py shell' and using os.remove to delete
the file, that worked fine.

I tried editing django/core/files/storage.py to output the results of
an os.access() check to show that I did have write access to the image
file immediately before attempting the os.remove. It showed that I had
write access to the image file.

I tried editing django/core/files/storage.py to use fcntl.lock to lock
the image file (to make sure no other process had locked the image
file) and it showed that the image file was not locked.

I tried editing django/core/files/storage.py to use os.chmod to grant
write access to the image file and got the same error message as
before, only now it occured at the os.chmod() rather than at the
os.remove().

I'm guessing that this problem has something to do with my recent
upgrade to Django 9.04, but that's just a guess as I can't even figure
out exactly what is going wrong.

I would appreciate any suggestions as to what to try next. Thank you
for your input.

Full error message follows:

OSError at /dar/repair/delete/1864/

[Errno 1] Operation not permitted: '/home/ase/Desktop/idms_project/
idms/media/dar/J0484_-_2009-03-04_008.jpg'

Request Method:         POST
Request URL:    http://localhost/dar/repair/delete/1864/
Exception Type:         OSError
Exception Value:

[Errno 1] Operation not permitted: '/home/ase/Desktop/idms_project/
idms/media/dar/J0484_-_2009-03-04_008.jpg'

Exception Location:     /usr/lib/python2.5/site-packages/django/core/
files/storage.py in delete, line 199
Python Executable:      /usr/bin/python
Python Version:         2.5.4
Python Path:    ['/usr/lib/python2.5/site-packages', '/home/ase/Desktop/
idms_project', '/home/ase/Desktop/idms_project/idms', '/usr/lib/
python2.5/site-packages/setuptools-0.6c11-py2.5.egg', '/usr/lib/
python2.5/site-packages/pisa-3.0.32-py2.5.egg', '/usr/lib/python2.5',
'/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/
lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages',
'/usr/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages/
Numeric', '/usr/lib/python2.5/site-packages/PIL', '/usr/lib/python2.5/
site-packages/gst-0.10', '/usr/lib/pymodules/python2.5', '/usr/lib/
python2.5/site-packages/gtk-2.0', '/usr/lib/pymodules/python2.5/
gtk-2.0', '/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode']
Server time:    Wed, 25 Nov 2009 21:48:48 +0000

Environment:

Request Method: POST
Request URL: http://localhost/dar/repair/delete/1864/
Django Version: 1.0.3
Python Version: 2.5.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'idms.general',
 'idms.ipl',
 'idms.doc',
 'idms.ssi',
 'idms.fsr',
 'idms.dar',
 'idms.dmm',
 'idms.tdm',
 'idms.ssir',
 'idms.nsr',
 'idms.ssir.templatetags',
 'idms.ffd']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'django.middleware.transaction.TransactionMiddleware')


Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
in get_response
  91.                 response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/lib/python2.5/site-packages/django/contrib/auth/
decorators.py" in __call__
  78.             return self.view_func(request, *args, **kwargs)
File "/home/ase/Desktop/idms_project/idms/dar/views.py" in
repair_delete
  284.             repair.delete()
File "/home/ase/Desktop/idms_project/idms/../idms/dar/models.py" in
delete
  192.             super(Repair,self).delete()
File "/usr/lib/python2.5/site-packages/django/db/models/base.py" in
delete
  476.         delete_objects(seen_objs)
File "/usr/lib/python2.5/site-packages/django/db/models/query.py" in
delete_objects
  909.             signals.post_delete.send(sender=cls,
instance=instance)
File "/usr/lib/python2.5/site-packages/django/dispatch/dispatcher.py"
in send
  166.             response = receiver(signal=self, sender=sender,
**named)
File "/usr/lib/python2.5/site-packages/django/db/models/fields/
files.py" in delete_file
  183.                 file.delete(save=False)
File "/usr/lib/python2.5/site-packages/django/db/models/fields/
files.py" in delete
  230.         super(ImageFieldFile, self).delete(save)
File "/usr/lib/python2.5/site-packages/django/db/models/fields/
files.py" in delete
  99.         self.storage.delete(self.name)
File "/usr/lib/python2.5/site-packages/django/core/files/storage.py"
in delete
  199.             os.remove(name)

Exception Type: OSError at /dar/repair/delete/1864/
Exception Value: [Errno 1] Operation not permitted: '/home/ase/Desktop/
idms_project/idms/media/dar/J0484_-_2009-03-04_008.jpg'

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to