Save the state of the current user
559577
def update_user(self):
        
        # First create a copy of the current user
        user_dict = self.serialize()
        # Then delete the entities in the description field
        del user_dict['description']['entities']
        # Then upload user_dict
        user, meta = self._api.update_user('me', data=user_dict)
139246
public function saveState()
	{
        if($this->sessionEnabled()) {
            // Session handling.
            if(!is_array($this->sessionvars)) {
                $this->sessionvars = array();
            }
            foreach($this->sessionvars as $varname => $val) {
                if($val === null) {
                    unset($_SESSION[$varname]);
                }
                else {
                    $_SESSION[$varname] = $val;
                }
            }
        }

        if(!headers_sent()) {
            foreach($this->cookievars as $cookiename => $cookiedef) {
                if($cookiedef['value'] === null) {
                    setcookie($cookiename, null, time() - 3600, '/'); // Expiring the cookie
                }
                else {
                    setcookie(
                        $cookiename,
                        $cookiedef['value'],
                        time() + $cookiedef['max_age'],
                        '/'
                    );
                }
            }
        }
	}
1309895
def save_state(self):
        """"""
        # Save boolean settings
        for key, check_box in list(self.boolean_settings.items()):
            self.save_boolean_setting(key, check_box)
        # Save text settings
        for key, line_edit in list(self.text_settings.items()):
            self.save_text_setting(key, line_edit)

        set_setting(
            'north_arrow_path', self.leNorthArrowPath.text(), self.settings)
        set_setting(
            'organisation_logo_path',
            self.organisation_logo_path_line_edit.text(),
            self.settings)
        set_setting(
            'reportTemplatePath',
            self.leReportTemplatePath.text(),
            self.settings)
        set_setting(
            'reportDisclaimer',
            self.txtDisclaimer.toPlainText(),
            self.settings)
        set_setting(
            'defaultUserDirectory',
            self.leUserDirectoryPath.text(),
            self.settings)
        index = self.earthquake_function.currentIndex()
        value = self.earthquake_function.itemData(index)
        set_setting('earthquake_function', value, qsettings=self.settings)

        currency_index = self.currency_combo_box.currentIndex()
        currency_key = self.currency_combo_box.itemData(currency_index)
        set_setting('currency', currency_key, qsettings=self.settings)

        # Save InaSAFE default values
        self.save_default_values()

        # Save population parameters
        self.save_population_parameters()
596396
def user(self, username, realname):
        """"""
        cmd = 'USER {username} 0 * :{realname}'.format(**locals())
        self.send_raw(cmd)
1304973
def save(self, commit=True):
        
        is_new_user = self.instance.pk is None

        user = super(UserForm, self).save(commit)

        # new users should be made active by default
        if is_new_user:
            user.is_active = True

        # if we had a new password set, use it
        new_pass = self.cleaned_data['new_password']
        if new_pass:
            user.set_password(new_pass)
            if commit:
                user.save()

        return user
1069122
def save(self):
        ""
        with open(self.state_file, "w") as fh:
            json.dump({
                "hosts": self.hosts,
                "stats": self.stats,
            }, fh)
406246
def handle_current_state(self):
        '''
        
        '''
        if getattr(self, '_current_state_hydrated_changed', False) and self.save_on_change:
            new_base_state = json.dumps(getattr(self, '_current_state_hydrated', {}))
            if new_base_state != self.base_state:
                self.base_state = new_base_state
                self.save()
926007
def set_user(self, user):
        
        self.session['user_id'] = user.key
        self.session['user_data'] = user.clean_value()
        role = self.get_role()
        # TODO: this should be remembered from previous login
        # self.session['role_data'] = default_role.clean_value()
        self.session['role_id'] = role.key
        self.current.role_id = role.key
        self.current.user_id = user.key
        # self.perm_cache = PermissionCache(role.key)
        self.session['permissions'] = role.get_permissions()
965552
def _saveState(self, path):
        """"""
        self.addSession()  # next session
        self._save(str(self.n_sessions), path)
944852
def save(self, user, commit=True):
        
        self.is_instance(user)

        schema = UpdateSchema()
        valid = schema.process(user)
        if not valid:
            return valid

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

        events.user_save_event.send(user)
        return user
1368024
def save_user_config(username, conf_dict, path=settings.LOGIN_FILE):
    
    users = load_users(path=path)
    users[username]["full_name"] = _encode_config(conf_dict)
    save_users(users, path=path)
895644
def save_state(self):
        """"""
        set_setting('lastSourceDir', self.source_directory.text())
        set_setting('lastOutputDir', self.output_directory.text())
        set_setting(
            'useDefaultOutputDir', self.scenario_directory_radio.isChecked())
1081709
public void saveState() {
	  ByteArrayOutputStream bos = new ByteArrayOutputStream();
	  try {
		ObjectOutputStream oos = new ObjectOutputStream(bos);
		oos.writeObject(this);
		oos.flush();
		keyValStore.setValue(keyValStoreName, Hex.toHexString(bos.toByteArray()));
		bos.close();
	} catch (IOException e) {
		logger.debug(String.format("Could not save state of member %s", this.name), e);
	}
   }
94451
def savestate(self, state):
        """"""
        oldstate = np.get_printoptions()
        np.set_printoptions(threshold=1e6)
        try:
            with open(os.path.join(self._directory, 'state.txt'), 'w') as f:
                print_(state, file=f)
        finally:
            np.set_printoptions(**oldstate)
287145
def _save(self, data):
        
        self.state = data.get('state')
        self.created = dt_time(data.get('created'))
        self.updated = dt_time(data.get('updated'))
255652
def user_post_save_handler(**kwargs):
    """"""
    if kwargs.get('created'):
        total = get_user_model().objects.all().count()
        data = [{
            'measurement': 'django_auth_user_create',
            'tags': {'host': settings.INFLUXDB_TAGS_HOST, },
            'fields': {'value': 1, },
            'time': timezone.now().isoformat(),
        }]
        write_points(data)

        data = [{
            'measurement': 'django_auth_user_count',
            'tags': {'host': settings.INFLUXDB_TAGS_HOST, },
            'fields': {'value': total, },
            'time': timezone.now().isoformat(),
        }]
        write_points(data)
1336129
def update_user(self, user, username=None, first_name=None, last_name=None):
		""""""
		
		if not isinstance(user, User):
			raise ValueError
		args = locals()
		url = api_url+'users/'+str(user.id)+'/'
		payload = {}
		for i in args:
			if args[i] is not None and i not in ['self', 'user']:
				payload[i] = args[i]
		r = requests.patch(url, data=json.dumps(payload), headers=self.headers)
		print(request_status(r))
		r.raise_for_status()
		return User(r.json())