Opened 13 years ago

Closed 13 years ago

#17689 closed Bug (fixed)

CachedFilesMixin causes ValueError when provided with a path to url()

Reported by: tkaemming Owned by: nobody
Component: contrib.staticfiles Version: 1.4-alpha-1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

For example, trying to set window.__admin_media_prefix__ in admin/base.html causes this error.

Here's the offending template tag:
https://code.djangoproject.com/browser/django/trunk/django/contrib/admin/templates/admin/base.html#L9

Traceback (I cut out the render bits and only left the parts significant to the issue at hand):

[pid: 23479|app: 0|req: 2/11] 127.0.0.1 () {40 vars in 780 bytes} [Tue Feb 14 19:42:53 2012] GET /admin/ => generated 168 bytes in 430 msecs (HTTP/1.0 500) 4 headers in 174 bytes (1 switches on core 0)
Internal Server Error: /admin/
Traceback (most recent call last):
  File "/srv/versions/development/src/django/django/contrib/staticfiles/templatetags/staticfiles.py", line 13, in static
    return staticfiles_storage.url(path)
  File "/srv/versions/development/src/django/django/contrib/staticfiles/storage.py", line 111, in url
    hashed_name = self.hashed_name(clean_name).replace('\\', '/')
  File "/srv/versions/development/src/django/django/contrib/staticfiles/storage.py", line 74, in hashed_name
    (clean_name, self))
ValueError: The file 'admin/' could not be found with <example.utils.storage.CachedS3BotoStorage object at 0x8ce99cc>.

I've attached a patch that prevents CachedStaticMixin from attempting to hash names ending in a path separator (forward slash only), incl. tests.

Attachments (1)

ticket-17689.diff (2.2 KB ) - added by tkaemming 13 years ago.

Download all attachments as: .zip

Change History (3)

by tkaemming, 13 years ago

Attachment: ticket-17689.diff added

comment:1 by tkaemming, 13 years ago

Version: 1.31.4-alpha-1

comment:2 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: newclosed

In [17535]:

Fixed #17689 -- Stopped the CachedStaticFilesStorage from trying to hash paths that aren't files.

Note: See TracTickets for help on using tickets.
Back to Top