#18983: django.contrib.staticfiles.finders.find can return [None] if a file is
not
found with a custom finder
-------------------------------------+--------------------
Reporter: paulswartz | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+--------------------
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/18983>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.