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).
pull/3/head
Ashesh Vashi 2015-11-20 14:55:47 +05:30
parent e52fd0d349
commit 9bc9025075
4 changed files with 26 additions and 11 deletions

View File

@ -13,7 +13,7 @@ from flask import url_for, render_template
from flask.ext.babel import gettext from flask.ext.babel import gettext
from pgadmin.browser.utils import PgAdminModule, PGChildModule from pgadmin.browser.utils import PgAdminModule, PGChildModule
from pgadmin.browser import BrowserPluginModule from pgadmin.browser import BrowserPluginModule
from pgadmin.browser.utils import NodeView, PGChildNode, PGChildNodeView from pgadmin.browser.utils import PGChildNodeView
@six.add_metaclass(ABCMeta) @six.add_metaclass(ABCMeta)
class CollectionNodeModule(PgAdminModule, PGChildModule): class CollectionNodeModule(PgAdminModule, PGChildModule):
@ -86,7 +86,7 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
@property @property
def node_type(self): def node_type(self):
return '%s-%s' % (self.SERVER_TYPE, self.NODE_TYPE) return '%s' % (self.NODE_TYPE)
@property @property
def csssnippets(self): def csssnippets(self):
@ -171,7 +171,7 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
return [] return []
class CollectionNodeView(NodeView, PGChildNode): class CollectionNodeView(PGChildNodeView):
""" """
A PostgreSQL Collection node has specific functions needs to address A PostgreSQL Collection node has specific functions needs to address
i.e. i.e.

View File

@ -62,7 +62,7 @@ class ServerModule(sg.ServerGroupPluginModule):
self.NODE_TYPE, self.NODE_TYPE,
connected=connected, connected=connected,
server_type=manager.server_type if connected else "pg", server_type=manager.server_type if connected else "pg",
server_version=manager.sversion if connected else 0 version=manager.version
) )
@property @property
@ -137,7 +137,7 @@ class ServerNode(PGChildNodeView):
self.node_type, self.node_type,
connected=connected, connected=connected,
server_type=manager.server_type if connected else 'PG', server_type=manager.server_type if connected else 'PG',
version=manager.sversion version=manager.version
) )
) )
return make_json_response(result=res) return make_json_response(result=res)
@ -295,7 +295,7 @@ class ServerNode(PGChildNodeView):
'comment': server.comment, 'comment': server.comment,
'role': server.role, 'role': server.role,
'connected': connected, 'connected': connected,
'version': manager.sversion, 'version': manager.ver,
'server_type': manager.server_type if connected else 'PG' 'server_type': manager.server_type if connected else 'PG'
} }
) )
@ -522,7 +522,7 @@ class ServerNode(PGChildNodeView):
), ),
'connected': True, 'connected': True,
'type': manager.server_type, 'type': manager.server_type,
'version': manager.sversion 'version': manager.version
} }
) )

View File

@ -86,7 +86,15 @@ function($, _, S, pgAdmin, Backbone, Alertify, Backform) {
j.append(content); j.append(content);
// Fetch Data // 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) { generate_url: function(item, type, d) {
var url = pgAdmin.Browser.URL + '{TYPE}/{REDIRECT}{REF}', var url = pgAdmin.Browser.URL + '{TYPE}/{REDIRECT}{REF}',
@ -114,7 +122,7 @@ function($, _, S, pgAdmin, Backbone, Alertify, Backform) {
}); });
var args = { var args = {
'TYPE': self.type, 'TYPE': self.node,
'REDIRECT': (type in opURL ? opURL[type] : type), 'REDIRECT': (type in opURL ? opURL[type] : type),
'REF': S('%s/').sprintf(ref).value() 'REF': S('%s/').sprintf(ref).value()
}; };

View File

@ -479,7 +479,15 @@ WHERE db.oid = {0}""".format(did))
return self.connections[my_id] 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 \ my_id = ('CONN:' + str(conn_id)) if conn_id is not None else \
('DB:' + str(database)) if database is not None else None ('DB:' + str(database)) if database is not None else None
@ -501,7 +509,6 @@ WHERE db.oid = {0}""".format(did))
return True return True
class Driver(BaseDriver): class Driver(BaseDriver):
""" """
class Driver(BaseDriver): class Driver(BaseDriver):