mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-27 11:10:19 -06:00
f12d981a9d
Made backend changes for: * Taking care of the connection status in the psycopg2 driver. And, when the connection is lost, it throws a exception with 503 http status message, and connection lost information in it. * Allowing the flask application to propagate the exceptions even in the release mode. * Utilising the existing password (while reconnection, if not disconnected explicitly). * Introduced a new ajax response message 'service_unavailable' (http status code: 503), which suggests temporary service unavailable. Client (front-end) changes: * To handle the connection lost of a database server for different operations by generating proper events, and handle them properly. Removed the connection status check code from different nodes, so that - it generates the proper exception, when accessing the non-alive connection. Fixes #1387
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
##########################################################################
|
|
#
|
|
# pgAdmin 4 - PostgreSQL Tools
|
|
#
|
|
# Copyright (C) 2013 - 2016, The pgAdmin Development Team
|
|
# This software is released under the PostgreSQL Licence
|
|
#
|
|
##########################################################################
|
|
|
|
from werkzeug.exceptions import HTTPException
|
|
from werkzeug.http import HTTP_STATUS_CODES
|
|
from flask_babel import gettext as _
|
|
from flask import request
|
|
|
|
from pgadmin.utils.ajax import service_unavailable
|
|
|
|
|
|
class ConnectionLost(HTTPException):
|
|
"""
|
|
Exception
|
|
"""
|
|
|
|
def __init__(self, _server_id, _database_name, _conn_id):
|
|
self.sid = _server_id
|
|
self.db = _database_name
|
|
self.conn_id = _conn_id
|
|
HTTPException.__init__(self)
|
|
|
|
@property
|
|
def name(self):
|
|
return HTTP_STATUS_CODES.get(505, 'Service Unavailable')
|
|
|
|
def get_response(self, environ=None):
|
|
return service_unavailable(
|
|
_("Connection to the server has been lost!"),
|
|
info="CONNECTION_LOST",
|
|
data={
|
|
'sid': self.sid,
|
|
'database': self.db,
|
|
'conn_id': self.conn_id
|
|
}
|
|
)
|