def save(self, user, commit=True):
        """ Persist user and emit event """
        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
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
Persist user and emit event