From 05e91044c77a2b87bc95e85b682b0b4ada02322e Mon Sep 17 00:00:00 2001 From: Harshal Dhumal Date: Tue, 20 Feb 2018 17:31:13 +0000 Subject: [PATCH] Fix intermittent specified_version_number ValueError issue on restart. Fixes #2983 Now we try to restore server details like server version number at restart so template paths can be resolved. --- web/pgadmin/utils/driver/psycopg2/__init__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py index 5acfb322a..81442e498 100644 --- a/web/pgadmin/utils/driver/psycopg2/__init__.py +++ b/web/pgadmin/utils/driver/psycopg2/__init__.py @@ -1752,6 +1752,8 @@ class ServerManager(object): res = dict() res['sid'] = self.sid + res['ver'] = self.ver + res['sversion'] = self.sversion if hasattr(self, 'password') and self.password: # If running under PY2 if hasattr(self.password, 'decode'): @@ -1861,6 +1863,20 @@ WHERE db.oid = {0}""".format(did)) Helps restoring to reconnect the auto-connect connections smoothly on reload/restart of the app server.. """ + # restore server version from flask session if flask server was + # restarted. As we need server version to resolve sql template paths. + + self.ver = data.get('ver', None) + self.sversion = data.get('sversion', None) + + if self.ver and not self.server_type: + from pgadmin.browser.server_groups.servers.types import ServerType + for st in ServerType.types(): + if st.instanceOf(self.ver): + self.server_type = st.stype + self.server_cls = st + break + # Hmm.. we will not honour this request, when I already have # connections if len(self.connections) != 0: @@ -1967,6 +1983,7 @@ WHERE db.oid = {0}""".format(did)) else: managers[self.sid] = updated_mgr session['__pgsql_server_managers'] = managers + session.force_write = True def utility(self, operation): """