Exemplo n.º 1
0
    def bulk_update_helper(self, body):
        total_changes = 0
        for uid_str, value in body.items():
            self._update(uid_str, value)
            total_changes += 1

        session.commit()
        return dict(changes=total_changes), 200
Exemplo n.º 2
0
 def delete_helper(self, uid_str):
     try:
         model_instance = self.model_class.find(uid_str)
     except Exception as ex:
         abort(500, ex)
     else:
         session.delete(model_instance)
         session.flush()
         session.commit()
         return None, 204
Exemplo n.º 3
0
 def create_helper(self, body):
     model_instance = self.model_class.create()
     session.add(model_instance)
     try:
         model_instance = self.write_visitor.visit(model_instance, body)
     except ModelFieldError as ex:
         abort(400, ex)
     else:
         session.flush()
         session.commit()
         model_dict = self.read_visitor.visit_model(model_instance)
         return model_dict, 201
Exemplo n.º 4
0
    def create_helper(self, body):
        session.begin(nested=True)

        model_dict, _ = super(KeyCloakCrudHelper, self).create_helper(body)
        if current_app.config.get('KEYCLOAK_MIGRATION', False):
            model_instance = self.model_class.find(model_dict['uid'])
            try:
                model_instance.notify_keycloak_server(self.admin)
            except KeyCloakMigrationError as ex:
                session.rollback()
                abort(500, ex)

        session.commit()
        return model_dict, 201
Exemplo n.º 5
0
    def update_helper(self, uid_str, body):
        model_instance = self._update(uid_str, body)
        session.commit()

        jsonable_dict = self.read_visitor.visit_model(model_instance)
        return jsonable_dict, 200