def get_status_key(self, instance): """Generates a key used to set a status on a field""" key_id = "inst_%s" % id(instance) if instance.pk is None else instance.pk return "%s.%s-%s-%s" % (instance._meta.app_label, get_model_name(instance), key_id, self.field.name)
def get_status_key(self, instance): """Generates a key used to set a status on a field""" key_id = "inst_%s" % id( instance) if instance.pk is None else instance.pk return "%s.%s-%s-%s" % (instance._meta.app_label, get_model_name(instance), key_id, self.field.name)
def get_output_file(self, in_file, instance, field, **kwargs): """Creates a temporary file. With regular `FileSystemStorage` it does not need to be deleted, instaed file is safely moved over. With other cloud based storage it is a good idea to set `delete=True`.""" return NamedTemporaryFile( mode='rb', suffix='_%s_%s%s' % (get_model_name(instance), field.name, self.get_ext()), delete=False)
def _get_status(self, instance, status_key=None): status_key = status_key or self.get_status_key(instance) status = { 'app_label': instance._meta.app_label, 'model_name': get_model_name(instance), 'pk': instance.pk, 'field_name': self.field.name, 'state': 'ready' } current_status = cache.get(status_key, None) if current_status is not None: status.update(current_status) return status_key, status
def get_output_file(self, in_file, instance, field, **kwargs): """Creates a temporary file. With regular `FileSystemStorage` it does not need to be deleted, instaed file is safely moved over. With other cloud based storage it is a good idea to set `delete=True`.""" return NamedTemporaryFile(mode='rb', suffix='_%s_%s%s' % ( get_model_name(instance), field.name, self.get_ext()), delete=False)