Hi,
Please find the attached patch for RM #1801: Properly handle databases with
datallowconn == false.
Issue: While connecting the database, allowconn parameter was not in
consideration. Also, the database properties query call was on the
selected database which was not correct.
Fix: Put the check of allowconn, while connecting the database in JS file.
Also, the database properties query call set to the maintenance database.
Thanks,
Khushboo
diff --git a/web/pgadmin/browser/collection.py b/web/pgadmin/browser/collection.py
index e4a83a2..391ccf9 100644
--- a/web/pgadmin/browser/collection.py
+++ b/web/pgadmin/browser/collection.py
@@ -66,7 +66,7 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
"id": "%s/%s" % (self.node_type, node_id),
"label": label,
"icon": self.node_icon if not icon else icon,
- "inode": self.node_inode,
+ "inode": self.node_inode if 'inode' not in kwargs else kwargs['inode'],
"_type": self.node_type,
"_id": node_id,
"_pid": parent_id,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
index ed08ef6..5c5374a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
@@ -214,7 +214,8 @@ class DatabaseView(PGChildNodeView):
allowConn=row['datallowconn'],
canCreate=row['cancreate'],
canDisconn=canDisConn,
- canDrop = canDrop
+ canDrop=canDrop,
+ inode=True if row['datallowconn'] else False
)
)
@@ -276,11 +277,13 @@ class DatabaseView(PGChildNodeView):
@check_precondition(action="properties")
def properties(self, gid, sid, did):
+ conn = self.manager.connection()
+
SQL = render_template(
"/".join([self.template_path, 'properties.sql']),
- did=did, conn=self.conn, last_system_oid=0
+ did=did, conn=conn, last_system_oid=0
)
- status, res = self.conn.execute_dict(SQL)
+ status, res = conn.execute_dict(SQL)
if len(res['rows']) == 0:
return gone(
@@ -292,9 +295,9 @@ class DatabaseView(PGChildNodeView):
SQL = render_template(
"/".join([self.template_path, 'acl.sql']),
- did=did, conn=self.conn
+ did=did, conn=conn
)
- status, dataclres = self.conn.execute_dict(SQL)
+ status, dataclres = conn.execute_dict(SQL)
if not status:
return internal_server_error(errormsg=res)
@@ -302,9 +305,9 @@ class DatabaseView(PGChildNodeView):
SQL = render_template(
"/".join([self.template_path, 'defacl.sql']),
- did=did, conn=self.conn
+ did=did, conn=conn
)
- status, defaclres = self.conn.execute_dict(SQL)
+ status, defaclres = conn.execute_dict(SQL)
if not status:
return internal_server_error(errormsg=res)
@@ -314,10 +317,10 @@ class DatabaseView(PGChildNodeView):
# Fetching variable for database
SQL = render_template(
"/".join([self.template_path, 'get_variables.sql']),
- did=did, conn=self.conn
+ did=did, conn=conn
)
- status, res1 = self.conn.execute_dict(SQL)
+ status, res1 = conn.execute_dict(SQL)
if not status:
return internal_server_error(errormsg=res1)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
index 47fc273..9c82be5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
@@ -102,6 +102,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
}
if (i && d) {
+ if (!d.allowConn) return false;
if (_.isUndefined(d.is_connecting) || !d.is_connecting) {
d.is_connecting = true;
@@ -229,7 +230,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
}
pgBrowser.tree.addIcon(item, {icon: data.icon});
- if (!data.connected) {
+ if (!data.connected && data.allowConn) {
connect_to_database(this, data, pgBrowser.tree, item, true);
return false;
}
@@ -242,13 +243,23 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
}
pgBrowser.tree.addIcon(item, {icon: data.icon});
- if (!data.connected) {
+ if (!data.connected && data.allowConn) {
connect_to_database(this, data, pgBrowser.tree, item, false);
return false;
}
return pgBrowser.Node.callbacks.selected.apply(this, arguments);
},
+
+ refresh: function(cmd, i) {
+ var self = this,
+ t = pgBrowser.tree,
+ item = i || t.selected(),
+ d = t.itemData(item);
+
+ if (!d.allowConn) return;
+ pgBrowser.Node.callbacks.refresh.apply(this, arguments);
+ }
},
model: pgBrowser.Node.Model.extend({
defaults: {
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers