django.contrib.staticfiles.finders.find can return [None] if a file is not found with a custom finder
|Reported by:||paulswartz||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
If a custom Finder returns None when it can't find a file (when all=True), the find() function wraps it in a list and adds it to the possible return values instead of recognizing it as a not-found file.
It results in this not-too-useful exception:
Traceback (most recent call last): File "/home/ec2-user/AdmitCloud/virtualenv/lib/python2.6/site-packages/django/core/handlers/base.py", line 111, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/home/ec2-user/AdmitCloud/virtualenv/lib/python2.6/site-packages/django/contrib/staticfiles/views.py", line 38, in serve document_root, path = os.path.split(absolute_path) File "/home/ec2-user/AdmitCloud/virtualenv/lib64/python2.6/posixpath.py", line 82, in split i = p.rfind('/') + 1 AttributeError: 'list' object has no attribute 'rfind'
If you're writing the custom Finder, the quick fix is to return  instead of None regardless of the all setting. I noticed it on 1.3, but it looks like it's still a problem in master. I'll throw a patch up on GitHub shortly.
Change History (5)
comment:1 Changed 4 years ago by paulswartz
- Has patch set
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset