google-code-export / django-photologue

Automatically exported from code.google.com/p/django-photologue
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

storage compatiblity for gallery uploads #105

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. setup s3 as default storage 
2. add a galleryupload object in the admin

What is the expected output? What do you see instead?

I get the NotImplemented Exception rather than processing the zip file.

Please use labels and text to provide additional information.

Environment:

Request Method: POST
Request URL: http://localhost:8000/admin/photologue/galleryupload/add/
Django Version: 1.0.2 final
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'photologue',
 'tagging']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.transaction.TransactionMiddleware')

Traceback:
File
"/Library/Python/2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/hand
lers/base.py"
in get_response
  86.                 response = callback(request, *callback_args,
**callback_kwargs)
File
"/Library/Python/2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/contrib/a
dmin/sites.py"
in root
  157.                 return self.model_page(request, *url.split('/', 2))
File
"/Library/Python/2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/views/dec
orators/cache.py"
in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File
"/Library/Python/2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/contrib/a
dmin/sites.py"
in model_page
  176.         return admin_obj(request, rest_of_url)
File
"/Library/Python/2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/contrib/a
dmin/options.py"
in __call__
  191.             return self.add_view(request)
File
"/Library/Python/2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/transa
ction.py"
in _commit_on_success
  238.                 res = func(*args, **kw)
File
"/Library/Python/2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/contrib/a
dmin/options.py"
in add_view
  494.                 self.save_model(request, new_object, form, change=False)
File
"/Library/Python/2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/contrib/a
dmin/options.py"
in save_model
  376.         obj.save()
File "apps/photologue/models.py" in save
  90.         gallery = self.process_zipfile()
File "apps/photologue/models.py" in process_zipfile
  95.         if os.path.isfile(self.zip_file.path):
File
"/Library/Python/2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/db/models
/fields/files.py"
in _get_path
  49.         return self.storage.path(self.name)
File
"/Library/Python/2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/file
s/storage.py"
in path
  81.         raise NotImplementedError("This backend doesn't support
absolute paths.")

Exception Type: NotImplementedError at /admin/photologue/galleryupload/add/
Exception Value: This backend doesn't support absolute paths.

I imagine the culprit is self.zip_file.path but I don't know how to fix it
offhand.

Original issue reported on code.google.com by mand...@gmail.com on 19 Feb 2009 at 6:31

GoogleCodeExporter commented 9 years ago
Are you using the latest rev from the 3.x branch and the latest ImageKit 
release?

Original comment by justin.d...@gmail.com on 19 Feb 2009 at 6:36

GoogleCodeExporter commented 9 years ago
Yep

Original comment by mand...@gmail.com on 19 Feb 2009 at 6:41

GoogleCodeExporter commented 9 years ago

cat apps/photologue/__init__.py
VERSION = (2, 1)

Original comment by mand...@gmail.com on 19 Feb 2009 at 6:42

GoogleCodeExporter commented 9 years ago
Or better yet:

svn info
Path: .
URL: http://django-photologue.googlecode.com/svn/branches/3.x/photologue
Repository Root: http://django-photologue.googlecode.com/svn
Repository UUID: 2d8b3452-2338-0410-8a60-9550768eb463
Revision: 384
Node Kind: directory
Schedule: normal
Last Changed Author: justin.driscoll
Last Changed Rev: 381
Last Changed Date: 2009-01-28 07:53:08 -0600 (Wed, 28 Jan 2009)

Original comment by mand...@gmail.com on 19 Feb 2009 at 6:43

GoogleCodeExporter commented 9 years ago
and django-imagekit-bd418da34a46.zip

Original comment by mand...@gmail.com on 19 Feb 2009 at 6:56

GoogleCodeExporter commented 9 years ago
I see whats going on. You have S3 set as the default storage but we don't want 
to be 
saving the zip file to S3 (waste of bandwidth and service fees) so we need to 
explicitly set the storage class on the GalleryUpload model to the standard 
file 
system storage class. I've updated the 3x branch to do this in r385 but I 
haven't had 
a chance to test this at all. Please let me know if this works.

Original comment by justin.d...@gmail.com on 20 Feb 2009 at 2:14

GoogleCodeExporter commented 9 years ago
Ok, I will try this out and get back to you ... sorry about the delay.

Original comment by mand...@gmail.com on 2 Mar 2009 at 2:16

GoogleCodeExporter commented 9 years ago
Now I'm getting an Exception ...

$ python manage.py runserver
Validating models...
Unhandled exception in thread started by <function inner_run at 0x724ab0>
Traceback (most recent call last):
  File
"/Library/Python/2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/mana
gement/commands/runserver.py",
line 48, in inner_run
    self.validate(display_num_errors=True)
  File
"/Library/Python/2.5/site-packages/Django-1.0.2_final-py2.5.egg/django/core/mana
gement/base.py",
line 250, in validate
    raise CommandError("One or more models did not validate:\n%s" % error_text)
django.core.management.base.CommandError: One or more models did not validate:
photologue.galleryupload: "zip_file": FileFields require an "upload_to" 
attribute.

Before I go and try adding an empty upload_to attribute I thought I'd post this.

Original comment by mand...@gmail.com on 4 Mar 2009 at 5:24

GoogleCodeExporter commented 9 years ago
Thanks, an empty upload_to attribute should fix it and I'll patch this soon. 
For some reason I was under the 
impression they had removed upload_to as a required keyword argument when they 
implemented storages 
classes (there's some redundancy there).

Original comment by justin.d...@gmail.com on 4 Mar 2009 at 10:34

GoogleCodeExporter commented 9 years ago
Actually I tried an empty upload_to="" but django didn't like that either.  I 
ended
up using upload_to="photologue".

Original comment by mand...@gmail.com on 6 Mar 2009 at 2:28

GoogleCodeExporter commented 9 years ago
Windows doesn't store temporary files in '/tmp'. Patch is available at
http://code.google.com/p/mesawarati/source/detail?r=10

Original comment by petar.ma...@gmail.com on 6 Mar 2009 at 6:34

GoogleCodeExporter commented 9 years ago
Sorry guys. I misread the FileSystemStorage class, threw some code at this and 
didn't 
test it. This whole mess should be fixed in r386.

Original comment by justin.d...@gmail.com on 6 Mar 2009 at 7:01

GoogleCodeExporter commented 9 years ago
I think you forgot to explicitly pass the location parameter to 
FileSystemStorage(),
as I've done in http://code.google.com/p/mesawarati/source/detail?r=10

Otherwise, the temporary *.zip files will be recorded to SETTINGS.MEDIA_ROOT.

Original comment by petar.ma...@gmail.com on 6 Mar 2009 at 7:26

GoogleCodeExporter commented 9 years ago
I left the default but passed the upload_to parameter which will save them in 
[settings.MEDIA_ROOT]/photologue/tmp/. I think it's best to keep them saved 
within 
the MEDIA_ROOT directory as it's most likely already writable. The whole /tmp 
thing 
was a mistake.

Original comment by justin.d...@gmail.com on 6 Mar 2009 at 7:33