PEP8 fixes.
parent
51811a451d
commit
43d3e0ca64
|
@ -291,8 +291,8 @@ def create_app(app_name=None):
|
|||
# Setup authentication
|
||||
##########################################################################
|
||||
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = u'sqlite:///{0}?timeout={1}'.format(
|
||||
config.SQLITE_PATH.replace(u'\\', u'/'),
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = u'sqlite:///{0}?timeout={1}'\
|
||||
.format(config.SQLITE_PATH.replace(u'\\', u'/'),
|
||||
getattr(config, 'SQLITE_TIMEOUT', 500)
|
||||
)
|
||||
|
||||
|
@ -406,7 +406,8 @@ def create_app(app_name=None):
|
|||
servergroup_id = servergroup.id
|
||||
|
||||
'''Add a server to the config database'''
|
||||
def add_server(user_id, servergroup_id, name, superuser, port, discovery_id, comment):
|
||||
def add_server(user_id, servergroup_id, name, superuser, port,
|
||||
discovery_id, comment):
|
||||
# Create a server object if needed, and store it.
|
||||
servers = Server.query.filter_by(
|
||||
user_id=user_id,
|
||||
|
@ -437,7 +438,7 @@ def create_app(app_name=None):
|
|||
|
||||
try:
|
||||
proc_arch64 = os.environ['PROCESSOR_ARCHITEW6432'].lower()
|
||||
except:
|
||||
except Exception as e:
|
||||
proc_arch64 = None
|
||||
|
||||
if proc_arch == 'x86' and not proc_arch64:
|
||||
|
@ -467,7 +468,8 @@ def create_app(app_name=None):
|
|||
svr_port = winreg.QueryValueEx(inst_key, 'Port')[0]
|
||||
svr_discovery_id = inst_id
|
||||
svr_comment = gettext(
|
||||
"Auto-detected %s installation with the data directory at %s" % (
|
||||
"Auto-detected %s installation with the data "
|
||||
"directory at %s" % (
|
||||
winreg.QueryValueEx(
|
||||
inst_key, 'Display Name'
|
||||
)[0],
|
||||
|
@ -484,7 +486,7 @@ def create_app(app_name=None):
|
|||
)
|
||||
|
||||
inst_key.Close()
|
||||
except:
|
||||
except Exception as e:
|
||||
pass
|
||||
else:
|
||||
# We use the postgres-winreg.ini file on non-Windows
|
||||
|
@ -501,7 +503,8 @@ def create_app(app_name=None):
|
|||
|
||||
# Loop the sections, and get the data from any that are PG or PPAS
|
||||
for section in sections:
|
||||
if section.startswith('PostgreSQL/') or section.startswith('EnterpriseDB/'):
|
||||
if section.startswith('PostgreSQL/') \
|
||||
or section.startswith('EnterpriseDB/'):
|
||||
svr_name = registry.get(section, 'Description')
|
||||
svr_superuser = registry.get(section, 'Superuser')
|
||||
svr_port = registry.getint(section, 'Port')
|
||||
|
@ -511,14 +514,17 @@ def create_app(app_name=None):
|
|||
if hasattr(str, 'decode'):
|
||||
description = description.decode('utf-8')
|
||||
data_directory = data_directory.decode('utf-8')
|
||||
svr_comment = gettext(u"Auto-detected %s installation with the data directory at %s" % (
|
||||
svr_comment = gettext(u"Auto-detected %s installation "
|
||||
u"with the data directory at %s" % (
|
||||
description,
|
||||
data_directory
|
||||
))
|
||||
)
|
||||
)
|
||||
add_server(user_id, servergroup_id, svr_name,
|
||||
svr_superuser, svr_port, svr_discovery_id, svr_comment)
|
||||
svr_superuser, svr_port, svr_discovery_id,
|
||||
svr_comment)
|
||||
|
||||
except:
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
@user_logged_in.connect_via(app)
|
||||
|
@ -545,7 +551,8 @@ def create_app(app_name=None):
|
|||
# mode, and it's not a help file request.
|
||||
if not config.SERVER_MODE and app.PGADMIN_KEY != '':
|
||||
if (
|
||||
(not 'key' in request.args or request.args['key'] != app.PGADMIN_KEY) and
|
||||
('key' not in request.args or
|
||||
request.args['key'] != app.PGADMIN_KEY) and
|
||||
request.cookies.get('PGADMIN_KEY') != app.PGADMIN_KEY and
|
||||
request.endpoint != 'help.static'
|
||||
):
|
||||
|
@ -558,7 +565,8 @@ def create_app(app_name=None):
|
|||
# that'll through a nice 500 error for us.
|
||||
if user is None:
|
||||
app.logger.error(
|
||||
'The desktop user %s was not found in the configuration database.'
|
||||
'The desktop user %s was not found in the configuration '
|
||||
'database.'
|
||||
% config.DESKTOP_USER
|
||||
)
|
||||
abort(401)
|
||||
|
|
|
@ -15,8 +15,8 @@ from socket import error as SOCKETErrorException
|
|||
from smtplib import SMTPConnectError, SMTPResponseException,\
|
||||
SMTPServerDisconnected, SMTPDataError, SMTPHeloError, SMTPException, \
|
||||
SMTPAuthenticationError, SMTPSenderRefused, SMTPRecipientsRefused
|
||||
from flask import current_app, render_template, url_for, make_response, flash,\
|
||||
Response, request, after_this_request, redirect
|
||||
from flask import current_app, render_template, url_for, make_response, \
|
||||
flash, Response, request, after_this_request, redirect
|
||||
from flask_babel import gettext
|
||||
from flask_login import current_user, login_required
|
||||
from flask_security.decorators import anonymous_user_required
|
||||
|
@ -40,7 +40,7 @@ from pgadmin import current_blueprint
|
|||
|
||||
try:
|
||||
import urllib.request as urlreq
|
||||
except:
|
||||
except ImportError as e:
|
||||
import urllib2 as urlreq
|
||||
|
||||
MODULE_NAME = 'browser'
|
||||
|
@ -55,9 +55,12 @@ class BrowserModule(PgAdminModule):
|
|||
for (endpoint, filename) in [
|
||||
('static', 'vendor/codemirror/codemirror.css'),
|
||||
('static', 'vendor/codemirror/addon/dialog/dialog.css'),
|
||||
('static', 'vendor/jQuery-contextMenu/jquery.contextMenu.css' if current_app.debug
|
||||
else 'vendor/jQuery-contextMenu/jquery.contextMenu.min.css'),
|
||||
('static', 'vendor/wcDocker/wcDocker.css' if current_app.debug
|
||||
('static', 'vendor/jQuery-contextMenu/jquery.contextMenu.css'
|
||||
if current_app.debug
|
||||
else
|
||||
'vendor/jQuery-contextMenu/jquery.contextMenu.min.css'),
|
||||
('static', 'vendor/wcDocker/wcDocker.css'
|
||||
if current_app.debug
|
||||
else 'vendor/wcDocker/wcDocker.min.css'),
|
||||
('browser.static', 'css/browser.css'),
|
||||
('browser.static', 'vendor/aciTree/css/aciTree.css')
|
||||
|
@ -82,8 +85,8 @@ class BrowserModule(PgAdminModule):
|
|||
'name': 'jqueryui.position',
|
||||
'path': url_for(
|
||||
'static',
|
||||
filename='vendor/jQuery-contextMenu/jquery.ui.position' if \
|
||||
current_app.debug else \
|
||||
filename='vendor/jQuery-contextMenu/jquery.ui.position' if
|
||||
current_app.debug else
|
||||
'vendor/jQuery-contextMenu/jquery.ui.position.min'
|
||||
),
|
||||
'deps': ['jquery'],
|
||||
|
@ -94,8 +97,8 @@ class BrowserModule(PgAdminModule):
|
|||
'name': 'jquery.contextmenu',
|
||||
'path': url_for(
|
||||
'static',
|
||||
filename='vendor/jQuery-contextMenu/jquery.contextMenu' if \
|
||||
current_app.debug else \
|
||||
filename='vendor/jQuery-contextMenu/jquery.contextMenu' if
|
||||
current_app.debug else
|
||||
'vendor/jQuery-contextMenu/jquery.contextMenu.min'
|
||||
),
|
||||
'deps': ['jquery', 'jqueryui.position'],
|
||||
|
@ -437,6 +440,7 @@ class BrowserModule(PgAdminModule):
|
|||
"""
|
||||
return ['browser.index', 'browser.nodes']
|
||||
|
||||
|
||||
blueprint = BrowserModule(MODULE_NAME, __name__)
|
||||
|
||||
|
||||
|
@ -471,7 +475,8 @@ class BrowserPluginModule(PgAdminModule):
|
|||
Every module extended from this will be identified as 'NODE-<type>'.
|
||||
|
||||
Also, create a preference 'show_node_<type>' to fetch whether it
|
||||
can be shown in the browser or not. Also, refer to the browser-preference.
|
||||
can be shown in the browser or not. Also, refer to the
|
||||
browser-preference.
|
||||
"""
|
||||
kwargs.setdefault("url_prefix", self.node_path)
|
||||
kwargs.setdefault("static_url_path", '/static')
|
||||
|
@ -525,7 +530,8 @@ class BrowserPluginModule(PgAdminModule):
|
|||
if self.module_use_template_javascript:
|
||||
scripts.extend([{
|
||||
'name': 'pgadmin.node.%s' % self.node_type,
|
||||
'path': url_for('browser.index') + '%s/module' % self.node_type,
|
||||
'path': url_for('browser.index') +
|
||||
'%s/module' % self.node_type,
|
||||
'when': self.script_load,
|
||||
'is_template': True
|
||||
}])
|
||||
|
@ -533,7 +539,8 @@ class BrowserPluginModule(PgAdminModule):
|
|||
scripts.extend([{
|
||||
'name': 'pgadmin.node.%s' % self.node_type,
|
||||
'path': url_for(
|
||||
'%s.static'% self.name, filename=('js/%s' % self.node_type)
|
||||
'%s.static' % self.name,
|
||||
filename=('js/%s' % self.node_type)
|
||||
),
|
||||
'when': self.script_load,
|
||||
'is_template': False
|
||||
|
@ -648,7 +655,8 @@ class BrowserPluginModule(PgAdminModule):
|
|||
@property
|
||||
def show_node(self):
|
||||
"""
|
||||
A proper to check to show node for this module on the browser tree or not.
|
||||
A proper to check to show node for this module on the browser tree or
|
||||
not.
|
||||
|
||||
Relies on show_node preference object, otherwise on the SHOW_ON_BROWSER
|
||||
default value.
|
||||
|
@ -675,14 +683,16 @@ class BrowserPluginModule(PgAdminModule):
|
|||
Sets the browser_preference, show_system_objects, show_node preference
|
||||
objects for this submodule.
|
||||
"""
|
||||
# Add the node informaton for browser, not in respective node preferences
|
||||
# Add the node informaton for browser, not in respective node
|
||||
# preferences
|
||||
self.browser_preference = blueprint.preference
|
||||
self.pref_show_system_objects = blueprint.preference.preference(
|
||||
'display', 'show_system_objects'
|
||||
)
|
||||
self.pref_show_node = self.browser_preference.preference(
|
||||
'node', 'show_node_' + self.node_type,
|
||||
self.label, 'boolean', self.SHOW_ON_BROWSER, category_label=gettext('Nodes')
|
||||
self.label, 'boolean', self.SHOW_ON_BROWSER,
|
||||
category_label=gettext('Nodes')
|
||||
)
|
||||
|
||||
|
||||
|
@ -721,7 +731,7 @@ def index():
|
|||
if response.getcode() == 200:
|
||||
data = json.loads(response.read().decode('utf-8'))
|
||||
current_app.logger.debug('Response data: %s' % data)
|
||||
except:
|
||||
except Exception as e:
|
||||
current_app.logger.exception('Exception when checking for update')
|
||||
|
||||
if data is not None:
|
||||
|
@ -799,7 +809,7 @@ def utils():
|
|||
from pgadmin.utils.driver import get_driver
|
||||
driver = get_driver(PG_DEFAULT_DRIVER)
|
||||
pg_libpq_version = driver.libpq_version()
|
||||
except:
|
||||
except Exception as e:
|
||||
pg_libpq_version = 0
|
||||
|
||||
for submodule in current_blueprint.submodules:
|
||||
|
@ -887,7 +897,9 @@ def browser_css():
|
|||
sql_font_size = round(float(sql_font_size_pref.get()), 2)
|
||||
|
||||
if sql_font_size != 0:
|
||||
snippets.append('.CodeMirror { font-size: %sem; }' % str(sql_font_size))
|
||||
snippets.append(
|
||||
'.CodeMirror { font-size: %sem; }' % str(sql_font_size)
|
||||
)
|
||||
|
||||
for submodule in blueprint.submodules:
|
||||
snippets.extend(submodule.csssnippets)
|
||||
|
@ -911,6 +923,8 @@ def get_nodes():
|
|||
# Only register route if SECURITY_CHANGEABLE is set to True
|
||||
# We can't access app context here so cannot
|
||||
# use app.config['SECURITY_CHANGEABLE']
|
||||
|
||||
|
||||
if hasattr(config, 'SECURITY_CHANGEABLE') and config.SECURITY_CHANGEABLE:
|
||||
@blueprint.route("/change_password", endpoint="change_password",
|
||||
methods=['GET', 'POST'])
|
||||
|
@ -932,7 +946,10 @@ if hasattr(config, 'SECURITY_CHANGEABLE') and config.SECURITY_CHANGEABLE:
|
|||
except SOCKETErrorException as e:
|
||||
# Handle socket errors which are not covered by SMTPExceptions.
|
||||
logging.exception(str(e), exc_info=True)
|
||||
flash(gettext(u'SMTP Socket error: {}\nYour password has not been changed.').format(e), 'danger')
|
||||
flash(gettext(u'SMTP Socket error: {}\n'
|
||||
u'Your password has not been changed.'
|
||||
).format(e),
|
||||
'danger')
|
||||
has_error = True
|
||||
except (SMTPConnectError, SMTPResponseException,
|
||||
SMTPServerDisconnected, SMTPDataError, SMTPHeloError,
|
||||
|
@ -940,12 +957,18 @@ if hasattr(config, 'SECURITY_CHANGEABLE') and config.SECURITY_CHANGEABLE:
|
|||
SMTPRecipientsRefused) as e:
|
||||
# Handle smtp specific exceptions.
|
||||
logging.exception(str(e), exc_info=True)
|
||||
flash(gettext(u'SMTP error: {}\nYour password has not been changed.').format(e), 'danger')
|
||||
flash(gettext(u'SMTP error: {}\n'
|
||||
u'Your password has not been changed.'
|
||||
).format(e),
|
||||
'danger')
|
||||
has_error = True
|
||||
except Exception as e:
|
||||
# Handle other exceptions.
|
||||
logging.exception(str(e), exc_info=True)
|
||||
flash(gettext(u'Error: {}\nYour password has not been changed.').format(e), 'danger')
|
||||
flash(gettext(u'Error: {}\n'
|
||||
u'Your password has not been changed.'
|
||||
).format(e),
|
||||
'danger')
|
||||
has_error = True
|
||||
|
||||
if request.json is None and not has_error:
|
||||
|
@ -984,7 +1007,6 @@ if hasattr(config, 'SECURITY_RECOVERABLE') and config.SECURITY_RECOVERABLE:
|
|||
current_app._get_current_object(),
|
||||
user=user, token=token)
|
||||
|
||||
|
||||
@blueprint.route("/reset_password", endpoint="forgot_password",
|
||||
methods=['GET', 'POST'])
|
||||
@anonymous_user_required
|
||||
|
@ -1004,7 +1026,10 @@ if hasattr(config, 'SECURITY_RECOVERABLE') and config.SECURITY_RECOVERABLE:
|
|||
except SOCKETErrorException as e:
|
||||
# Handle socket errors which are not covered by SMTPExceptions.
|
||||
logging.exception(str(e), exc_info=True)
|
||||
flash(gettext(u'SMTP Socket error: {}\nYour password has not been changed.').format(e), 'danger')
|
||||
flash(gettext(u'SMTP Socket error: {}\n'
|
||||
u'Your password has not been changed.'
|
||||
).format(e),
|
||||
'danger')
|
||||
has_error = True
|
||||
except (SMTPConnectError, SMTPResponseException,
|
||||
SMTPServerDisconnected, SMTPDataError, SMTPHeloError,
|
||||
|
@ -1013,12 +1038,18 @@ if hasattr(config, 'SECURITY_RECOVERABLE') and config.SECURITY_RECOVERABLE:
|
|||
|
||||
# Handle smtp specific exceptions.
|
||||
logging.exception(str(e), exc_info=True)
|
||||
flash(gettext(u'SMTP error: {}\nYour password has not been changed.').format(e), 'danger')
|
||||
flash(gettext(u'SMTP error: {}\n'
|
||||
u'Your password has not been changed.'
|
||||
).format(e),
|
||||
'danger')
|
||||
has_error = True
|
||||
except Exception as e:
|
||||
# Handle other exceptions.
|
||||
logging.exception(str(e), exc_info=True)
|
||||
flash(gettext(u'Error: {}\nYour password has not been changed.').format(e), 'danger')
|
||||
flash(gettext(u'Error: {}\n'
|
||||
u'Your password has not been changed.'
|
||||
).format(e),
|
||||
'danger')
|
||||
has_error = True
|
||||
|
||||
if request.json is None and not has_error:
|
||||
|
@ -1033,8 +1064,8 @@ if hasattr(config, 'SECURITY_RECOVERABLE') and config.SECURITY_RECOVERABLE:
|
|||
forgot_password_form=form,
|
||||
**_ctx('forgot_password'))
|
||||
|
||||
|
||||
# We are not in app context so cannot use url_for('browser.forgot_password')
|
||||
# We are not in app context so cannot use
|
||||
# url_for('browser.forgot_password')
|
||||
# So hard code the url '/browser/reset_password' while passing as
|
||||
# parameter to slash_url_suffix function.
|
||||
@blueprint.route('/reset_password' + slash_url_suffix(
|
||||
|
@ -1063,7 +1094,10 @@ if hasattr(config, 'SECURITY_RECOVERABLE') and config.SECURITY_RECOVERABLE:
|
|||
except SOCKETErrorException as e:
|
||||
# Handle socket errors which are not covered by SMTPExceptions.
|
||||
logging.exception(str(e), exc_info=True)
|
||||
flash(gettext(u'SMTP Socket error: {}\nYour password has not been changed.').format(e), 'danger')
|
||||
flash(gettext(u'SMTP Socket error: {}\n'
|
||||
u'Your password has not been changed.'
|
||||
).format(e),
|
||||
'danger')
|
||||
has_error = True
|
||||
except (SMTPConnectError, SMTPResponseException,
|
||||
SMTPServerDisconnected, SMTPDataError, SMTPHeloError,
|
||||
|
@ -1072,12 +1106,18 @@ if hasattr(config, 'SECURITY_RECOVERABLE') and config.SECURITY_RECOVERABLE:
|
|||
|
||||
# Handle smtp specific exceptions.
|
||||
logging.exception(str(e), exc_info=True)
|
||||
flash(gettext(u'SMTP error: {}\nYour password has not been changed.').format(e), 'danger')
|
||||
flash(gettext(u'SMTP error: {}\n'
|
||||
u'Your password has not been changed.'
|
||||
).format(e),
|
||||
'danger')
|
||||
has_error = True
|
||||
except Exception as e:
|
||||
# Handle other exceptions.
|
||||
logging.exception(str(e), exc_info=True)
|
||||
flash(gettext(u'Error: {}\nYour password has not been changed.').format(e), 'danger')
|
||||
flash(gettext(u'Error: {}\n'
|
||||
u'Your password has not been changed.'
|
||||
).format(e),
|
||||
'danger')
|
||||
has_error = True
|
||||
|
||||
if not has_error:
|
||||
|
|
|
@ -53,14 +53,14 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
|
|||
"""
|
||||
return True
|
||||
|
||||
|
||||
def get_own_javascripts(self):
|
||||
scripts = []
|
||||
|
||||
if self.module_use_template_javascript:
|
||||
scripts.extend([{
|
||||
'name': 'pgadmin.node.%s' % self.node_type,
|
||||
'path': url_for('browser.index') + '%s/module' % self.node_type,
|
||||
'path': url_for('browser.index') +
|
||||
'%s/module' % self.node_type,
|
||||
'when': self.script_load,
|
||||
'is_template': True
|
||||
}])
|
||||
|
@ -68,7 +68,8 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
|
|||
scripts.extend([{
|
||||
'name': 'pgadmin.node.%s' % self.node_type,
|
||||
'path': url_for(
|
||||
'%s.static'% self.name, filename=('js/%s' % self.node_type)
|
||||
'%s.static' % self.name,
|
||||
filename=('js/%s' % self.node_type)
|
||||
),
|
||||
'when': self.script_load,
|
||||
'is_template': False
|
||||
|
@ -86,7 +87,9 @@ 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 if 'inode' not in kwargs else kwargs['inode'],
|
||||
"inode": self.node_inode
|
||||
if 'inode' not in kwargs
|
||||
else kwargs['inode'],
|
||||
"_type": self.node_type,
|
||||
"_id": node_id,
|
||||
"_pid": parent_id,
|
||||
|
@ -236,7 +239,8 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
|
|||
along with that get two browser level preferences show_system_objects,
|
||||
and show_node will be registered to used by the submodules.
|
||||
"""
|
||||
# Add the node informaton for browser, not in respective node preferences
|
||||
# Add the node informaton for browser, not in respective node
|
||||
# preferences
|
||||
self.browser_preference = Preferences.module('browser')
|
||||
self.pref_show_system_objects = self.browser_preference.preference(
|
||||
'show_system_objects'
|
||||
|
|
|
@ -19,6 +19,7 @@ from pgadmin.utils.ajax import make_json_response, precondition_required
|
|||
|
||||
from config import PG_DEFAULT_DRIVER
|
||||
|
||||
|
||||
def is_version_in_range(sversion, min_ver, max_ver):
|
||||
assert (max_ver is None or isinstance(max_ver, int))
|
||||
assert (min_ver is None or isinstance(min_ver, int))
|
||||
|
@ -31,13 +32,14 @@ def is_version_in_range(sversion, min_ver, max_ver):
|
|||
return True
|
||||
return False
|
||||
|
||||
|
||||
class PGChildModule(object):
|
||||
"""
|
||||
class PGChildModule
|
||||
|
||||
This is a base class for children/grand-children of PostgreSQL, and
|
||||
all EDB Postgres Advanced Server version (i.e. EDB Postgres Advanced Server, Green Plum,
|
||||
etc).
|
||||
all EDB Postgres Advanced Server version
|
||||
(i.e. EDB Postgres Advanced Server, Green Plum, etc).
|
||||
|
||||
Method:
|
||||
------
|
||||
|
@ -68,8 +70,12 @@ class PGChildModule(object):
|
|||
assert (self.server_type is None or isinstance(self.server_type, list))
|
||||
|
||||
if self.server_type is None or manager.server_type in self.server_type:
|
||||
return is_version_in_range(sversion, self.min_gpdbver if manager.server_type == 'gpdb' else self.min_ver,
|
||||
self.max_gpdbver if manager.server_type == 'gpdb' else self.max_ver)
|
||||
return is_version_in_range(sversion, self.min_gpdbver
|
||||
if manager.server_type == 'gpdb'
|
||||
else self.min_ver,
|
||||
self.max_gpdbver
|
||||
if manager.server_type == 'gpdb'
|
||||
else self.max_ver)
|
||||
|
||||
return False
|
||||
|
||||
|
@ -173,7 +179,8 @@ class NodeView(with_metaclass(MethodViewType, View)):
|
|||
|
||||
id_url = None
|
||||
for p in cls.ids:
|
||||
id_url = '{0}<{1}:{2}>'.format(common_url if not id_url else id_url,
|
||||
id_url = '{0}<{1}:{2}>'.format(
|
||||
common_url if not id_url else id_url,
|
||||
p['type'], p['id'])
|
||||
|
||||
return id_url, common_url
|
||||
|
@ -217,15 +224,16 @@ class NodeView(with_metaclass(MethodViewType, View)):
|
|||
meth in self.operations[self.cmd][1]) or
|
||||
(len(self.operations[self.cmd]) > 2 and
|
||||
meth in self.operations[self.cmd][2])), \
|
||||
"Unimplemented method ({0}) for command ({1}), which {2} an id".format(
|
||||
"Unimplemented method ({0}) for command ({1}), which {2} an id"\
|
||||
.format(
|
||||
meth, self.cmd,
|
||||
'requires' if has_id else 'does not require'
|
||||
)
|
||||
|
||||
meth = self.operations[self.cmd][0][meth] if has_id else \
|
||||
self.operations[self.cmd][1][meth] if has_args and \
|
||||
meth in self.operations[self.cmd][1] else \
|
||||
self.operations[self.cmd][2][meth]
|
||||
self.operations[self.cmd][1][meth] \
|
||||
if has_args and meth in self.operations[self.cmd][1] \
|
||||
else self.operations[self.cmd][2][meth]
|
||||
|
||||
method = getattr(self, meth, None)
|
||||
|
||||
|
@ -367,7 +375,8 @@ class PGChildNodeView(NodeView):
|
|||
|
||||
# fetch role dependencies
|
||||
if where_clause.find('subid') < 0:
|
||||
sql = render_template("/".join([sql_path, 'role_dependencies.sql']),
|
||||
sql = render_template(
|
||||
"/".join([sql_path, 'role_dependencies.sql']),
|
||||
where_clause=where_clause)
|
||||
|
||||
status, result = conn.execute_dict(sql)
|
||||
|
@ -385,7 +394,11 @@ class PGChildNodeView(NodeView):
|
|||
dep_type = 'Owner'
|
||||
|
||||
if row['refclassid'] == 1260:
|
||||
dependencies.append({'type': 'role', 'name': ref_name, 'field': dep_type})
|
||||
dependencies.append(
|
||||
{'type': 'role',
|
||||
'name': ref_name,
|
||||
'field': dep_type}
|
||||
)
|
||||
|
||||
return dependencies
|
||||
|
||||
|
@ -489,7 +502,8 @@ class PGChildNodeView(NodeView):
|
|||
type_name = 'table'
|
||||
elif type_str[0] == 'R':
|
||||
type_name = 'rule'
|
||||
ref_name = _ref_name + ' ON ' + ref_name + row['ownertable']
|
||||
ref_name = \
|
||||
_ref_name + ' ON ' + ref_name + row['ownertable']
|
||||
_ref_name = None
|
||||
elif type_str[0] == 'C':
|
||||
if type_str[1] == 'c':
|
||||
|
@ -535,6 +549,12 @@ class PGChildNodeView(NodeView):
|
|||
else:
|
||||
dep_type = dep_types[dep_str[0]]
|
||||
|
||||
dependency.append({'type': type_name, 'name': ref_name, 'field': dep_type})
|
||||
dependency.append(
|
||||
{
|
||||
'type': type_name,
|
||||
'name': ref_name,
|
||||
'field': dep_type
|
||||
}
|
||||
)
|
||||
|
||||
return dependency
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
##########################################################################
|
||||
|
||||
"""A blueprint module implementing the pgAdmin help system."""
|
||||
MODULE_NAME = 'help'
|
||||
|
||||
from flask import url_for
|
||||
from flask_babel import gettext
|
||||
from pgadmin.utils import PgAdminModule
|
||||
|
@ -17,6 +15,8 @@ from pgadmin.utils.menu import MenuItem, Panel
|
|||
from pgadmin.utils.preferences import Preferences
|
||||
import config
|
||||
|
||||
MODULE_NAME = 'help'
|
||||
|
||||
|
||||
class HelpModule(PgAdminModule):
|
||||
def get_own_menuitems(self):
|
||||
|
|
Loading…
Reference in New Issue