Resolved couple of small bugs introduced during database server

connection management implementation.
This commit is contained in:
Ashesh Vashi
2015-10-28 22:34:23 +05:30
parent a0cfddffdf
commit c53b57a013
5 changed files with 20 additions and 18 deletions

View File

@@ -493,7 +493,7 @@ class ServerNode(NodeView):
"""Check and return the connection status.""" """Check and return the connection status."""
from pgadmin.utils.driver import get_driver from pgadmin.utils.driver import get_driver
manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid) manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
conn = manager.get_connection() conn = manager.connection()
return make_json_response(data={'connected': conn.connected()}) return make_json_response(data={'connected': conn.connected()})

View File

@@ -1,6 +1,10 @@
.icon-server { .icon-server {
background-image: url('{{ url_for('NODE-server.static', filename='img/server.png') }}') !important; background-image: url('{{ url_for('NODE-server.static', filename='img/server.png') }}') !important;
border-radius: 10px border-radius: 10px;
background-repeat: no-repeat;
align-content: center;
vertical-align: middle;
height: 1.3em;
} }
.icon-server-not-connected { .icon-server-not-connected {

View File

@@ -203,22 +203,22 @@
background-color: #A44; background-color: #A44;
} }
.wcButtonHover, .wcButton:hover, button:hover { .wcButtonHover, .wcButton:hover {
border: 1px outset #B66; border: 1px outset #B66;
background-color: #B66; background-color: #B66;
} }
.wcButtonActive, .wcButton:active, button:active { .wcButtonActive, .wcButton:active {
border: 1px inset #B66; border: 1px inset #B66;
background-color: #B66; background-color: #B66;
} }
.wcButtonActive.wcButtonHover, .wcButton:hover.wcButtonActive, .wcButton:active.wcButtonHover, .wcButton:active:hover, button:active:hover { .wcButtonActive.wcButtonHover, .wcButton:hover.wcButtonActive, .wcButton:active.wcButtonHover, .wcButton:active:hover {
border: 1px inset #C88; border: 1px inset #C88;
background-color: #C88; background-color: #C88;
} }
.wcButtonDisabled, .wcButton.disabled, button:disabled { .wcButtonDisabled, .wcButton.disabled {
border: 1px outset #933 !important; border: 1px outset #933 !important;
background-color: #933 !important; background-color: #933 !important;
color: #533 !important; color: #533 !important;

View File

@@ -1,6 +1,6 @@
require( require(
['alertify'], ['alertify', 'underscore.string'],
function(alertify) { function(alertify, S) {
alertify.defaults.transition = "zoom"; alertify.defaults.transition = "zoom";
alertify.defaults.theme.ok = "btn btn-primary"; alertify.defaults.theme.ok = "btn btn-primary";
alertify.defaults.theme.cancel = "btn btn-danger"; alertify.defaults.theme.cancel = "btn btn-danger";

View File

@@ -418,7 +418,8 @@ class ServerManager(object):
def connection(self, database=None, conn_id=None, auto_reconnect=True): def connection(self, database=None, conn_id=None, auto_reconnect=True):
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)) ('DB:' + (str(database) if database is not None else \
self.db))
self.pinged = datetime.now() self.pinged = datetime.now()
@@ -507,7 +508,7 @@ class Driver(BaseDriver):
managers = self.managers[session['_id']] managers = self.managers[session['_id']]
managers['pinged'] = datetime.datetime.now() managers['pinged'] = datetime.datetime.now()
if sid not in managers: if str(sid) not in managers:
from pgadmin.settings.settings_model import Server from pgadmin.settings.settings_model import Server
s = Server.query.filter_by(id=sid).first() s = Server.query.filter_by(id=sid).first()
@@ -560,16 +561,16 @@ class Driver(BaseDriver):
connection, and it stops working on disconnection. connection, and it stops working on disconnection.
""" """
manager = connection_manager(sid) manager = self.connection_manager(sid)
return manager.connection(database, conn_id, connect, **kwargs) return manager.connection(database, conn_id, auto_reconnect)
def release_connection(self, sid, database=None, conn_id=None): def release_connection(self, sid, database=None, conn_id=None):
""" """
Release the connection for the given connection-id/database in this Release the connection for the given connection-id/database in this
session. session.
""" """
return connection_manager(sid).release(database, conn_id) return self.connection_manager(sid).release(database, conn_id)
def gc(self): def gc(self):
""" """
@@ -577,13 +578,10 @@ class Driver(BaseDriver):
server for more than config.MAX_SESSION_IDLE_TIME. server for more than config.MAX_SESSION_IDLE_TIME.
""" """
import datetime import datetime
from config import MAX_SESSION_IDLE_TIME import config
assert(MAX_SESSION_IDLE_TIME is not None and
isinstance(MAX_SESSION_IDLE_TIME, int))
# Mininum session idle is 20 minutes # Mininum session idle is 20 minutes
max_idle_time = max(MAX_SESSION_IDLE_TIME, 20) max_idle_time = max(config.MAX_SESSION_IDLE_TIME or 60, 20)
session_idle_timeout = datetime.timedelta(minutes=max_idle_time) session_idle_timeout = datetime.timedelta(minutes=max_idle_time)
curr_time = datetime.datetime.now() curr_time = datetime.datetime.now()