Skip to content

Instantly share code, notes, and snippets.

Created January 6, 2013 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4468776 to your computer and use it in GitHub Desktop.
Save anonymous/4468776 to your computer and use it in GitHub Desktop.
Custom storage for Django Pipeline with cached-files + S3 storage via boto
from boto.utils import parse_ts
from django.contrib.staticfiles.storage import CachedFilesMixin
from pipeline.storage import PipelineMixin
from storages.backends.s3boto import S3BotoStorage
class S3PipelineStorage(PipelineMixin, CachedFilesMixin, S3BotoStorage):
# Fix for django-storages can't parse datetime error
# https://github.com/ulyssesv/django-cached-s3-storage/blob/master/cached_s3_storage.py
def modified_time(self, name):
name = self._normalize_name(self._clean_name(name))
entry = self.entries.get(name)
if entry is None:
entry = self.bucket.get_key(self._encode_name(name))
# Parse the last_modified string to a local datetime object.
return parse_ts(entry.last_modified)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment