save data will obtain the current subid from the session, and save it
       depending on the database type. Currently we just support flat files
17332
def save_data(self, session, exp_id, content):
    ''''''

    subid = session.get('subid')

    # We only attempt save if there is a subject id, set at start
    data_file = None
    if subid is not None:

        data_base = "%s/%s" %(self.data_base, subid)

        # If not running in headless, ensure path exists
        if not self.headless and not os.path.exists(data_base):
            mkdir_p(data_base)

        # Conditions for saving:
        do_save = False

        # If headless with token pre-generated OR not headless
        if self.headless and os.path.exists(data_base) or not self.headless:
            do_save = True
        if data_base.endswith(('revoked','finished')):
            do_save = False  

        # If headless with token pre-generated OR not headless
        if do_save is True:
            data_file = "%s/%s-results.json" %(data_base, exp_id)
            if os.path.exists(data_file):
                self.logger.warning('%s exists, and is being overwritten.' %data_file)
            write_json(content, data_file)

    return data_file
567264
public function save ()
    {
        $Statement = $this->dbTable->getSql()->prepareStatementForSqlObject($this->sqlInsert);
        $Statement->execute();
        $this->id = $this->dbTable->getAdapter()->getDriver()->getConnection()->getLastGeneratedValue();
    }
710986
def get_db_prep_save(self, value, connection, **kwargs):
        """"""
        if value is None and self.null:
            return None
        # default values come in as strings; only non-strings should be
        # run through `dumps`
        if not isinstance(value, six.string_types):
            value = dumps(value)

        return value
431980
def save(self):
        
        try:
            if self.exists() is False:
                self.db.session.add(self)
            # self.db.session.merge(self)
            self.db.session.commit()
        except (Exception, BaseException) as error:
            if current_app.config['DEBUG']:
                raise error
            return None
874902
function save() {
			var act = new NobleMachine(function() {
				setStrs = [];

				for (var key in model.columns) {
					if ([model.primary].indexOf(key) == -1 && me[key] !== undefined) {
						setStrs.push('`' + key + '`' + " = " + nrutil.serialize(me[key]));
					}
				}

				if (model.columns['updatedAt'])
					setStrs.push('`updatedAt` = NOW()');

				var sql;
				if (me[model.primary]) {
					sql = "UPDATE " + model.table
							+ " SET " + setStrs.join(',')
							+ " WHERE `" + model.primary + "` = " + me[model.primary];
				} else {
					if (model.columns['createdAt'])
						setStrs.push('`createdAt` = NOW()');

					sql = "INSERT"
							+ " INTO " + model.table
							+ " SET " + setStrs.join(',');
				}


				act.toNext(db_query(sql));
			});

			act.next(function(result) {
				//log.debug("RESULT: " + JSON.stringify(result));

				if (result.insert_id) {
					me[model.primary] = result.insert_id;
				} else if (!me[model.primary]) {
					act.toError("No insert_id, and no extant primary key!");
					return;
				}

				
				logger.log("Successfully saved `" + model.ident + "` record `" + me[model.primary] + "`");

				act.toNext(me);
			});

			act.error(function(err) {
				logger.error("Error saving `" + model.ident + "` record: " + JSON.stringify(err));
				act.emitError(err);
			});

			return act;
		}
544619
def save(self) -> sql.Executant:
        
        r = self._dict_to_SQL(self.modifications)
        self.modifications.clear()
        return r
241334
def save(bulk = false)
      raise ArgumentError, "doc.database required for saving" unless database
      result = database.save_doc self, bulk
      result['ok']
    end
350228
function save() {

		if ($this->cacheConf['type'] == 'noop') {
			// do nothing
		}
		else { // non-noop

			$stateCopy = $this->state;
			$stateCopy['loaded'] = [];

			if ($this->cacheConf['type'] == 'file') {
				$username = \get_current_user();
				$cacheDir = realpath($this->syspath.'/'.\trim($this->cacheConf['path'], '\\/'));
				$cachePath = $cacheDir.'/freia.'.(\php_sapi_name() === 'cli' ? 'cli' : 'server').'.'.$username.'.symbols.json';
				if ($this->file_exists($cacheDir)) {
					try {
						$this->file_put_contents($cachePath, \json_encode($stateCopy, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
						if ( ! $this->chmod($cachePath, $this->filePermission())) {
							$this->error_log("Unable to set permissions on cache file: $cachePath");
						}
					}
					catch (\Exception $e) {
						$this->error_log('Failed to save state to cache file ['.$cachePath.'] Error: '.$e->getMessage());
					}
				}
				else {
					$this->error_log('Missing cache directory: '.$this->cacheConf['path']);
				}
			}
			else if ($this->cacheConf['type'] == 'memcached') {
				$mc = $this->memcachedInstance();
				$success = $mc->set('freia-symbols', $stateCopy, time() + 604800);
				if ( ! $success) {
					$this->error_log("Memcached failed to store key freia-symbols, code: ".$mc->getResultCode());
				}
			}
		}
	}
1274065
protected void copySessionDb(String currentFile, String destFile) throws Exception {

		// ZAP: Changed to call the method close(boolean, boolean).
		getDb().close(false, false);

		// copy session related files to the path specified
		FileCopier copier = new FileCopier();

		// ZAP: Check if files exist.
		File fileIn1 = new File(currentFile + ".data");
		if (fileIn1.exists()) {
			File fileOut1 = new File(destFile + ".data");
			copier.copy(fileIn1, fileOut1);
		}

		File fileIn2 = new File(currentFile + ".script");
		if (fileIn2.exists()) {
			File fileOut2 = new File(destFile + ".script");
			copier.copy(fileIn2, fileOut2);
		}

		File fileIn3 = new File(currentFile + ".properties");
		if (fileIn3.exists()) {
			File fileOut3 = new File(destFile + ".properties");
			copier.copy(fileIn3, fileOut3);
		}

		File fileIn4 = new File(currentFile + ".backup");
		if (fileIn4.exists()) {
			File fileOut4 = new File(destFile + ".backup");
			copier.copy(fileIn4, fileOut4);
		}

		// ZAP: Handle the "lobs" file.
		File lobsFile = new File(currentFile + ".lobs");
		if (lobsFile.exists()) {
			File newLobsFile = new File(destFile + ".lobs");
			copier.copy(lobsFile, newLobsFile);
		}

		getDb().open(destFile);

	}
1002178
def save_data(self, idx):
        """"""
        for subseqs in self:
            if isinstance(subseqs, abctools.OutputSequencesABC):
                subseqs.save_data(idx)
1161953
def save(self, status=None, callback_pos=None, id_workflow=None):
        """"""
        if self.model is None:
            raise WorkflowsMissingModel()

        with db.session.begin_nested():
            workflow_object_before_save.send(self)

            self.model.modified = datetime.now()
            if status is not None:
                self.model.status = status

            if id_workflow is not None:
                workflow = Workflow.query.filter_by(uuid=id_workflow).one()
                self.model.workflow = workflow

            # Special handling of JSON fields to mark update
            if self.model.callback_pos is None:
                self.model.callback_pos = list()
            elif callback_pos is not None:
                self.model.callback_pos = callback_pos
            flag_modified(self.model, 'callback_pos')

            if self.model.data is None:
                self.model.data = dict()
            flag_modified(self.model, 'data')

            if self.model.extra_data is None:
                self.model.extra_data = dict()
            flag_modified(self.model, 'extra_data')

            db.session.merge(self.model)

            if self.id is not None:
                self.log.debug("Saved object: {id} at {callback_pos}".format(
                    id=self.model.id or "new",
                    callback_pos=self.model.callback_pos
                ))
        workflow_object_after_save.send(self)
226105
def save_data(self,session, exp_id, content):
    ''''''
    from expfactory.database.models import (
        Participant,
        Result
    )
    subid = session.get('subid')
    token = session.get('token') 

    self.logger.info('Saving data for subid %s' % subid)    

    # We only attempt save if there is a subject id, set at start
    if subid is not None:
        p = Participant.query.filter(Participant.id == subid).first() # better query here

        # Does 
        if self.headless and p.token != token:
            self.logger.warning('%s attempting to use mismatched token [%s] skipping save' %(p.id, token))
        elif self.headless and p.token.endswith(('finished','revoked')):
            self.logger.warning('%s attempting to use expired token [%s] skipping save' %(p.id, token))
        else:

            # Preference is to save data under 'data', otherwise do all of it
            if "data" in content:
                content = content['data']

            result = Result(data=content,
                            exp_id=exp_id,
                            participant_id=p.id) # check if changes from str/int

            # Create and save the result
            self.session.add(result)
            p.results.append(result)
            self.session.commit()

            self.logger.info("Save [participant] %s [result] %s" %(p, result))
277108
def save_storage(self, instance, schema):
        """"""
        for field_schema, fields in iterate_fields(instance, schema):
            name = field_schema['name']
            value = fields[name]
            if field_schema.get('type', '').startswith('basic:json:'):
                if value and not self.pk:
                    raise ValidationError(
                        'Data object must be `created` before creating `basic:json:` fields')

                if isinstance(value, int):
                    # already in Storage
                    continue

                if isinstance(value, str):
                    file_path = self.location.get_path(filename=value)  # pylint: disable=no-member
                    if os.path.isfile(file_path):
                        try:
                            with open(file_path) as file_handler:
                                value = json.load(file_handler)
                        except json.JSONDecodeError:
                            with open(file_path) as file_handler:
                                content = file_handler.read()
                                content = content.rstrip()
                                raise ValidationError(
                                    "Value of '{}' must be a valid JSON, current: {}".format(name, content)
                                )

                storage = self.storages.create(  # pylint: disable=no-member
                    name='Storage for data id {}'.format(self.pk),
                    contributor=self.contributor,
                    json=value,
                )

                # `value` is copied by value, so `fields[name]` must be changed
                fields[name] = storage.pk
1339351
public function saveById($id, $data)
    {
        $subData = array();
        foreach (array_keys($this->subAttributeList) as $subKey) {
            $subData[$subKey] = null;
            if (isset($data[$subKey])) {
                $subData[$subKey] = $data[$subKey];
                unset($data[$subKey]);
            }
        }
        $id = parent::saveById($id, $data);
        foreach (array_keys($this->subAttributeList) as $subKey) {
            $this->saveSubAttributeById($id, $subKey, $subData[$subKey]);
        }
        return $id;
    }
472236
function save() {
      var value, data = '';

      // localStorage can be disabled on WebKit/Gecko so make a dummy storage
      if (!hasOldIEDataSupport) {
        return;
      }

      for (var key in items) {
        value = items[key];
        data += (data ? ',' : '') + key.length.toString(32) + ',' + key + ',' + value.length.toString(32) + ',' + value;
      }

      storageElm.setAttribute(userDataKey, data);

      try {
        storageElm.save(userDataKey);
      } catch (ex) {
        // Ignore disk full
      }

      updateKeys();
    }
609717
def save(self):
    """"""
    req = datastore.CommitRequest()
    req.mode = datastore.CommitRequest.NON_TRANSACTIONAL
    req.mutations.add().upsert.CopyFrom(self.to_proto())
    resp = datastore.commit(req)
    if not self.id:
      self.id = resp.mutation_results[0].key.path[-1].id
    return self
1309077
def save_data(self, idx):
        """"""
        for name in self:
            actual = getattr(self, name)
            diskflag = getattr(self, '_%s_diskflag' % name)
            ramflag = getattr(self, '_%s_ramflag' % name)
            if diskflag:
                file_ = getattr(self, '_%s_file' % name)
                ndim = getattr(self, '_%s_ndim' % name)
                length_tot = 1
                for jdx in range(ndim):
                    length = getattr(self, '_%s_length_%s' % (name, jdx))
                    length_tot *= length
                if ndim:
                    raw = struct.pack(length_tot*'d', *actual.flatten())
                else:
                    raw = struct.pack('d', actual)
                file_.write(raw)
            elif ramflag:
                array = getattr(self, '_%s_array' % name)
                array[idx] = actual