#15320 closed (wontfix)
staticfiles allows change of storage backend on collection but not when searching for files
Reported by: | Owned by: | ||
---|---|---|---|
Component: | contrib.staticfiles | Version: | 1.2 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
the culprits are:
finders.py:
64 for prefix, root in self.locations: 65 filesystem_storage = FileSystemStorage(location=root)
i need the FileSystemFinder to think that some files are always modified (i want to use them as overrides for a simple skin system.)
here's the storage i'm want to use (in django 1.2 and backported staticfiles, but everything is still applicaple):
import os.path from datetime import datetime from django.conf import settings from staticfiles.storage import StaticFileStorage class SkinAwareStorage(StaticFileStorage): def __init__(self, *args, **kwargs): super(SkinAwareStorage, self).__init__(*args, **kwargs) def modified_time(self, name): '''Always return current time for non-default skins''' p = self.path(name) if p.startswith(os.path.join(settings.STATIC_ROOT, 'skins')) \ and not p.startswith(os.path.join(settings.STATIC_ROOT, 'skins', 'default')): return datetime.now() else: return super(SkinAwareStorage, self).modified_time(name)
my suggestion: a STATICFILES_FINDER_STORAGE settings parameter.
Change History (4)
comment:1 by , 14 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
follow-up: 3 comment:2 by , 14 years ago
i was following the comment in django-staticfiles docs about finder interface being private - don't want an api change to blow up in my face when least expeceted. it's going to be a bit scary if you suddenly decide to change self.storages into something else.
anyway, thanks for the tip.
comment:3 by , 14 years ago
Replying to imbaczek@…:
i was following the comment in django-staticfiles docs about finder interface being private - don't want an api change to blow up in my face when least expeceted. it's going to be a bit scary if you suddenly decide to change self.storages into something else.
I understand your concern, and in fact I did some changes on the API in the last couple of months. Once 1.3 is out we can revisit the decision about making the finder API private.
This seems like an edge case to me (hence closing), but for the record that's pretty easy to do already:
Also, you probably don't want your
SkinAwareStorage
class to subclassStaticFileStorage
but simplyFileSystemStorage
since that's only used for the collection.