Persist role model
16987
def save(self, role, commit=True):
        
        self.is_instance(role)

        schema = RoleSchema()
        valid = schema.process(role)
        if not valid:
            return valid

        db.session.add(role)
        if commit:
            db.session.commit()

        events.role_saved_event.send(role)
        return role
1235144
def persist
      future = nil
      set_id if new_record?
      callback = new_record? ? :create : :update

      self.class.transaction do |redis|
        run_callbacks :save do
          run_callbacks callback do
            redis.pipelined do
              attrs = coerced_attributes
              key = self.class.sti_child? ? self.class.sti_base_key_for(id) : self.class.key_for(id)
              future = attrs.any? ? redis.hmset(key, attrs) : :unchanged

              if new_record?
                if self.class.all_index_enabled?
                  redis.sadd(self.class.key_for(:all), id)
                  redis.sadd(self.class.sti_base_key_for(:all), id) if self.class.sti_child?
                end
                add_to_indexes(redis)
              else
                update_indexes(redis)
              end
            end
          end
        end
      end

      future
    end
1354928
def save_model(self, request, obj, form, change):
        
        super(SitePermissionUserAdmin, self).save_model(
            request, obj, form, change)
        user = self.model.objects.get(id=obj.id)
        has_perms = len(user.get_all_permissions()) > 0
        has_sites = SitePermission.objects.filter(user=user).count() > 0
        if user.is_active and user.is_staff and not user.is_superuser and not (
                has_perms and has_sites):
            error(request, "The user is active but won't be able to access "
                           "the admin, due to no edit/site permissions being "
                           "selected")
505524
def role_present(name, profile=None, **connection_args):
    ''''
    
    '''
    ret = {'name': name,
           'changes': {},
           'result': True,
           'comment': 'Role "{0}" already exists'.format(name)}

    # Check if role is already present
    role = __salt__['keystone.role_get'](name=name, profile=profile,
                                         **connection_args)

    if 'Error' not in role:
        return ret
    else:
        if __opts__.get('test'):
            ret['result'] = None
            ret['comment'] = 'Role "{0}" will be added'.format(name)
            return ret
        # Create role
        __salt__['keystone.role_create'](name, profile=profile,
                                         **connection_args)
        ret['comment'] = 'Role "{0}" has been added'.format(name)
        ret['changes']['Role'] = 'Created'
    return ret
204013
protected function persist()
    {
        $this->db->beginTransaction();

        try {
            $user = $this->model->find($this->selectedUser);
            $user->update(['password' => Hash::make($this->password)]);
        } catch (Exception $e) {
            $this->db->rollBack();
            $this->warn('Could not persist to the database: ' . $e->getMessage());
        }

        $this->db->commit();
        $this->info('Password Updated');

    }
700046
public void savePersistentObject(PersistentObject object) {
        final String type = object.getClass().getSimpleName();
        LOG.trace("Trying to create a new " + type);
        dao.saveOrUpdate(object);
        LOG.info("Created the " + type + " with id " + object.getId());
    }
284485
protected void persistProperties() throws Exception {
		if (isNewState()) {
			return;
		}

		if (Database.DB_TYPE_HSQLDB.equals(model.getDb().getType())) {
			configuration.save(new File(fileName));
		}
		model.getDb().getTableSession().update(getSessionId(), getSessionName());
	}
554441
def save(self):
        '''  '''
        redis = type(self).get_redis()
        pipe = to_pipeline(redis)

        pipe.hset(self.key(), 'id', self.id)

        for fieldname, field in self.proxy:
            if not isinstance(field, Relation):
                field.save(getattr(self, fieldname), pipe, commit=False)

        pipe.sadd(type(self).members_key(), self.id)

        pipe.execute()

        if self.notify:
            data = json.dumps({
                'event': 'create' if not self._persisted else 'update',
                'data': self.to_json(),
            })
            redis.publish(type(self).cls_key(), data)
            redis.publish(self.key(), data)

        self._persisted = True

        return self
1002356
def _create(cls, model_class, *args, **kwargs):
        """"""
        session = cls._meta.sqlalchemy_session
        session_persistence = cls._meta.sqlalchemy_session_persistence
        if cls._meta.force_flush:
            session_persistence = SESSION_PERSISTENCE_FLUSH

        obj = model_class(*args, **kwargs)
        if session is None:
            raise RuntimeError("No session provided.")
        session.add(obj)
        if session_persistence == SESSION_PERSISTENCE_FLUSH:
            session.flush()
        elif session_persistence == SESSION_PERSISTENCE_COMMIT:
            session.commit()
        return obj
1248671
def persist(self):
        """"""

        self.persisted_nodes = self.graph.dump_nodes()
        self.persisted_streamers = self.graph.dump_streamers()
        self.persisted_exists = True
        self.persisted_constants = self._sensor_log.dump_constants()
427597
function persistObject(target, schema) {
    var model = createModel(schema);
    serializr_1.setDefaultModelSchema(target, model);
    return target;
}
18669
def create_role(self, name):
        ''''''
        models = self.session.router
        return models.role.new(name=name, owner=self)
226923
function persist(modelfunc, keyfield)
{
	/*jshint newcap:false */
	assert(typeof modelfunc === 'function');

	if (!modelfunc.prototype.__properties && !modelfunc.prototype.serialize)
		throw(new Error('persist only accepts polyclay models'));

	// We must supply either a keyfield parameter or already have a 'key' property.
	var keyprop = Object.getOwnPropertyDescriptor(modelfunc.prototype, 'key');
	if (!keyprop)
	{
		if (!keyfield)
			keyfield = '_id';

		Object.defineProperty(modelfunc.prototype, 'key',
		{
			get: function getKey()
			{
				return this[this.keyfield];
			},
			set: function setKey(v)
			{
				this[this.keyfield] = v;
			},
			enumerable: true
		});
	}
	else
		keyfield = 'key';

	modelfunc.prototype.keyfield = keyfield;

	_.assign(modelfunc, persist.statics);
	_.assign(modelfunc.prototype, persist.plugins);
}
383479
public PanelUser updateRole(PanelUser panelUser, PanelUserRole panelUserRole, User modifier) {
    panelUser.setRole(panelUserRole);
    panelUser.setLastModified(new Date());
    panelUser.setLastModifier(modifier);
    
    return persist(panelUser);
  }
791681
private function persist()
    {
        $sessionBag = $this->session->getBag($this->getSessionBagKey());
        $sessionBag->set($this->getScope(), $this->filterAttributes());

        $databaseSessionBag = $this->session->getBag($this->getDatabaseSessionBagKey());
        $databaseSessionBag->set($this->getScope(), $this->filterAttributes(true));
    }
1062890
function persist(pErr, pVal) {
          if (pErr) {
            return cb(pErr);
          }

          if (ttl) {
            conn.setex(key, ttl, pVal, handleResponse(conn, cb));
          } else {
            conn.set(key, pVal, handleResponse(conn, cb));
          }
        }
834296
public void persistInSession( HttpServletRequest request, HttpServletResponse response )
    {
        StorageHandler sh = Handlers.get( getServletContext() ).getStorageHandler();
        HttpServletRequest unwrappedRequest = PageFlowUtils.unwrapMultipart( request );
        RequestContext rc = new RequestContext( unwrappedRequest, null );
        String attrName =
                ScopedServletUtils.getScopedSessionAttrName( InternalConstants.FACES_BACKING_ATTR, unwrappedRequest );
        
        sh.setAttribute( rc, attrName, this );
    }