def _render(self, context): instance = self.instance.resolve(context) field = self.field.resolve(context) geometry = self.geometry.resolve(context) options = {} for key, expr in self.options: noresolve = {u'True': True, u'False': False, u'None': None} value = noresolve.get(unicode(expr), expr.resolve(context)) if key == 'options': options.update(value) else: options[key] = value if settings.THUMBNAIL_DUMMY: thumbnail_url = DummyImageFile(geometry).url elif getattr(instance, field): thumbnail_url = THUMBNAIL_OPTIONS.build_url(instance, field, geometry, **options) elif not self.direct_usage: return self.nodelist_empty.render(context) if self.direct_usage: return thumbnail_url else: context.push() context[self.as_var] = thumbnail_url output = self.nodelist_file.render(context) context.pop() return output
def spawn_pre_cache_signal(sender, instance, created, **kwargs): configs = THUMBNAIL_OPTIONS.get(sender, {}) for config in configs: if config and config.precache: precache_sorl.send(sender=sender, instance=instance, model_config=config)