Exemplo n.º 1
0
 def get_source_cache(self, create=False, update=False):
     modtime = self.get_source_modtime()
     update_modified = modtime and utils.fromtimestamp(modtime)
     if update:
         update_modified = update_modified or utils.now()
     return models.Source.objects.get_file(
         create=create, update_modified=update_modified,
         storage=self.source_storage, name=self.name,
         check_cache_miss=self.thumbnail_check_cache_miss)
Exemplo n.º 2
0
 def get_thumbnail_cache(self, thumbnail_name, create=False, update=False):
     modtime = self.get_thumbnail_modtime(thumbnail_name)
     update_modified = modtime and utils.fromtimestamp(modtime)
     if update:
         update_modified = update_modified or utils.now()
     source = self.get_source_cache(create=True)
     return models.Thumbnail.objects.get_file(
         create=create, update_modified=update_modified,
         storage=self.thumbnail_storage, source=source, name=thumbnail_name,
         check_cache_miss=self.thumbnail_check_cache_miss)
Exemplo n.º 3
0
 def get_source_cache(self, create=False, update=False):
     if self.remote_source:
         return None
     modtime = self.get_source_modtime()
     update_modified = modtime and utils.fromtimestamp(modtime)
     if update:
         update_modified = update_modified or utils.now()
     return models.Source.objects.get_file(
         create=create, update_modified=update_modified,
         storage=self.source_storage, name=self.name,
         check_cache_miss=self.thumbnail_check_cache_miss)
Exemplo n.º 4
0
 def get_source_cache(self, create=False, update=False):
     if self.remote_source:
         return None
     if hasattr(self, '_source_cache') and not update:
         if self._source_cache or not create:
             return self._source_cache
     modtime = self.get_source_modtime()
     update_modified = modtime and utils.fromtimestamp(modtime)
     if update:
         update_modified = update_modified or utils.now()
     self._source_cache = models.Source.objects.get_file(
         create=create, update_modified=update_modified,
         storage=self.source_storage, name=self.name,
         check_cache_miss=self.thumbnail_check_cache_miss)
     return self._source_cache
Exemplo n.º 5
0
    def get_thumbnail_cache(self, thumbnail_name, create=False, update=False):
        if self.remote_source:
            return None

        thumbnail_cache_hash = utils.get_storage_hash(thumbnail_name)
        if self.thumbnail_cache.has_key(thumbnail_cache_hash):
            return self.thumbnail_cache[thumbnail_cache_hash]

        modtime = self.get_thumbnail_modtime(thumbnail_name)
        update_modified = modtime and utils.fromtimestamp(modtime)
        if update:
            update_modified = update_modified or utils.now()

        source = self.get_source_cache(create=True)

        thumbnail_cache = models.Thumbnail.objects.get_file(
            create=create, update_modified=update_modified,
            storage=self.thumbnail_storage, source=source, name=thumbnail_name,
            check_cache_miss=self.thumbnail_check_cache_miss)
        if thumbnail_cache:
            self.thumbnail_cache[thumbnail_cache_hash] = thumbnail_cache
        return thumbnail_cache