Preprocess the object before the object is saved.  This
        automatically gets called when the save method gets called.
340420
def save_prep(cls, instance_or_instances):
        
        instances = make_obj_list(instance_or_instances)

        tokens = set(cls.objects.get_available_tokens(
            count=len(instances),
            token_length=cls.token_length
        ))

        for instance in instances:
            if not instance.token:
                instance.token = tokens.pop()

        super(AbstractTokenModel, cls).save_prep(
            instance_or_instances=instances
        )
941289
public function beforeUpdate()
    {
        foreach ($this->models as $relationName => $config) {
            $this->markFilesAsPermanent($this->getRelationValues($relationName));
        }
    }
1371346
protected function doInsertBefore() {
    $request = $this->getRequest();
    $persistenceFacade = $this->getPersistenceFacade();
    $isOrderBottom = $this->isOrderBotton($request);

    // load the moved object, the reference object and the conainer object
    $insertOid = ObjectId::parse($request->getValue('insertOid'));
    $referenceOid = ObjectId::parse($request->getValue('referenceOid'));
    $containerOid = ObjectId::parse($request->getValue('containerOid'));
    $insertObject = $persistenceFacade->load($insertOid);
    $referenceObject = $isOrderBottom ? new NullNode() : $persistenceFacade->load($referenceOid);
    $containerObject = $persistenceFacade->load($containerOid);

    // check object existence
    $objectMap = ['insertOid' => $insertObject,
        'referenceOid' => $referenceObject,
        'containerOid' => $containerObject];
    if ($this->checkObjects($objectMap)) {
      $role = $request->getValue('role');
      $originalChildren = $containerObject->getValue($role);
      // add the new node to the container, if it is not yet
      $nodeExists = sizeof(Node::filter($originalChildren, $insertOid)) == 1;
      if (!$nodeExists) {
        $containerObject->addNode($insertObject, $role);
      }
      // reorder the children list
      $orderedChildren = [];
      foreach ($originalChildren as $curChild) {
        $oid = $curChild->getOID();
        if ($oid == $referenceOid) {
          $orderedChildren[] = $insertObject;
        }
        if ($oid != $insertOid) {
          $orderedChildren[] = $curChild;
        }
      }

      // get the sortkey values of the objects before and after the insert position
      if ($isOrderBottom) {
        $orderedChildren[] = $insertObject;
      }
      $containerObject->setNodeOrder($orderedChildren, [$insertObject], $role);
    }
  }
811079
def pre_process(self):
        
        LOGGER.info('ANALYSIS : Pre processing')

        for pre_processor in self._preprocessors:
            layer = pre_processor['process']['function'](self)
            purpose = pre_processor['output'].get('value')['key']
            save_style = pre_processor['output'].get('save_style', False)
            result, name = self.datastore.add_layer(layer, purpose, save_style)
            if not result:
                raise Exception(
                    tr('Something went wrong with the datastore : '
                       '{error_message}').format(error_message=name))
            layer = self.datastore.layer(name)
            self._preprocessors_layers[purpose] = layer
            self.debug_layer(layer, add_to_datastore=False)

            self.set_state_process('pre_processor', pre_processor['name'])
            LOGGER.info('{name} : Running'.format(name=pre_processor['name']))
649951
protected function handlePrePersist()
    {
        $environment = $this->getEnvironment();
        if (null !== $this->preFunction) {
            \call_user_func($this->preFunction, $environment, $this->model, $this->originalModel);
        }

        $environment->getEventDispatcher()->dispatch(
            PrePersistModelEvent::NAME,
            new PrePersistModelEvent($environment, $this->model, $this->originalModel)
        );
    }
756137
def pre_save(self, model_instance, add):
        """"""
        value = super().pre_save(model_instance, add)
        if isinstance(value, LocalizedValue):
            for file in value.__dict__.values():
                if file and not file._committed:
                    file.save(file.name, file, save=False)
        return value
165830
protected function before() {
		if($this->connection->getDatabasePlatform() instanceof SQLServerPlatform) {
			$this->connection->executeUpdate('EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"');
		} else if($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
			$this->connection->executeUpdate('SET FOREIGN_KEY_CHECKS=0');
		} else if($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
			$this->connection->executeUpdate('PRAGMA foreign_keys = OFF');
		}
	}
488323
def before(self, context):
        ""
        run.before_each.execute(context)
        self._invoke(self._before, context)
768771
public function onBeforeWrite()
    {
        $owner = $this->owner;
        $owner->IDCustomValue = Convert::raw2url($owner->IDCustomValue);
    }
968334
public function onBeforeWrite()
    {
        parent::onBeforeWrite();

        if (!$this->Sort) {
            if ($this->hasExtension(Versioned::class)) {
                $records = Versioned::get_by_stage(BaseElement::class, Versioned::DRAFT);
            } else {
                $records = BaseElement::get();
            }

            $records = $records->filter('ParentID', $this->ParentID);

            $this->Sort = $records->max('Sort') + 1;
        }
    }
275782
public function beforeDelete()
    {
        foreach ($this->attributes as $attr => $options) {
            $this->ensureAttributes($attr, $options);
            $this->deleteFiles($attr);
        }
    }
524616
public function beforeSave()
    {
        /*
         * Dynamic attributes are stored in the jsonable attribute 'data'.
         */
        $staticAttributes = ['id', 'theme', 'data', 'created_at', 'updated_at'];
        $dynamicAttributes = array_except($this->getAttributes(), $staticAttributes);

        $this->data = $dynamicAttributes;
        $this->setRawAttributes(array_only($this->getAttributes(), $staticAttributes));
    }
422047
def pre_save(self, instance, add):
        
        # get currently entered slug
        value = self.value_from_object(instance)
        slug = None

        # auto populate (if the form didn't do that already).
        # If you want unique_with logic, use django-autoslug instead.
        # This model field only allows parameters which can be passed to the form widget too.
        if self.populate_from and (self.always_update or not value):
            value = getattr(instance, self.populate_from)

        # Make sure the slugify logic is applied,
        # even on manually entered input.
        if value:
            value = force_text(value)
            slug = self.slugify(value)
            if self.max_length < len(slug):
                slug = slug[:self.max_length]

        # make the updated slug available as instance attribute
        setattr(instance, self.name, slug)
        return slug
523919
protected function _beforeSave()
    {
        $value = $this->getValue();
        $value = Mage::helper('adyen/installments')->makeStorableArrayFieldValue($value);
        $this->setValue($value);
    }
906822
public function preRun(): void {
    $this->insert = $this->getConnection()->insert($this->getTable(), $this->getFields());
  }
1262026
protected function beforeSave() 
	{
		if(parent::beforeSave()) {
			$this->banner_file_type = serialize(Utility::formatFileType($this->banner_file_type));
		}
		return true;
	}
1054548
public function preSave()
    {
        $this->originalData = $this->original;
        $this->updatedData = $this->attributes;

        // we can only safely compare basic items, so for now we drop any object based
        // items apart from DateTime objects where we compare them specially
        foreach ($this->updatedData as $key => $val) {
            if (is_object($val)) {
                if (!($val instanceof DateTime)) {
                    unset($this->originalData[$key]);
                    unset($this->updatedData[$key]);
                }
            }
        }

        // the below is ugly, for sure, but it's required so we can save the standard model
        // then use the keep / dontkeep values for later, in the isRevisionable method
        $this->dontKeep = isset($this->dontKeepRevisionOf) ?
            $this->dontKeepRevisionOf + $this->dontKeep
            : $this->dontKeep;

        $this->doKeep = isset($this->keepRevisionOf) ?
            $this->keepRevisionOf + $this->doKeep
            : $this->doKeep;

        unset($this->attributes['dontKeepRevisionOf']);
        unset($this->attributes['keepRevisionOf']);

        $this->dirtyData = $this->getDirty();
        $this->updating = $this->exists;
    }