Ticket #27541: manifest_storage.patch

File manifest_storage.patch, 1.6 KB (added by Ryan Lopopolo, 8 years ago)

manifest_storage indirection

  • django/contrib/staticfiles/storage.py

    diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py
    index a1d7875..360d0d3 100644
    a b class ManifestFilesMixin(HashedFilesMixin):  
    300300    manifest_version = '1.0'  # the manifest format standard
    301301    manifest_name = 'staticfiles.json'
    302302
    303     def __init__(self, *args, **kwargs):
     303    def __init__(self, manifest_storage=None, *args, **kwargs):
    304304        super(ManifestFilesMixin, self).__init__(*args, **kwargs)
     305        if manifest_storage is None:
     306            manifest_storage = self
     307        self.manifest_storage = manifest_storage
    305308        self.hashed_files = self.load_manifest()
    306309
    307310    def read_manifest(self):
    308311        try:
    309             with self.open(self.manifest_name) as manifest:
     312            with self.manifest_storage.open(self.manifest_name) as manifest:
    310313                return manifest.read().decode('utf-8')
    311314        except IOError:
    312315            return None
    class ManifestFilesMixin(HashedFilesMixin):  
    336339
    337340    def save_manifest(self):
    338341        payload = {'paths': self.hashed_files, 'version': self.manifest_version}
    339         if self.exists(self.manifest_name):
    340             self.delete(self.manifest_name)
     342        if self.manifest_storage.exists(self.manifest_name):
     343            self.manifest_storage.delete(self.manifest_name)
    341344        contents = json.dumps(payload).encode('utf-8')
    342         self._save(self.manifest_name, ContentFile(contents))
     345        self.manifest_storage._save(self.manifest_name, ContentFile(contents))
    343346
    344347
    345348class _MappingCache(object):
Back to Top