Improvement for easy thumbnails backend #35

Closed
wants to merge 5 commits into
from

Conversation

Projects
None yet
5 participants
@michael54

Hi,
I improved the backend for easy thumbnails and changed that file's name to easythumbnails.py. It solves the import name problem. Also I added some more options for easy thumbnails.
To make uploaded file unique, I used uuid to generate a sub directory for local backend.

@skoczen

This comment has been minimized.

Show comment Hide comment
@skoczen

skoczen Nov 17, 2012

Owner

Hey Michael,

Thanks for the contribution! A couple questions:

  • What "import name problem" is this fixing?
  • Can you clarify the use of UPLOAD_DIR? Is this an easy_thumbnails standard? (I'm not an easy thumbnails user, myself)
  • Any reason you've added UPLOAD_DIR to local, instead of just the easy thumbnails backend?

Thanks!

Owner

skoczen commented Nov 17, 2012

Hey Michael,

Thanks for the contribution! A couple questions:

  • What "import name problem" is this fixing?
  • Can you clarify the use of UPLOAD_DIR? Is this an easy_thumbnails standard? (I'm not an easy thumbnails user, myself)
  • Any reason you've added UPLOAD_DIR to local, instead of just the easy thumbnails backend?

Thanks!

@michael54

This comment has been minimized.

Show comment Hide comment
@michael54

michael54 Nov 17, 2012

I tried to use the old easy thumbnails backend, but my django give me an error. No module named files in easy_thumbnails. I guess the reason is the backend file (easy_thumbnails.py) has the same name with app name of easy thumbnails, and this confuses python.
And I don't know why, but update_filename function doesn't work for easy thumbnails backend. So uploading images may have conflict filenames. Therefore I use uuid to generate a random string as a sub dir under UPLOAD_DIR to solve the potential filename conflict when using easy thumbnails.

I tried to use the old easy thumbnails backend, but my django give me an error. No module named files in easy_thumbnails. I guess the reason is the backend file (easy_thumbnails.py) has the same name with app name of easy thumbnails, and this confuses python.
And I don't know why, but update_filename function doesn't work for easy thumbnails backend. So uploading images may have conflict filenames. Therefore I use uuid to generate a random string as a sub dir under UPLOAD_DIR to solve the potential filename conflict when using easy thumbnails.

@skoczen

This comment has been minimized.

Show comment Hide comment
@skoczen

skoczen Nov 17, 2012

Owner

Hey Michael,

You should be able to get around that error by being more explicit in your import:

from ajaxuploader.backends import easy_thumbnails

If you want it and the easy_thumbnails library in the same file, you'd do something like:

from ajaxuploader.backends import easy_thumbnails as backend_thumbnails

Changing the name in this library breaks backwards compatibility for existing users, so I'm inclined against it.

As for the update_filename issue, it'd be great to get a test of what's failing, so we can fix it in the way that makes sense. At the least, I don't see anything that suggests you couldn't add UPLOAD_DIR to the easy_thumbnail backend, or even better, fix the issue with update_filename - it's there to solve exactly this problem!

For what it's worth, I'm using update_filename in a couple instances (mostly S3 backend), with custom overrides, and it's working for me. Would love better test coverage on this to help me be sure it works, but there's only so much time in the day.

Big takeaways:

  • unless there are other reasons I'm missing on the name, I'd prefer to leave it as easy_thumbails.
  • I'd prefer to see how update_filename is failing, and have the fix there. Your UUID idea's interesting, and could be a proposal to change the existing default if it's what's broken.

Thanks for helping make ajax-uploader better!

-Steven

Owner

skoczen commented Nov 17, 2012

Hey Michael,

You should be able to get around that error by being more explicit in your import:

from ajaxuploader.backends import easy_thumbnails

If you want it and the easy_thumbnails library in the same file, you'd do something like:

from ajaxuploader.backends import easy_thumbnails as backend_thumbnails

Changing the name in this library breaks backwards compatibility for existing users, so I'm inclined against it.

As for the update_filename issue, it'd be great to get a test of what's failing, so we can fix it in the way that makes sense. At the least, I don't see anything that suggests you couldn't add UPLOAD_DIR to the easy_thumbnail backend, or even better, fix the issue with update_filename - it's there to solve exactly this problem!

For what it's worth, I'm using update_filename in a couple instances (mostly S3 backend), with custom overrides, and it's working for me. Would love better test coverage on this to help me be sure it works, but there's only so much time in the day.

Big takeaways:

  • unless there are other reasons I'm missing on the name, I'd prefer to leave it as easy_thumbails.
  • I'd prefer to see how update_filename is failing, and have the fix there. Your UUID idea's interesting, and could be a proposal to change the existing default if it's what's broken.

Thanks for helping make ajax-uploader better!

-Steven

@bashu

This comment has been minimized.

Show comment Hide comment
@bashu

bashu Dec 14, 2012

Yep, the same problem here:
[skip]
from views import avatar_uploader
File "/Users/bashu/Projects/prodavalco/accounts/views.py", line 4, in
from ajaxuploader.backends import easy_thumbnails as backend_thumbnails
File "/Users/bashu/.virtualenvs/prodavalco/lib/python2.7/site-packages/ajaxuploader/backends/easy_thumbnails.py", line 4, in
from easy_thumbnails.files import get_thumbnailer
ImportError: No module named files

easy_thumbnails backend is broken! Forking...

bashu commented Dec 14, 2012

Yep, the same problem here:
[skip]
from views import avatar_uploader
File "/Users/bashu/Projects/prodavalco/accounts/views.py", line 4, in
from ajaxuploader.backends import easy_thumbnails as backend_thumbnails
File "/Users/bashu/.virtualenvs/prodavalco/lib/python2.7/site-packages/ajaxuploader/backends/easy_thumbnails.py", line 4, in
from easy_thumbnails.files import get_thumbnailer
ImportError: No module named files

easy_thumbnails backend is broken! Forking...

@applecat

This comment has been minimized.

Show comment Hide comment
@applecat

applecat Nov 11, 2013

+1 on import issue:

Traceback (most recent call last):
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/core/handlers/base.py", line 103, in get_response
    resolver_match = resolver.resolve(request.path_info)
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/core/urlresolvers.py", line 319, in resolve
    for pattern in self.url_patterns:
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/core/urlresolvers.py", line 347, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/core/urlresolvers.py", line 342, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Users/dimus/Projects/proactions.ru/proactions/urls.py", line 8, in <module>
    from ajaxuploader.backends import easy_thumbnails as backend_thumbnails
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/ajaxuploader/backends/easy_thumbnails.py", line 4, in <module>
    from easy_thumbnails.files import get_thumbnailer
ImportError: No module named files

+1 on import issue:

Traceback (most recent call last):
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/core/handlers/base.py", line 103, in get_response
    resolver_match = resolver.resolve(request.path_info)
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/core/urlresolvers.py", line 319, in resolve
    for pattern in self.url_patterns:
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/core/urlresolvers.py", line 347, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/core/urlresolvers.py", line 342, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/Users/dimus/Projects/proactions.ru/proactions/urls.py", line 8, in <module>
    from ajaxuploader.backends import easy_thumbnails as backend_thumbnails
  File "/Users/dimus/Venvs/proactions/lib/python2.7/site-packages/ajaxuploader/backends/easy_thumbnails.py", line 4, in <module>
    from easy_thumbnails.files import get_thumbnailer
ImportError: No module named files
@bee-keeper

This comment has been minimized.

Show comment Hide comment
@bee-keeper

bee-keeper Mar 4, 2014

Contributor

+1 on broken easy thumbnails backend. I have same stack trace as applecat above me. Would like to help out with this as time permits - is there any interest in getting this fixed?

Contributor

bee-keeper commented Mar 4, 2014

+1 on broken easy thumbnails backend. I have same stack trace as applecat above me. Would like to help out with this as time permits - is there any interest in getting this fixed?

@bashu

This comment has been minimized.

Show comment Hide comment
@bashu

bashu Mar 6, 2014

this is the only reason why I maintain my own fork...

bashu commented Mar 6, 2014

this is the only reason why I maintain my own fork...

@skoczen

This comment has been minimized.

Show comment Hide comment
@skoczen

skoczen Mar 8, 2014

Owner

Good news - 0.3.5 is going out this afternoon, and I've changed the backend to easythumbnails.py, mostly to reduce annoyance. This should resolve this issue - please reopen a new issue/pr if there are more!

Owner

skoczen commented Mar 8, 2014

Good news - 0.3.5 is going out this afternoon, and I've changed the backend to easythumbnails.py, mostly to reduce annoyance. This should resolve this issue - please reopen a new issue/pr if there are more!

@skoczen skoczen closed this Mar 8, 2014

@bee-keeper

This comment has been minimized.

Show comment Hide comment
@bee-keeper

bee-keeper Mar 18, 2014

Contributor

Thanks for this - works perfectly except for the return path omits the upload directory. I've issued a pull request to fix this issue.

Contributor

bee-keeper commented Mar 18, 2014

Thanks for this - works perfectly except for the return path omits the upload directory. I've issued a pull request to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment