From 82bd94e696408005ba45aff7d880ec35e7ebaa09 Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Fri, 14 Jun 2019 11:50:01 +0530 Subject: [PATCH] Fix connection restoration issue when pgAdmin server is restarted and the page is refreshed. Fixes #4357 --- docs/en_US/release_notes_4_9.rst | 3 ++- web/pgadmin/utils/driver/psycopg2/__init__.py | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/en_US/release_notes_4_9.rst b/docs/en_US/release_notes_4_9.rst index 8e0dc29f3..07b69d37a 100644 --- a/docs/en_US/release_notes_4_9.rst +++ b/docs/en_US/release_notes_4_9.rst @@ -26,4 +26,5 @@ Bug fixes | `Bug #4320 `_ - Fix issue where SSH tunnel connection using password is failing, it's regression of Master Password. | `Bug #4329 `_ - Fix an initialisation error when two functions with parameters are debugged in parallel. | `Bug #4343 `_ - Fix issue where property dialog of column should open properly for EPAS v12. -| `Bug #4350 `_ - Ensure we include the CSRF token when uploading files. \ No newline at end of file +| `Bug #4350 `_ - Ensure we include the CSRF token when uploading files. +| `Bug #4357 `_ - Fix connection restoration issue when pgAdmin server is restarted and the page is refreshed. \ No newline at end of file diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py index ed67631bf..60a3bb2b8 100644 --- a/web/pgadmin/utils/driver/psycopg2/__init__.py +++ b/web/pgadmin/utils/driver/psycopg2/__init__.py @@ -84,10 +84,11 @@ class Driver(BaseDriver): if '__pgsql_server_managers' in session: session_managers = session['__pgsql_server_managers'].copy() - manager = managers[str(sid)] = ServerManager(server_data) - if sid in session_managers: - manager._restore(session_managers[sid]) - manager.update_session() + for server in Server.query.filter_by(user_id=current_user.id): + manager = managers[str(server.id)] = ServerManager(server) + if server.id in session_managers: + manager._restore(session_managers[server.id]) + manager.update_session() else: managers = self.managers[session.sid] if str(sid) in managers: