Adds deletion of thumbnails and key value store references to the
        parent class implementation. Only called in Django < 1.2.5
173122
def delete_file(self, instance, sender, **kwargs):
        
        file_ = getattr(instance, self.attname)

        # If no other object of this type references the file, and it's not the
        # default value for future objects, delete it from the backend.
        query = Q(**{self.name: file_.name}) & ~Q(pk=instance.pk)
        qs = sender._default_manager.filter(query)

        if (file_ and file_.name != self.default and not qs):
            default.backend.delete(file_)
        elif file_:
            # Otherwise, just close the file, so it doesn't tie up resources.
            file_.close()
170201
def base_definition_post_delete(sender, instance, **kwargs):
    
    if hasattr(instance._state, '_deletion'):
        # Make sure to flatten abstract bases since Django
        # migrations can't deal with them.
        model = popattr(instance._state, '_deletion')
        for field in instance.base._meta.fields:
            perform_ddl('remove_field', model, field)
459614
def save(self, **kwargs):
        
        self.remove_file()
        if not self.image:
            self.generate(save=False)
        else:
            self.image.name = self.file()
        super(FormatedPhoto, self).save(**kwargs)
634734
def save(self, delete_zip_import=True, *args, **kwargs):
        
        super(BaseGallery, self).save(*args, **kwargs)
        if self.zip_import:
            zip_file = ZipFile(self.zip_import)
            for name in zip_file.namelist():
                data = zip_file.read(name)
                try:
                    from PIL import Image
                    image = Image.open(BytesIO(data))
                    image.load()
                    image = Image.open(BytesIO(data))
                    image.verify()
                except ImportError:
                    pass
                except:
                    continue
                name = os.path.split(name)[1]

                # In python3, name is a string. Convert it to bytes.
                if not isinstance(name, bytes):
                    try:
                        name = name.encode('cp437')
                    except UnicodeEncodeError:
                        # File name includes characters that aren't in cp437,
                        # which isn't supported by most zip tooling. They will
                        # not appear correctly.
                        tempname = name

                # Decode byte-name.
                if isinstance(name, bytes):
                    encoding = charsetdetect(name)['encoding']
                    tempname = name.decode(encoding)

                # A gallery with a slug of "/" tries to extract files
                # to / on disk; see os.path.join docs.
                slug = self.slug if self.slug != "/" else ""
                path = os.path.join(GALLERIES_UPLOAD_DIR, slug, tempname)
                try:
                    saved_path = default_storage.save(path, ContentFile(data))
                except UnicodeEncodeError:
                    from warnings import warn
                    warn("A file was saved that contains unicode "
                         "characters in its path, but somehow the current "
                         "locale does not support utf-8. You may need to set "
                         "'LC_ALL' to a correct value, eg: 'en_US.UTF-8'.")
                    # The native() call is needed here around str because
                    # os.path.join() in Python 2.x (in posixpath.py)
                    # mixes byte-strings with unicode strings without
                    # explicit conversion, which raises a TypeError as it
                    # would on Python 3.
                    path = os.path.join(GALLERIES_UPLOAD_DIR, slug,
                                        native(str(name, errors="ignore")))
                    saved_path = default_storage.save(path, ContentFile(data))
                self.images.create(file=saved_path)
            if delete_zip_import:
                zip_file.close()
                self.zip_import.delete(save=True)
729223
def _create_thumbnail(self, model_instance, thumbnail, image_name):
        
        thumbnail = self._do_resize(thumbnail, self.thumbnail_size)
        full_image_name = self.generate_filename(model_instance, image_name)
        thumbnail_filename = _get_thumbnail_filename(full_image_name)
        thumb = self._get_simple_uploaded_file(thumbnail, thumbnail_filename)
        self.storage.save(thumbnail_filename, thumb)
952131
public function deletePhoto($model, $parentRelation = null)
    {
        $thumbs = $this->options['photo']['thumbnails'];
        $id = is_null($parentRelation) ? $model->id : $model->$parentRelation->id;
        $path = $this->options['photo']['path'] . "/{$id}";
        // delete original
        $this->delete($path . "/original/{$model->photo}");
        // thumbnails delete
        foreach($thumbs as $thumb => $size){
            $this->delete($path . "/thumbnails/{$thumb}_{$model->photo}");
        }
    }
1109659
def update(self, *objs):
        
        keys = self.keys()
        new_keys = get_objs_columns(objs, self.realfieldb)

        modified = False
        for v in new_keys:
            if v in keys:    #the id has been existed, so don't insert new record
                keys.remove(v)
            else:
                d = {self.fielda:self.valuea, self.fieldb:v}
                if self.before_save:
                    self.before_save(d)
                if self.through_model:
                    obj = self.through_model(**d)
                    obj.save()
                else:
                    self.do_(self.table.insert().values(**d))
                modified = True
                
        if keys: #if there are still keys, so delete them
            self.clear(*keys)
            modified = True
        
        #cache [] to _STORED_attr_name
        setattr(self.instance, self.store_key, new_keys)
        
        return modified
474273
def auto_delete_files_on_instance_change(
        instance: Any,
        fieldnames: Iterable[str],
        model_class) -> None:
    

    if not instance.pk:
        return  # instance not yet saved in database
    # noinspection PyUnresolvedReferences
    try:
        # noinspection PyUnresolvedReferences
        old_instance = model_class.objects.get(pk=instance.pk)
    except model_class.DoesNotExist:
        return  # old version gone from database entirely
    for fieldname in fieldnames:
        old_filefield = getattr(old_instance, fieldname, None)
        if not old_filefield:
            continue
        new_filefield = getattr(instance, fieldname, None)
        if old_filefield != new_filefield:
            if os.path.isfile(old_filefield.path):
                os.remove(old_filefield.path)
889832
def delete(self, image_file, delete_thumbnails=True):
        
        if delete_thumbnails:
            self.delete_thumbnails(image_file)
        self._delete(image_file.key)
887637
def _deleter(self, obj):
        
        if self._fdel_ is not None:
            self._fdel_(obj)

        else:
            delattr(obj, self._attrname())

        # notify parent schema about value deletion.
        if isinstance(obj, Schema):
            obj._delvalue(self)
493818
def contribute_to_class(self, cls, name, **kwargs):
        
        super(PlaceholderField, self).contribute_to_class(cls, name, **kwargs)

        # overwrites what instance.<colname> returns; give direct access to the placeholder
        setattr(cls, name, PlaceholderFieldDescriptor(self.slot))

        # Make placeholder fields easy to find
        # Can't assign this to cls._meta because that gets overwritten by every level of model inheritance.
        if not hasattr(cls, '_meta_placeholder_fields'):
            cls._meta_placeholder_fields = {}
        cls._meta_placeholder_fields[name] = self

        # Configure the revere relation if possible.
        # TODO: make sure reverse queries work properly
        if django.VERSION >= (1, 11):
            rel = self.remote_field
        else:
            rel = self.rel

        if rel.related_name is None:
            # Make unique for model (multiple models can use same slotnane)
            rel.related_name = '{app}_{model}_{slot}_FIXME'.format(
                app=cls._meta.app_label,
                model=cls._meta.object_name.lower(),
                slot=self.slot
            )

            # Remove attribute must exist for the delete page. Currently it's not actively used.
            # The regular ForeignKey assigns a ForeignRelatedObjectsDescriptor to it for example.
            # In this case, the PlaceholderRelation is already the reverse relation.
            # Being able to move forward from the Placeholder to the derived models does not have that much value.
            setattr(rel.to, self.rel.related_name, None)
432747
def delete(self, file_, delete_file=True):
        
        image_file = ImageFile(file_)
        if delete_file:
            image_file.delete()
        default.kvstore.delete(image_file)
1250910
function(fullSchema, schema, seenObjects, path, options) {
  // Top level reference, dereference it
  if(schema['$ref']) {
    // Dereference
    var dereference = deref(fullSchema, '', schema["$ref"], seenObjects, options);
    // Delete the tag
    delete(schema['$ref']);
    // Merge the dereferenced value
    for(var name in dereference) {
      schema[name] = dereference[name];
    }
  }

  for(var name in schema) {
    var value = schema[name];
    path.push(name);

    if(value instanceof Object) {
      // Extract the path
      if(value["$ref"]) {
        // Get the reference
        var reference = value["$ref"];
        // Unroll the reference
        var dereference = deref(fullSchema, name, reference, seenObjects, path, options);
        // Add the dereferenced value
        schema[name] = dereference;
      } else {
        extractReferences(fullSchema, value, seenObjects, path, options);
      }
    }

    path.pop();
  }
}
941087
function(models, options) {
      models  || (models = []);
      options || (options = {});
      this.each(this._removeReference);
      this._reset();
      this.add(models, {silent: true});
      if (!options.silent) this.trigger('reset', this, options);
      return this;
    }
1220466
def save(self, name, content, *args, **kwargs):
        
        options = getattr(self.field, 'resize_source', None)
        if options:
            if 'quality' not in options:
                options['quality'] = self.thumbnail_quality
            content = Thumbnailer(content, name).generate_thumbnail(options)
            # If the generated extension differs from the original, use it
            # instead.
            orig_name, ext = os.path.splitext(name)
            generated_ext = os.path.splitext(content.name)[1]
            if generated_ext.lower() != ext.lower():
                name = orig_name + generated_ext
        super(ThumbnailerImageFieldFile, self).save(name, content, *args,
                                                    **kwargs)
441371
def add(self, parent, obj_type, **attributes):
        
        return self.ixnCommand('add', parent.obj_ref(), obj_type, get_args_pairs(attributes))
218264
function() {
    const Utils = this.definition.store.utils
    var self = this
    var primaryKeys = this.definition.primaryKeys

    var options = Utils.clone(self.definition.actions['destroy'])

    for (var i = 0; i < primaryKeys.length; i++) {
      options.params[primaryKeys[i]] = this[primaryKeys[i]]
    }

    Utils.applyParams(options)

    return self
      .callInterceptors('beforeDestroy', [self, options])
      .then(function() {
        return self.model.definition.store.connection.delete(options.url)
      })
      .then(function(result) {
        debug('delete ' + options.url)
        // var validationErrors = obj[self.errorParam || 'error']
        // if(typeof validationErrors === 'object' && Object.keys(validationErrors) > 0){
        //   this.errors.set(validationErrors)
        //   return resolve(false)
        // }
        var data = result.data[this.rootParam || 'data']

        if (data) {
          self.set(data)
        }

        return self.callInterceptors('afterDestroy', [self, options])
      })
      .then(function(record) {
        record.__exists = false
        return record
      })
  }