From 248b8bb90e2fcfca6abb19768da645383257dd0d Mon Sep 17 00:00:00 2001 From: John Davis Date: Fri, 6 Oct 2023 10:17:58 -0400 Subject: [PATCH] SA2.0: Replacde flush with commit --- lib/tool_shed/webapp/api2/__init__.py | 4 +++- lib/tool_shed/webapp/api2/repositories.py | 13 +++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/tool_shed/webapp/api2/__init__.py b/lib/tool_shed/webapp/api2/__init__.py index 6961c8407b93..3630038280f3 100644 --- a/lib/tool_shed/webapp/api2/__init__.py +++ b/lib/tool_shed/webapp/api2/__init__.py @@ -29,6 +29,7 @@ from galaxy.exceptions import AdminRequiredException from galaxy.managers.session import GalaxySessionManager from galaxy.managers.users import UserManager +from galaxy.model.base import transaction from galaxy.security.idencoding import IdEncodingHelper from galaxy.util import unicodify from galaxy.web.framework.decorators import require_admin_message @@ -331,7 +332,8 @@ def ensure_valid_session(trans: SessionRequestContext) -> None: # be needed. if prev_galaxy_session: sa_session.add(prev_galaxy_session) - sa_session.flush() + with transaction(sa_session): + sa_session.commit() def set_auth_cookie(trans: SessionRequestContext, session): diff --git a/lib/tool_shed/webapp/api2/repositories.py b/lib/tool_shed/webapp/api2/repositories.py index 776e4064a7ab..4c809e2c1cec 100644 --- a/lib/tool_shed/webapp/api2/repositories.py +++ b/lib/tool_shed/webapp/api2/repositories.py @@ -20,6 +20,7 @@ from starlette.datastructures import UploadFile as StarletteUploadFile from galaxy.exceptions import InsufficientPermissionsException +from galaxy.model.base import transaction from galaxy.webapps.galaxy.api import as_form from tool_shed.context import SessionRequestContext from tool_shed.managers.repositories import ( @@ -357,7 +358,8 @@ def set_malicious( repository_metadata = get_repository_metadata_for_management(trans, encoded_repository_id, changeset_revision) repository_metadata.malicious = True trans.sa_session.add(repository_metadata) - trans.sa_session.flush() + with transaction(trans.sa_session): + trans.sa_session.commit() return Response(status_code=status.HTTP_204_NO_CONTENT) @router.delete( @@ -374,7 +376,8 @@ def unset_malicious( repository_metadata = get_repository_metadata_for_management(trans, encoded_repository_id, changeset_revision) repository_metadata.malicious = False trans.sa_session.add(repository_metadata) - trans.sa_session.flush() + with transaction(trans.sa_session): + trans.sa_session.commit() return Response(status_code=status.HTTP_204_NO_CONTENT) @router.put( @@ -392,7 +395,8 @@ def set_deprecated( raise InsufficientPermissionsException("You do not have permission to update this repository.") repository.deprecated = True trans.sa_session.add(repository) - trans.sa_session.flush() + with transaction(trans.sa_session): + trans.sa_session.commit() return Response(status_code=status.HTTP_204_NO_CONTENT) @router.delete( @@ -410,7 +414,8 @@ def unset_deprecated( raise InsufficientPermissionsException("You do not have permission to update this repository.") repository.deprecated = False trans.sa_session.add(repository) - trans.sa_session.flush() + with transaction(trans.sa_session): + trans.sa_session.commit() return Response(status_code=status.HTTP_204_NO_CONTENT) @router.delete(