From 9bc90250757c3e5e00e32695faef3532bfc41d6c Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Fri, 20 Nov 2015 14:55:47 +0530 Subject: [PATCH] Issues resolved related to connection management and collection nodes: - Allow to release connection using the database OID (did). - Generate correct url for the collection nodes. - Removed the server-type from the collection node module, from the generate_browser_collection_node(...) function. - Show version string, and not version integer in the server properties (when connected). --- web/pgadmin/browser/collection.py | 6 +++--- .../browser/server_groups/servers/__init__.py | 8 ++++---- .../browser/templates/browser/js/collection.js | 12 ++++++++++-- web/pgadmin/utils/driver/psycopg2/__init__.py | 11 +++++++++-- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/web/pgadmin/browser/collection.py b/web/pgadmin/browser/collection.py index 893940d6d..26ce45d93 100644 --- a/web/pgadmin/browser/collection.py +++ b/web/pgadmin/browser/collection.py @@ -13,7 +13,7 @@ from flask import url_for, render_template from flask.ext.babel import gettext from pgadmin.browser.utils import PgAdminModule, PGChildModule from pgadmin.browser import BrowserPluginModule -from pgadmin.browser.utils import NodeView, PGChildNode, PGChildNodeView +from pgadmin.browser.utils import PGChildNodeView @six.add_metaclass(ABCMeta) class CollectionNodeModule(PgAdminModule, PGChildModule): @@ -86,7 +86,7 @@ class CollectionNodeModule(PgAdminModule, PGChildModule): @property def node_type(self): - return '%s-%s' % (self.SERVER_TYPE, self.NODE_TYPE) + return '%s' % (self.NODE_TYPE) @property def csssnippets(self): @@ -171,7 +171,7 @@ class CollectionNodeModule(PgAdminModule, PGChildModule): return [] -class CollectionNodeView(NodeView, PGChildNode): +class CollectionNodeView(PGChildNodeView): """ A PostgreSQL Collection node has specific functions needs to address i.e. diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py index 430dc3af1..0abd83a58 100644 --- a/web/pgadmin/browser/server_groups/servers/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/__init__.py @@ -62,7 +62,7 @@ class ServerModule(sg.ServerGroupPluginModule): self.NODE_TYPE, connected=connected, server_type=manager.server_type if connected else "pg", - server_version=manager.sversion if connected else 0 + version=manager.version ) @property @@ -137,7 +137,7 @@ class ServerNode(PGChildNodeView): self.node_type, connected=connected, server_type=manager.server_type if connected else 'PG', - version=manager.sversion + version=manager.version ) ) return make_json_response(result=res) @@ -295,7 +295,7 @@ class ServerNode(PGChildNodeView): 'comment': server.comment, 'role': server.role, 'connected': connected, - 'version': manager.sversion, + 'version': manager.ver, 'server_type': manager.server_type if connected else 'PG' } ) @@ -522,7 +522,7 @@ class ServerNode(PGChildNodeView): ), 'connected': True, 'type': manager.server_type, - 'version': manager.sversion + 'version': manager.version } ) diff --git a/web/pgadmin/browser/templates/browser/js/collection.js b/web/pgadmin/browser/templates/browser/js/collection.js index 819fb856a..0830eba4d 100644 --- a/web/pgadmin/browser/templates/browser/js/collection.js +++ b/web/pgadmin/browser/templates/browser/js/collection.js @@ -86,7 +86,15 @@ function($, _, S, pgAdmin, Backbone, Alertify, Backform) { j.append(content); // Fetch Data - collections.fetch({reset: true}); + collections.fetch({reset: true}) + .error(function(jqxhr, error, message) { + Alertify.pgNotifier( + error, jqxhr, + S( + "{{ _("Error fetching the properties - %%s!") }}" + ).sprintf(message).value() + ); + }); }, generate_url: function(item, type, d) { var url = pgAdmin.Browser.URL + '{TYPE}/{REDIRECT}{REF}', @@ -114,7 +122,7 @@ function($, _, S, pgAdmin, Backbone, Alertify, Backform) { }); var args = { - 'TYPE': self.type, + 'TYPE': self.node, 'REDIRECT': (type in opURL ? opURL[type] : type), 'REF': S('%s/').sprintf(ref).value() }; diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py index 2d18af7b7..f0c495cef 100644 --- a/web/pgadmin/utils/driver/psycopg2/__init__.py +++ b/web/pgadmin/utils/driver/psycopg2/__init__.py @@ -479,7 +479,15 @@ WHERE db.oid = {0}""".format(did)) return self.connections[my_id] - def release(self, database=None, conn_id=None): + def release(self, database=None, conn_id=None, did=None): + if did is not None: + if did in self.db_info and 'datname' in self.db_info[did]: + database = self.db_info[did]['datname'] + if database is None: + return False + else: + return False + my_id = ('CONN:' + str(conn_id)) if conn_id is not None else \ ('DB:' + str(database)) if database is not None else None @@ -501,7 +509,6 @@ WHERE db.oid = {0}""".format(did)) return True - class Driver(BaseDriver): """ class Driver(BaseDriver):