If its level is into persist levels, convert the message to models and save it
429297
def process_message(self, message, *args, **kwargs):
        
        if not message.level in PERSISTENT_MESSAGE_LEVELS:
            return message

        user = kwargs.get("user") or self.get_user()

        try:
            anonymous = user.is_anonymous()
        except TypeError:
            anonymous = user.is_anonymous
        if anonymous:
            raise NotImplementedError('Persistent message levels cannot be used for anonymous users.')
        message_persistent = PersistentMessage()
        message_persistent.level = message.level
        message_persistent.message = message.message
        message_persistent.extra_tags = message.extra_tags
        message_persistent.user = user

        if "expires" in kwargs:
            message_persistent.expires = kwargs["expires"]
        message_persistent.save()
        return None
321318
def save(self, *args, **kwargs):
        
        super(Layer, self).save(*args, **kwargs)

        # if is_published of an existing layer changes
        if self.pk and self.is_published != self._current_is_published:
            # send django signal
            layer_is_published_changed.send(
                sender=self.__class__,
                instance=self,
                old_is_published=self._current_is_published,
                new_is_published=self.is_published
            )
            # unpublish nodes
            self.update_nodes_published()

        # update _current_is_published
        self._current_is_published = self.is_published
965792
def save_model():
    
    if not os.path.exists("checkpoint"):
        os.mkdir("checkpoint")
    return mx.callback.do_checkpoint("checkpoint/checkpoint", args.save_period)
762434
def post_save(sender, instance, created, **kwargs):
    
    # Only create order model instances for
    # those modules specified in settings.
    model_label = '.'.join([sender._meta.app_label, sender._meta.object_name])
    labels = resolve_labels(model_label)

    order_field_names = is_orderable(model_label)
    if order_field_names:
        orderitem_set = getattr(
            instance,
            resolve_order_item_related_set_name(labels)
        )
        if not orderitem_set.all():
            fields = {}
            for order_field_name in order_field_names:
                fields[order_field_name] = 1
            orderitem_set.model.objects.create(item=instance, **fields)
            sanitize_order(orderitem_set.model)
1154298
def save(self):
        
        with rconnect() as conn:
            try:
                self.validate()
            except ValidationError as e:
                log.warn(e.messages)
                raise
            except ModelValidationError as e:
                log.warn(e.messages)
                raise
            except ModelConversionError as e:
                log.warn(e.messages)
                raise
            except ValueError as e:
                log.warn(e)
                raise
            except FrinkError as e:
                log.warn(e.messages)
                raise
            except Exception as e:
                log.warn(e)
                raise
            else:
                # If this is a new unsaved object, it'll likely have an
                # id of None, which RethinkDB won't like. So if it's None,
                # generate a UUID for it. If the save fails, we should re-set
                # it to None.
                if self.id is None:
                    self.id = str(uuid.uuid4())
                    log.debug(self.id)

                try:
                    query = r.db(self._db).table(self._table).insert(
                        self.to_primitive(),
                        conflict="replace"
                    )
                    log.debug(query)
                    rv = query.run(conn)
                    # Returns something like this:
                    # {
                    #   u'errors': 0,
                    #   u'deleted': 0,
                    #   u'generated_keys': [u'dd8ad1bc-8609-4484-b6c4-ed96c72c03f2'],
                    #   u'unchanged': 0,
                    #   u'skipped': 0,
                    #   u'replaced': 0,
                    #   u'inserted': 1
                    # }
                    log.debug(rv)
                except Exception as e:
                    log.warn(e)
                    self.id = None
                    raise
                else:
                    return self
170408
def save_model(self, request, obj, form, change):
        
        super(DisplayableAdmin, self).save_model(request, obj, form, change)
        if settings.USE_MODELTRANSLATION:
            lang = get_language()
            for code in OrderedDict(settings.LANGUAGES):
                if code != lang:  # Already done
                    try:
                        activate(code)
                    except:
                        pass
                    else:
                        obj.save()
            activate(lang)
470523
def save(self, model, joining=None, touch=True):
        
        if joining is None:
            joining = {}

        model.save({'touch': False})

        self.attach(model.get_key(), joining, touch)

        return model
200690
def save(self, idempotency_key=None):
        """"""
        updated_params = self.serialize(None)
        headers = populate_headers(idempotency_key)

        if not updated_params:
            util.logger.debug("Trying to save already saved object %r", self)
            return defer.succeed(self)

        d = self.request('post', self.instance_url(), updated_params, headers)
        return d.addCallback(self.refresh_from).addCallback(lambda _: self)
1024738
def persist(self, key):
        """"""
        fut = self.execute(b'PERSIST', key)
        return wait_convert(fut, bool)
412786
def persist(self, ttl=None, **kwargs):
        """"""
        from ..container import container_map
        from ..container.persist import PersistStore
        import time
        if 'original_tok' in self.metadata:
            raise ValueError('Cannot persist a source taken from the persist '
                             'store')
        method = container_map[self.container]._persist
        store = PersistStore()
        out = method(self, path=store.getdir(self), **kwargs)
        out.description = self.description
        metadata = {'timestamp': time.time(),
                    'original_metadata': self.metadata,
                    'original_source': self.__getstate__(),
                    'original_name': self.name,
                    'original_tok': self._tok,
                    'persist_kwargs': kwargs,
                    'ttl': ttl,
                    'cat': {} if self.cat is None else self.cat.__getstate__()}
        out.metadata = metadata
        out.name = self.name
        store.add(self._tok, out)
        return out
64870
def _to_base_type(self, msg):
    """"""
    ent = _message_to_entity(msg, self._modelclass)
    ent.blob_ = self._protocol_impl.encode_message(msg)
    return ent
103960
def save(self, model_fname='model.pkl'):
        
        with open(model_fname, 'wb') as fh:
            pickle.dump(self.stmts, fh, protocol=4)
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
319819
private function keepMessage($level, $message) {
		if(static::LOG_LEVELS[$this->keepMessages] > static::LOG_LEVELS[$level]) {
			return;
		}

		if($level == '' || $level == 'LOG'){
			$keepMessage = $message;
		} else {
			$keepMessage = $level . " " . $message;
		}
		$this->logEntries[] = $keepMessage;
	}
428142
private void _saveMessages(FacesContext facesContext)
    {
        if (isKeepMessages()) 
        {
            // get all messages from the FacesContext and store
            // them on the renderMap
            List<MessageEntry> messageList = null;
                
            Iterator<String> iterClientIds = facesContext.getClientIdsWithMessages();
            while (iterClientIds.hasNext())
            {
                String clientId = (String) iterClientIds.next();
                Iterator<FacesMessage> iterMessages = facesContext.getMessages(clientId);
                
                while (iterMessages.hasNext())
                {
                    FacesMessage message = iterMessages.next();
    
                    if (messageList == null)
                    {
                        messageList = new ArrayList<MessageEntry>();
                    }
                    messageList.add(new MessageEntry(clientId, message));
                }
            }
    
            _getRenderFlashMap(facesContext).put(FLASH_KEEP_MESSAGES_LIST, messageList);
        }
        else
        {
            // do not keep messages --> remove messagesList from renderMap
            _getRenderFlashMap(facesContext).remove(FLASH_KEEP_MESSAGES_LIST);
        }
    }
502187
def serialize_on_save(sender, instance, raw, created, using, **kwargs):
    
    if not raw:
        if "historical" not in instance._meta.label_lower:
            try:
                wrapped_instance = site_offline_models.get_wrapped_instance(instance)
            except ModelNotRegistered:
                pass
            else:
                wrapped_instance.to_outgoing_transaction(using, created=created)
675950
def save
      raise EntityModelIsNotPersistedError unless entity.persisted?

      if persisted?
        return false unless changed?
        update
      else
        create
      end

      @previously_changed = changes
      @changed_attributes.clear

      true
    end