Attach a model instance to the parent models.

        :param model: The model instance to attach
        :type model: Model

        :rtype: Model
978749
def save(self, model):
        
        model.set_attribute(self.get_plain_morph_type(), self._morph_class)

        return super(MorphOneOrMany, self).save(model)
1193229
public function setModel(Model $model)
    {
        $this->model = $model;
        $append = $this->getAppends();

        if ($append instanceof WithModelInterface) {
            $append->setModel($model);
        }

        return $this;
    }
919865
public function setModel(Model $model)
    {
        if (strpos($this->originalName, '.') !== false) {
            $parts = explode('.', $this->originalName);
            $name = array_pop($parts);

            while ($parts) {
                $part = array_shift($parts);
                $relation = $model->getAttribute($part);

                if ($relation instanceof Model) {
                    $model = $relation;
                    $this->setName($name);
                }
            }
        }

        return parent::setModel($model);
    }
985294
def model
      @model ||= begin
        model = find_or_build_model

        set_attributes(model)

        after_build_blocks.each { |block| instance_exec(model, &block) }
        model
      end
    end
815685
def save(self, model):
        
        model.set_attribute(self.get_plain_foreign_key(), self.get_parent_key())

        if model.save():
            return model

        return False
568074
public void updateModel(@NonNull Model model) {
        if (zoo != null) {
            for (val w: zoo)
                w.updateModel(model);
        } else {
            // if zoo wasn't initalized yet - just replace model
            this.model = model;
        }
    }
508740
public synchronized void replaceModel (MaxentModel model) {
	replacementThread = Thread.currentThread();
	while (!replacementCanProceed) Thread.yield();
	setter.setModel(model);
	replacementThread = null;
    }
331789
def add_instance(model, _commit=True, **kwargs):
    
    try:
        model = get_model(model)
    except ImportError:
        return None

    instance = model(**kwargs)
    db.session.add(instance)

    try:
        if _commit:
            db.session.commit()
        else:
            db.session.flush()
        return instance.id
    except IntegrityError:
        db.session.rollback()
        return
169510
def add_eager_constraints(self, models):
        
        table = self._parent.get_table()

        self._query.where_in("%s.%s" % (table, self._first_key), self.get_keys(models))
825903
def follow_model(self, model):
        
        if model:
          self.models_by_name[model.__name__.lower()] = model
          signals.post_save.connect(create_or_update, sender=model)
          signals.post_delete.connect(self.remove_orphans, sender=model)
844089
public void setModel (ComboBoxModel<?> model)
    {
        // if we had a previous model, unregister ourselves from it
        if (_model != null) {
            _model.removeListDataListener(this);
        }

        // subscribe to our new model
        _model = model;
        _model.addListDataListener(this);

        // rebuild the list
        removeAll();
        addButtons(0, _model.getSize());
    }
904972
def setModel( self, model ):
        
        if model == self._model:
            return False
            
        self._model = model
        
        if not self._record and model:
            self._record = model()
        
        if model:
            uifile = model.schema().property('uifile')
            if ( uifile ):
                self.setUiFile(uifile)
        
        self.rebuild()
        
        return True
796002
def bind(self, model, template="{}"):
        
        self._bound_model = model
        self._uri_template = template
        self._set_uri_from_bound_model()
1002003
def insert_model(self, model, *, upsert=None):
    
    pkname = model.primary_key_name
    include_keys = set(model.attrs.keys()).difference(model.exclude_keys_sql)

    if model.primary_key_is_auto:
      if pkname in include_keys:
        include_keys.remove(pkname)
    else:
      if isinstance(pkname, str):
        include_keys.add(pkname)
      else:
        include_keys.update(set(pkname))

    data = model.to_dict(include_keys=include_keys)
    returnings = []

    if model.primary_key_is_auto:
      returnings.append(pkname)
    if model.timestamps:
      returnings.extend(ts_name for ts_name in model.timestamps if ts_name)

    returning = ", ".join(returnings)
    cr = self.insert(model.table_name, data, returning=returning, upsert=upsert)

    if self.core.supports_returning_syntax:
      if returning:
        rec = cr.fetchone()
        if rec:
          for idx, attr_name in enumerate(returnings):
            setattr(model, attr_name, rec[idx])
    else:
      if model.primary_key_is_auto:
        setattr(model, model.primary_key_name, cr.lastrowid)

    return model
878310
def associate(self, model):
        
        self._parent.set_attribute(self._foreign_key, model.get_key())
        self._parent.set_attribute(self._morph_type, model.get_morph_class())

        return self._parent.set_relation(self._relation, model)
46938
def update_model(self, model):
        
        for k, v in self.parse_form().items():
            setattr(model, k, v)
825566
def contribute_to_class(self, model, name, **kwargs):
        
        super(LocalizedField, self).contribute_to_class(model, name, **kwargs)
        setattr(model, self.name, self.descriptor_class(self))