mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Code tidy.
This commit is contained in:
@@ -87,7 +87,7 @@ FILE_LOG_FORMAT = '%(asctime)s: %(levelname)s\t%(name)s:\t%(message)s'
|
||||
LOG_FILE = os.path.join(
|
||||
DATA_DIR,
|
||||
'pgadmin4.log'
|
||||
)
|
||||
)
|
||||
|
||||
##########################################################################
|
||||
# Server settings
|
||||
@@ -139,7 +139,6 @@ SECURITY_PASSWORD_HASH = 'pbkdf2_sha512'
|
||||
# Should HTML be minified on the fly when not in debug mode?
|
||||
MINIFY_HTML = True
|
||||
|
||||
|
||||
##########################################################################
|
||||
# Server Connection Driver Settings
|
||||
##########################################################################
|
||||
@@ -165,7 +164,7 @@ SETTINGS_SCHEMA_VERSION = 11
|
||||
SQLITE_PATH = os.path.join(
|
||||
DATA_DIR,
|
||||
'pgadmin4.db'
|
||||
)
|
||||
)
|
||||
# SQLITE_TIMEOUT will define how long to wait before throwing the error -
|
||||
# OperationError due to database lock. On slower system, you may need to change
|
||||
# this to some higher value.
|
||||
@@ -195,7 +194,7 @@ SQLITE_TIMEOUT = 500
|
||||
SESSION_DB_PATH = os.path.join(
|
||||
DATA_DIR,
|
||||
'sessions'
|
||||
)
|
||||
)
|
||||
|
||||
SESSION_COOKIE_NAME = 'pga4_session'
|
||||
|
||||
@@ -217,11 +216,11 @@ MAIL_PASSWORD = 'SuperSecret'
|
||||
|
||||
# These settings define the content of password reset emails
|
||||
SECURITY_EMAIL_SUBJECT_PASSWORD_RESET = "Password reset instructions for %s" \
|
||||
% APP_NAME
|
||||
% APP_NAME
|
||||
SECURITY_EMAIL_SUBJECT_PASSWORD_NOTICE = "Your %s password has been reset" \
|
||||
% APP_NAME
|
||||
% APP_NAME
|
||||
SECURITY_EMAIL_SUBJECT_PASSWORD_CHANGE_NOTICE = \
|
||||
"Your password for %s has been changed" % APP_NAME
|
||||
"Your password for %s has been changed" % APP_NAME
|
||||
|
||||
##########################################################################
|
||||
# Upgrade checks
|
||||
@@ -247,7 +246,7 @@ UPGRADE_CHECK_URL = 'https://www.pgadmin.org/versions.json'
|
||||
STORAGE_DIR = os.path.join(
|
||||
DATA_DIR,
|
||||
'storage'
|
||||
)
|
||||
)
|
||||
|
||||
##########################################################################
|
||||
# Allows flask application to response to the each request asynchronously
|
||||
|
||||
@@ -31,13 +31,12 @@ import config
|
||||
|
||||
|
||||
class PgAdmin(Flask):
|
||||
|
||||
def find_submodules(self, basemodule):
|
||||
for module_name in find_modules(basemodule, True):
|
||||
if module_name in self.config['MODULE_BLACKLIST']:
|
||||
self.logger.info(
|
||||
'Skipping blacklisted module: %s' % module_name
|
||||
)
|
||||
'Skipping blacklisted module: %s' % module_name
|
||||
)
|
||||
continue
|
||||
self.logger.info('Examining potential module: %s' % module_name)
|
||||
module = import_module(module_name)
|
||||
@@ -104,6 +103,7 @@ def _find_blueprint():
|
||||
if request.blueprint:
|
||||
return current_app.blueprints[request.blueprint]
|
||||
|
||||
|
||||
current_blueprint = LocalProxy(_find_blueprint)
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ def create_app(app_name=config.APP_NAME):
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///{0}?timeout={1}'.format(
|
||||
config.SQLITE_PATH.replace('\\', '/'),
|
||||
getattr(config, 'SQLITE_TIMEOUT', 500)
|
||||
)
|
||||
)
|
||||
|
||||
# Only enable password related functionality in server mode.
|
||||
if config.SERVER_MODE is True:
|
||||
@@ -204,10 +204,10 @@ def create_app(app_name=config.APP_NAME):
|
||||
# Pre-flight checks
|
||||
if int(version.value) < int(config.SETTINGS_SCHEMA_VERSION):
|
||||
app.logger.info(
|
||||
"""Upgrading the database schema from version {0} to {1}.""".format(
|
||||
version.value, config.SETTINGS_SCHEMA_VERSION
|
||||
)
|
||||
)
|
||||
"""Upgrading the database schema from version {0} to {1}.""".format(
|
||||
version.value, config.SETTINGS_SCHEMA_VERSION
|
||||
)
|
||||
)
|
||||
from setup import do_upgrade
|
||||
do_upgrade(app, user_datastore, security, version)
|
||||
|
||||
@@ -236,9 +236,9 @@ def create_app(app_name=config.APP_NAME):
|
||||
# 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.'
|
||||
% config.DESKTOP_USER
|
||||
)
|
||||
'The desktop user %s was not found in the configuration database.'
|
||||
% config.DESKTOP_USER
|
||||
)
|
||||
abort(401)
|
||||
|
||||
login_user(user)
|
||||
@@ -263,7 +263,7 @@ def create_app(app_name=config.APP_NAME):
|
||||
return {
|
||||
'current_app': current_app,
|
||||
'current_blueprint': current_blueprint
|
||||
}
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
# All done!
|
||||
|
||||
@@ -46,6 +46,7 @@ class AboutModule(PgAdminModule):
|
||||
blueprint = AboutModule(MODULE_NAME, __name__,
|
||||
static_url_path='')
|
||||
|
||||
|
||||
##########################################################################
|
||||
# A test page
|
||||
##########################################################################
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
##########################################################################
|
||||
|
||||
import json
|
||||
import six
|
||||
from abc import ABCMeta, abstractmethod, abstractproperty
|
||||
|
||||
import six
|
||||
from flask import current_app, render_template, url_for, make_response, flash
|
||||
from flask.ext.babel import gettext
|
||||
from flask.ext.login import current_user
|
||||
@@ -33,21 +33,20 @@ MODULE_NAME = 'browser'
|
||||
|
||||
|
||||
class BrowserModule(PgAdminModule):
|
||||
|
||||
LABEL = gettext('Browser')
|
||||
|
||||
def get_own_stylesheets(self):
|
||||
stylesheets = []
|
||||
# Add browser stylesheets
|
||||
for (endpoint, filename) in [
|
||||
('static', 'css/codemirror/codemirror.css'),
|
||||
('static', 'css/jQuery-contextMenu/jquery.contextMenu.css' if current_app.debug
|
||||
else 'css/jQuery-contextMenu/jquery.contextMenu.min.css'),
|
||||
('static', 'css/wcDocker/wcDocker.css' if current_app.debug
|
||||
else 'css/wcDocker/wcDocker.min.css'),
|
||||
('browser.static', 'css/browser.css'),
|
||||
('browser.static', 'css/aciTree/css/aciTree.css')
|
||||
]:
|
||||
('static', 'css/codemirror/codemirror.css'),
|
||||
('static', 'css/jQuery-contextMenu/jquery.contextMenu.css' if current_app.debug
|
||||
else 'css/jQuery-contextMenu/jquery.contextMenu.min.css'),
|
||||
('static', 'css/wcDocker/wcDocker.css' if current_app.debug
|
||||
else 'css/wcDocker/wcDocker.min.css'),
|
||||
('browser.static', 'css/browser.css'),
|
||||
('browser.static', 'css/aciTree/css/aciTree.css')
|
||||
]:
|
||||
stylesheets.append(url_for(endpoint, filename=filename))
|
||||
stylesheets.append(url_for('browser.browser_css'))
|
||||
return stylesheets
|
||||
@@ -57,122 +56,122 @@ class BrowserModule(PgAdminModule):
|
||||
scripts.append({
|
||||
'name': 'alertify',
|
||||
'path': url_for(
|
||||
'static',
|
||||
filename='js/alertifyjs/alertify' if current_app.debug
|
||||
else 'js/alertifyjs/alertify.min'
|
||||
),
|
||||
'static',
|
||||
filename='js/alertifyjs/alertify' if current_app.debug
|
||||
else 'js/alertifyjs/alertify.min'
|
||||
),
|
||||
'exports': 'alertify',
|
||||
'preloaded': True
|
||||
})
|
||||
})
|
||||
scripts.append({
|
||||
'name': 'jqueryui.position',
|
||||
'path': url_for(
|
||||
'static',
|
||||
filename='js/jQuery-contextMenu/jquery.ui.position' if \
|
||||
current_app.debug else \
|
||||
'js/jQuery-contextMenu/jquery.ui.position.min'
|
||||
),
|
||||
current_app.debug else \
|
||||
'js/jQuery-contextMenu/jquery.ui.position.min'
|
||||
),
|
||||
'deps': ['jquery'],
|
||||
'exports': 'jQuery.ui.position',
|
||||
'preloaded': True
|
||||
})
|
||||
})
|
||||
scripts.append({
|
||||
'name': 'jquery.contextmenu',
|
||||
'path': url_for(
|
||||
'static',
|
||||
filename='js/jQuery-contextMenu/jquery.contextMenu' if \
|
||||
current_app.debug else \
|
||||
'js/jQuery-contextMenu/jquery.contextMenu.min'
|
||||
),
|
||||
current_app.debug else \
|
||||
'js/jQuery-contextMenu/jquery.contextMenu.min'
|
||||
),
|
||||
'deps': ['jquery', 'jqueryui.position'],
|
||||
'exports': 'jQuery.contextMenu',
|
||||
'preloaded': True
|
||||
})
|
||||
})
|
||||
scripts.append({
|
||||
'name': 'jquery.aciplugin',
|
||||
'path': url_for(
|
||||
'browser.static',
|
||||
filename='js/aciTree/jquery.aciPlugin.min'
|
||||
),
|
||||
'browser.static',
|
||||
filename='js/aciTree/jquery.aciPlugin.min'
|
||||
),
|
||||
'deps': ['jquery'],
|
||||
'exports': 'aciPluginClass',
|
||||
'preloaded': True
|
||||
})
|
||||
})
|
||||
scripts.append({
|
||||
'name': 'jquery.acitree',
|
||||
'path': url_for(
|
||||
'browser.static',
|
||||
filename='js/aciTree/jquery.aciTree' if
|
||||
current_app.debug else 'js/aciTree/jquery.aciTree.min'
|
||||
),
|
||||
'browser.static',
|
||||
filename='js/aciTree/jquery.aciTree' if
|
||||
current_app.debug else 'js/aciTree/jquery.aciTree.min'
|
||||
),
|
||||
'deps': ['jquery', 'jquery.aciplugin'],
|
||||
'exports': 'aciPluginClass.plugins.aciTree',
|
||||
'preloaded': True
|
||||
})
|
||||
})
|
||||
scripts.append({
|
||||
'name': 'jquery.acisortable',
|
||||
'path': url_for(
|
||||
'browser.static',
|
||||
filename='js/aciTree/jquery.aciSortable.min'
|
||||
),
|
||||
'browser.static',
|
||||
filename='js/aciTree/jquery.aciSortable.min'
|
||||
),
|
||||
'deps': ['jquery', 'jquery.aciplugin'],
|
||||
'exports': 'aciPluginClass.plugins.aciSortable',
|
||||
'when': None,
|
||||
'preloaded': True
|
||||
})
|
||||
})
|
||||
scripts.append({
|
||||
'name': 'jquery.acifragment',
|
||||
'path': url_for(
|
||||
'browser.static',
|
||||
filename='js/aciTree/jquery.aciFragment.min'
|
||||
),
|
||||
'browser.static',
|
||||
filename='js/aciTree/jquery.aciFragment.min'
|
||||
),
|
||||
'deps': ['jquery', 'jquery.aciplugin'],
|
||||
'exports': 'aciPluginClass.plugins.aciFragment',
|
||||
'when': None,
|
||||
'preloaded': True
|
||||
})
|
||||
})
|
||||
scripts.append({
|
||||
'name': 'wcdocker',
|
||||
'path': url_for(
|
||||
'static',
|
||||
filename='js/wcDocker/wcDocker' if current_app.debug
|
||||
else 'js/wcDocker/wcDocker.min'
|
||||
),
|
||||
'static',
|
||||
filename='js/wcDocker/wcDocker' if current_app.debug
|
||||
else 'js/wcDocker/wcDocker.min'
|
||||
),
|
||||
'deps': ['jquery.contextmenu'],
|
||||
'exports': '',
|
||||
'preloaded': True
|
||||
})
|
||||
})
|
||||
|
||||
scripts.append({
|
||||
'name': 'pgadmin.browser.datamodel',
|
||||
'path': url_for('browser.static', filename='js/datamodel'),
|
||||
'preloaded': True
|
||||
})
|
||||
})
|
||||
|
||||
for name, script in [
|
||||
['pgadmin.browser', 'js/browser'],
|
||||
['pgadmin.browser.error', 'js/error']]:
|
||||
['pgadmin.browser', 'js/browser'],
|
||||
['pgadmin.browser.error', 'js/error']]:
|
||||
scripts.append({
|
||||
'name': name,
|
||||
'path': url_for('browser.index') + script,
|
||||
'preloaded': True
|
||||
})
|
||||
})
|
||||
|
||||
for name, script in [
|
||||
['pgadmin.browser.node', 'js/node'],
|
||||
['pgadmin.browser.messages', 'js/messages'],
|
||||
['pgadmin.browser.collection', 'js/collection']]:
|
||||
['pgadmin.browser.node', 'js/node'],
|
||||
['pgadmin.browser.messages', 'js/messages'],
|
||||
['pgadmin.browser.collection', 'js/collection']]:
|
||||
scripts.append({
|
||||
'name': name,
|
||||
'path': url_for('browser.index') + script,
|
||||
'preloaded': True,
|
||||
'deps': ['pgadmin.browser.datamodel']
|
||||
})
|
||||
})
|
||||
|
||||
for name, end in [
|
||||
['pgadmin.browser.menu', 'js/menu'],
|
||||
['pgadmin.browser.panel', 'js/panel'],
|
||||
['pgadmin.browser.frame', 'js/frame']]:
|
||||
['pgadmin.browser.menu', 'js/menu'],
|
||||
['pgadmin.browser.panel', 'js/panel'],
|
||||
['pgadmin.browser.frame', 'js/frame']]:
|
||||
scripts.append({
|
||||
'name': name, 'path': url_for('browser.static', filename=end),
|
||||
'preloaded': True})
|
||||
@@ -181,7 +180,7 @@ class BrowserModule(PgAdminModule):
|
||||
'name': 'pgadmin.browser.node.ui',
|
||||
'path': url_for('browser.static', filename='js/node.ui'),
|
||||
'when': 'server-group'
|
||||
})
|
||||
})
|
||||
|
||||
for module in self.submodules:
|
||||
scripts.extend(module.get_own_javascripts())
|
||||
@@ -192,7 +191,8 @@ class BrowserModule(PgAdminModule):
|
||||
'display', 'show_system_objects',
|
||||
gettext("Show system objects"), 'boolean', False,
|
||||
category_label=gettext('Display')
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
blueprint = BrowserModule(MODULE_NAME, __name__)
|
||||
|
||||
@@ -238,10 +238,10 @@ class BrowserPluginModule(PgAdminModule):
|
||||
self.pref_show_node = None
|
||||
|
||||
super(BrowserPluginModule, self).__init__(
|
||||
"NODE-%s" % self.node_type,
|
||||
import_name,
|
||||
**kwargs
|
||||
)
|
||||
"NODE-%s" % self.node_type,
|
||||
import_name,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@property
|
||||
def jssnippets(self):
|
||||
@@ -275,7 +275,7 @@ class BrowserPluginModule(PgAdminModule):
|
||||
'name': 'pgadmin.node.%s' % self.node_type,
|
||||
'path': url_for('browser.index') + '%s/module' % self.node_type,
|
||||
'when': self.script_load
|
||||
}])
|
||||
}])
|
||||
|
||||
for module in self.submodules:
|
||||
scripts.extend(module.get_own_javascripts())
|
||||
@@ -283,7 +283,7 @@ class BrowserPluginModule(PgAdminModule):
|
||||
|
||||
def generate_browser_node(
|
||||
self, node_id, parent_id, label, icon, inode, node_type, **kwargs
|
||||
):
|
||||
):
|
||||
"""
|
||||
Helper function to create a browser node for this particular subnode.
|
||||
|
||||
@@ -306,31 +306,30 @@ class BrowserPluginModule(PgAdminModule):
|
||||
browser tree.
|
||||
"""
|
||||
obj = {
|
||||
"id": "%s/%s" % (node_type, node_id),
|
||||
"label": label,
|
||||
"icon": icon,
|
||||
"inode": inode,
|
||||
"_type": node_type,
|
||||
"_id": node_id,
|
||||
"_pid": parent_id,
|
||||
"module": 'pgadmin.node.%s' % node_type
|
||||
}
|
||||
"id": "%s/%s" % (node_type, node_id),
|
||||
"label": label,
|
||||
"icon": icon,
|
||||
"inode": inode,
|
||||
"_type": node_type,
|
||||
"_id": node_id,
|
||||
"_pid": parent_id,
|
||||
"module": 'pgadmin.node.%s' % node_type
|
||||
}
|
||||
for key in kwargs:
|
||||
obj.setdefault(key, kwargs[key])
|
||||
return obj
|
||||
|
||||
|
||||
@property
|
||||
def csssnippets(self):
|
||||
"""
|
||||
Returns a snippet of css to include in the page
|
||||
"""
|
||||
snippets = [
|
||||
render_template(
|
||||
"browser/css/node.css",
|
||||
node_type=self.node_type,
|
||||
_=gettext
|
||||
)]
|
||||
render_template(
|
||||
"browser/css/node.css",
|
||||
node_type=self.node_type,
|
||||
_=gettext
|
||||
)]
|
||||
|
||||
for submodule in self.submodules:
|
||||
snippets.extend(submodule.csssnippets)
|
||||
@@ -417,11 +416,11 @@ class BrowserPluginModule(PgAdminModule):
|
||||
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')
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route("/")
|
||||
@@ -475,11 +474,11 @@ def index():
|
||||
flash(msg, 'warning')
|
||||
|
||||
return render_template(
|
||||
MODULE_NAME + "/index.html",
|
||||
username=current_user.email,
|
||||
is_admin=current_user.has_role("Administrator"),
|
||||
_=gettext
|
||||
)
|
||||
MODULE_NAME + "/index.html",
|
||||
username=current_user.email,
|
||||
is_admin=current_user.has_role("Administrator"),
|
||||
_=gettext
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route("/js/browser.js")
|
||||
@@ -499,23 +498,23 @@ def browser_js():
|
||||
for submodule in current_blueprint.submodules:
|
||||
snippets.extend(submodule.jssnippets)
|
||||
return make_response(
|
||||
render_template(
|
||||
'browser/js/browser.js',
|
||||
layout=layout,
|
||||
jssnippets=snippets,
|
||||
pg_help_path=pg_help_path,
|
||||
edbas_help_path=edbas_help_path,
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'})
|
||||
render_template(
|
||||
'browser/js/browser.js',
|
||||
layout=layout,
|
||||
jssnippets=snippets,
|
||||
pg_help_path=pg_help_path,
|
||||
edbas_help_path=edbas_help_path,
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'})
|
||||
|
||||
|
||||
@blueprint.route("/js/error.js")
|
||||
@login_required
|
||||
def error_js():
|
||||
return make_response(
|
||||
render_template('browser/js/error.js', _=gettext),
|
||||
200, {'Content-Type': 'application/x-javascript'})
|
||||
render_template('browser/js/error.js', _=gettext),
|
||||
200, {'Content-Type': 'application/x-javascript'})
|
||||
|
||||
|
||||
@blueprint.route("/js/node.js")
|
||||
@@ -530,26 +529,27 @@ def node_js():
|
||||
edbas_help_path = edbas_help_path_pref.get()
|
||||
|
||||
return make_response(
|
||||
render_template('browser/js/node.js',
|
||||
pg_help_path=pg_help_path,
|
||||
edbas_help_path=edbas_help_path,
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'})
|
||||
render_template('browser/js/node.js',
|
||||
pg_help_path=pg_help_path,
|
||||
edbas_help_path=edbas_help_path,
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'})
|
||||
|
||||
|
||||
@blueprint.route("/js/messages.js")
|
||||
def messages_js():
|
||||
return make_response(
|
||||
render_template('browser/js/messages.js', _=gettext),
|
||||
200, {'Content-Type': 'application/x-javascript'})
|
||||
render_template('browser/js/messages.js', _=gettext),
|
||||
200, {'Content-Type': 'application/x-javascript'})
|
||||
|
||||
|
||||
@blueprint.route("/js/collection.js")
|
||||
@login_required
|
||||
def collection_js():
|
||||
return make_response(
|
||||
render_template('browser/js/collection.js', _=gettext),
|
||||
200, {'Content-Type': 'application/x-javascript'})
|
||||
render_template('browser/js/collection.js', _=gettext),
|
||||
200, {'Content-Type': 'application/x-javascript'})
|
||||
|
||||
|
||||
@blueprint.route("/browser.css")
|
||||
@@ -560,10 +560,10 @@ def browser_css():
|
||||
for submodule in blueprint.submodules:
|
||||
snippets.extend(submodule.csssnippets)
|
||||
return make_response(
|
||||
render_template(
|
||||
'browser/css/browser.css', snippets=snippets, _=gettext
|
||||
),
|
||||
200, {'Content-Type': 'text/css'})
|
||||
render_template(
|
||||
'browser/css/browser.css', snippets=snippets, _=gettext
|
||||
),
|
||||
200, {'Content-Type': 'text/css'})
|
||||
|
||||
|
||||
@blueprint.route("/nodes/")
|
||||
|
||||
@@ -35,7 +35,7 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
|
||||
"NODE-%s" % self.node_type,
|
||||
import_name,
|
||||
**kwargs
|
||||
)
|
||||
)
|
||||
PGChildModule.__init__(self)
|
||||
|
||||
@property
|
||||
@@ -52,7 +52,7 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
|
||||
'name': 'pgadmin.node.%s' % self.node_type,
|
||||
'path': url_for('browser.index') + '%s/module' % self.node_type,
|
||||
'when': self.script_load
|
||||
}])
|
||||
}])
|
||||
|
||||
for module in self.submodules:
|
||||
scripts.extend(module.get_own_javascripts())
|
||||
@@ -61,32 +61,32 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
|
||||
|
||||
def generate_browser_node(
|
||||
self, node_id, parent_id, label, icon, **kwargs
|
||||
):
|
||||
):
|
||||
obj = {
|
||||
"id": "%s/%s" % (self.node_type, node_id),
|
||||
"label": label,
|
||||
"icon": self.node_icon if not icon else icon,
|
||||
"inode": self.node_inode,
|
||||
"_type": self.node_type,
|
||||
"_id": node_id,
|
||||
"_pid": parent_id,
|
||||
"module": 'pgadmin.node.%s' % self.node_type
|
||||
}
|
||||
"id": "%s/%s" % (self.node_type, node_id),
|
||||
"label": label,
|
||||
"icon": self.node_icon if not icon else icon,
|
||||
"inode": self.node_inode,
|
||||
"_type": self.node_type,
|
||||
"_id": node_id,
|
||||
"_pid": parent_id,
|
||||
"module": 'pgadmin.node.%s' % self.node_type
|
||||
}
|
||||
for key in kwargs:
|
||||
obj.setdefault(key, kwargs[key])
|
||||
return obj
|
||||
|
||||
def generate_browser_collection_node(self, parent_id, **kwargs):
|
||||
obj = {
|
||||
"id": "coll-%s/%d" % (self.node_type, parent_id),
|
||||
"label": self.collection_label,
|
||||
"icon": self.collection_icon,
|
||||
"inode": True,
|
||||
"_type": 'coll-%s' % (self.node_type),
|
||||
"_id": parent_id,
|
||||
"_pid": parent_id,
|
||||
"module": 'pgadmin.node.%s' % self.node_type
|
||||
}
|
||||
"id": "coll-%s/%d" % (self.node_type, parent_id),
|
||||
"label": self.collection_label,
|
||||
"icon": self.collection_icon,
|
||||
"inode": True,
|
||||
"_type": 'coll-%s' % (self.node_type),
|
||||
"_id": parent_id,
|
||||
"_pid": parent_id,
|
||||
"module": 'pgadmin.node.%s' % self.node_type
|
||||
}
|
||||
|
||||
for key in kwargs:
|
||||
obj.setdefault(key, kwargs[key])
|
||||
@@ -103,16 +103,16 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
|
||||
Returns a snippet of css to include in the page
|
||||
"""
|
||||
snippets = [
|
||||
render_template(
|
||||
"browser/css/collection.css",
|
||||
node_type=self.node_type
|
||||
),
|
||||
render_template(
|
||||
"browser/css/node.css",
|
||||
node_type=self.node_type,
|
||||
_=gettext
|
||||
)
|
||||
]
|
||||
render_template(
|
||||
"browser/css/collection.css",
|
||||
node_type=self.node_type
|
||||
),
|
||||
render_template(
|
||||
"browser/css/node.css",
|
||||
node_type=self.node_type,
|
||||
_=gettext
|
||||
)
|
||||
]
|
||||
|
||||
for submodule in self.submodules:
|
||||
snippets.extend(submodule.csssnippets)
|
||||
@@ -136,14 +136,14 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
|
||||
"""
|
||||
icon to be displayed for the browser collection node
|
||||
"""
|
||||
return 'icon-coll-%s' % (self.node_type)
|
||||
return 'icon-coll-%s' % (self.node_type)
|
||||
|
||||
@property
|
||||
def node_icon(self):
|
||||
"""
|
||||
icon to be displayed for the browser nodes
|
||||
"""
|
||||
return 'icon-%s' % (self.node_type)
|
||||
return 'icon-%s' % (self.node_type)
|
||||
|
||||
@property
|
||||
def node_inode(self):
|
||||
@@ -218,10 +218,10 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
|
||||
# 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'
|
||||
)
|
||||
'show_system_objects'
|
||||
)
|
||||
self.pref_show_node = self.browser_preference.register(
|
||||
'node', 'show_node_' + self.node_type,
|
||||
self.collection_label, 'node', self.SHOW_ON_BROWSER,
|
||||
category_label=gettext('Nodes')
|
||||
)
|
||||
'node', 'show_node_' + self.node_type,
|
||||
self.collection_label, 'node', self.SHOW_ON_BROWSER,
|
||||
category_label=gettext('Nodes')
|
||||
)
|
||||
|
||||
@@ -25,7 +25,6 @@ from pgadmin.model import db, ServerGroup
|
||||
|
||||
|
||||
class ServerGroupModule(BrowserPluginModule):
|
||||
|
||||
NODE_TYPE = "server-group"
|
||||
|
||||
def get_nodes(self, *arg, **kwargs):
|
||||
@@ -35,13 +34,13 @@ class ServerGroupModule(BrowserPluginModule):
|
||||
).order_by("id")
|
||||
for idx, group in enumerate(groups):
|
||||
yield self.generate_browser_node(
|
||||
"%d" % (group.id), None,
|
||||
group.name,
|
||||
"icon-%s" % self.node_type,
|
||||
True,
|
||||
self.node_type,
|
||||
can_delete=True if idx > 0 else False
|
||||
)
|
||||
"%d" % (group.id), None,
|
||||
group.name,
|
||||
"icon-%s" % self.node_type,
|
||||
True,
|
||||
self.node_type,
|
||||
can_delete=True if idx > 0 else False
|
||||
)
|
||||
|
||||
@property
|
||||
def node_type(self):
|
||||
@@ -71,18 +70,17 @@ class ServerGroupModule(BrowserPluginModule):
|
||||
|
||||
|
||||
class ServerGroupMenuItem(MenuItem):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
kwargs.setdefault("type", ServerGroupModule.NODE_TYPE)
|
||||
super(ServerGroupMenuItem, self).__init__(**kwargs)
|
||||
|
||||
|
||||
@six.add_metaclass(ABCMeta)
|
||||
class ServerGroupPluginModule(BrowserPluginModule):
|
||||
"""
|
||||
Base class for server group plugins.
|
||||
"""
|
||||
|
||||
|
||||
@abstractmethod
|
||||
def get_nodes(self, *arg, **kwargs):
|
||||
pass
|
||||
@@ -92,7 +90,6 @@ blueprint = ServerGroupModule(__name__, static_url_path='')
|
||||
|
||||
|
||||
class ServerGroupView(NodeView):
|
||||
|
||||
node_type = ServerGroupModule.NODE_TYPE
|
||||
parent_ids = []
|
||||
ids = [{'type': 'int', 'id': 'gid'}]
|
||||
@@ -102,11 +99,11 @@ class ServerGroupView(NodeView):
|
||||
|
||||
for sg in ServerGroup.query.filter_by(
|
||||
user_id=current_user.id
|
||||
).order_by('name'):
|
||||
).order_by('name'):
|
||||
res.append({
|
||||
'id': sg.id,
|
||||
'name': sg.name
|
||||
})
|
||||
})
|
||||
|
||||
return ajax_response(response=res, status=200)
|
||||
|
||||
@@ -122,32 +119,32 @@ class ServerGroupView(NodeView):
|
||||
|
||||
if sg.id == gid:
|
||||
return make_json_response(
|
||||
status=417,
|
||||
success=0,
|
||||
errormsg=gettext(
|
||||
'The specified server group cannot be deleted.'
|
||||
)
|
||||
)
|
||||
status=417,
|
||||
success=0,
|
||||
errormsg=gettext(
|
||||
'The specified server group cannot be deleted.'
|
||||
)
|
||||
)
|
||||
|
||||
# There can be only one record at most
|
||||
sg = groups.filter_by(id=gid).first()
|
||||
|
||||
if sg is None:
|
||||
return make_json_response(
|
||||
status=417,
|
||||
success=0,
|
||||
errormsg=gettext(
|
||||
'The specified server group could not be found.'
|
||||
)
|
||||
)
|
||||
status=417,
|
||||
success=0,
|
||||
errormsg=gettext(
|
||||
'The specified server group could not be found.'
|
||||
)
|
||||
)
|
||||
else:
|
||||
try:
|
||||
db.session.delete(sg)
|
||||
db.session.commit()
|
||||
except Exception as e:
|
||||
return make_json_response(
|
||||
status=410, success=0, errormsg=e.message
|
||||
)
|
||||
status=410, success=0, errormsg=e.message
|
||||
)
|
||||
|
||||
return make_json_response(result=request.form)
|
||||
|
||||
@@ -156,19 +153,19 @@ class ServerGroupView(NodeView):
|
||||
|
||||
# There can be only one record at most
|
||||
servergroup = ServerGroup.query.filter_by(
|
||||
user_id=current_user.id,
|
||||
id=gid).first()
|
||||
user_id=current_user.id,
|
||||
id=gid).first()
|
||||
|
||||
data = request.form if request.form else json.loads(request.data.decode())
|
||||
|
||||
if servergroup is None:
|
||||
return make_json_response(
|
||||
status=417,
|
||||
success=0,
|
||||
errormsg=gettext(
|
||||
'The specified server group could not be found.'
|
||||
)
|
||||
)
|
||||
status=417,
|
||||
success=0,
|
||||
errormsg=gettext(
|
||||
'The specified server group could not be found.'
|
||||
)
|
||||
)
|
||||
else:
|
||||
try:
|
||||
if u'name' in data:
|
||||
@@ -176,8 +173,8 @@ class ServerGroupView(NodeView):
|
||||
db.session.commit()
|
||||
except Exception as e:
|
||||
return make_json_response(
|
||||
status=410, success=0, errormsg=e.message
|
||||
)
|
||||
status=410, success=0, errormsg=e.message
|
||||
)
|
||||
|
||||
return make_json_response(result=request.form)
|
||||
|
||||
@@ -186,22 +183,22 @@ class ServerGroupView(NodeView):
|
||||
|
||||
# There can be only one record at most
|
||||
sg = ServerGroup.query.filter_by(
|
||||
user_id=current_user.id,
|
||||
id=gid).first()
|
||||
user_id=current_user.id,
|
||||
id=gid).first()
|
||||
|
||||
if sg is None:
|
||||
return make_json_response(
|
||||
status=417,
|
||||
success=0,
|
||||
errormsg=gettext(
|
||||
'The specified server group could not be found.'
|
||||
)
|
||||
)
|
||||
status=417,
|
||||
success=0,
|
||||
errormsg=gettext(
|
||||
'The specified server group could not be found.'
|
||||
)
|
||||
)
|
||||
else:
|
||||
return ajax_response(
|
||||
response={'id': sg.id, 'name': sg.name},
|
||||
status=200
|
||||
)
|
||||
response={'id': sg.id, 'name': sg.name},
|
||||
status=200
|
||||
)
|
||||
|
||||
def create(self):
|
||||
data = request.form if request.form else json.loads(request.data.decode())
|
||||
@@ -229,26 +226,26 @@ class ServerGroupView(NodeView):
|
||||
data[u'name'] = sg.name
|
||||
|
||||
return jsonify(
|
||||
node=self.blueprint.generate_browser_node(
|
||||
"%d" % (sg.id), None,
|
||||
sg.name,
|
||||
"icon-%s" % self.node_type,
|
||||
True,
|
||||
self.node_type,
|
||||
can_delete=True # This is user created hence can deleted
|
||||
)
|
||||
)
|
||||
node=self.blueprint.generate_browser_node(
|
||||
"%d" % (sg.id), None,
|
||||
sg.name,
|
||||
"icon-%s" % self.node_type,
|
||||
True,
|
||||
self.node_type,
|
||||
can_delete=True # This is user created hence can deleted
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
return make_json_response(
|
||||
status=410,
|
||||
success=0,
|
||||
errormsg=e.message)
|
||||
status=410,
|
||||
success=0,
|
||||
errormsg=e.message)
|
||||
|
||||
else:
|
||||
return make_json_response(
|
||||
status=417,
|
||||
success=0,
|
||||
errormsg=gettext('No server group name was specified'))
|
||||
status=417,
|
||||
success=0,
|
||||
errormsg=gettext('No server group name was specified'))
|
||||
|
||||
def sql(self, gid):
|
||||
return make_json_response(status=422)
|
||||
@@ -271,9 +268,9 @@ class ServerGroupView(NodeView):
|
||||
Override this property for your own logic.
|
||||
"""
|
||||
return make_response(
|
||||
render_template("server_groups/server_groups.js"),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template("server_groups/server_groups.js"),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def nodes(self, gid=None):
|
||||
"""Return a JSON document listing the server groups for the user"""
|
||||
@@ -283,18 +280,18 @@ class ServerGroupView(NodeView):
|
||||
groups = ServerGroup.query.filter_by(user_id=current_user.id)
|
||||
else:
|
||||
groups = ServerGroup.query.filter_by(user_id=current_user.id,
|
||||
id=gid).first()
|
||||
id=gid).first()
|
||||
|
||||
for group in groups:
|
||||
nodes.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
"%d" % (group.id), None,
|
||||
group.name,
|
||||
"icon-%s" % self.node_type,
|
||||
True,
|
||||
self.node_type
|
||||
)
|
||||
)
|
||||
self.blueprint.generate_browser_node(
|
||||
"%d" % (group.id), None,
|
||||
group.name,
|
||||
"icon-%s" % self.node_type,
|
||||
True,
|
||||
self.node_type
|
||||
)
|
||||
)
|
||||
|
||||
return make_json_response(data=nodes)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import traceback
|
||||
|
||||
import pgadmin.browser.server_groups as sg
|
||||
from flask import render_template, request, make_response, jsonify, \
|
||||
current_app, url_for
|
||||
current_app, url_for
|
||||
from flask.ext.babel import gettext
|
||||
from flask.ext.security import current_user
|
||||
from pgadmin.browser.server_groups.servers.types import ServerType
|
||||
@@ -91,21 +91,21 @@ class ServerModule(sg.ServerGroupPluginModule):
|
||||
wal_paused = None
|
||||
|
||||
yield self.generate_browser_node(
|
||||
"%d" % (server.id),
|
||||
gid,
|
||||
server.name,
|
||||
"icon-server-not-connected" if not connected else
|
||||
"icon-{0}".format(manager.server_type),
|
||||
True,
|
||||
self.NODE_TYPE,
|
||||
connected=connected,
|
||||
server_type=manager.server_type if connected else "pg",
|
||||
version=manager.version,
|
||||
db=manager.db,
|
||||
user=manager.user_info if connected else None,
|
||||
in_recovery=in_recovery,
|
||||
wal_pause=wal_paused
|
||||
)
|
||||
"%d" % (server.id),
|
||||
gid,
|
||||
server.name,
|
||||
"icon-server-not-connected" if not connected else
|
||||
"icon-{0}".format(manager.server_type),
|
||||
True,
|
||||
self.NODE_TYPE,
|
||||
connected=connected,
|
||||
server_type=manager.server_type if connected else "pg",
|
||||
version=manager.version,
|
||||
db=manager.db,
|
||||
user=manager.user_info if connected else None,
|
||||
in_recovery=in_recovery,
|
||||
wal_pause=wal_paused
|
||||
)
|
||||
|
||||
@property
|
||||
def jssnippets(self):
|
||||
@@ -133,17 +133,17 @@ class ServerModule(sg.ServerGroupPluginModule):
|
||||
'name': 'pgadmin.node.server',
|
||||
'path': url_for('browser.index') + '%s/module' % self.node_type,
|
||||
'when': self.script_load
|
||||
},
|
||||
{
|
||||
'name': 'pgadmin.browser.server.privilege',
|
||||
'path': url_for('browser.index') + 'server/static/js/privilege',
|
||||
'when': self.node_type,
|
||||
'deps': ['pgadmin.browser.node.ui']
|
||||
},
|
||||
{
|
||||
'name': 'pgadmin.browser.server.privilege',
|
||||
'path': url_for('browser.index') + 'server/static/js/privilege',
|
||||
'when': self.node_type,
|
||||
'deps': ['pgadmin.browser.node.ui']
|
||||
},
|
||||
{
|
||||
'name': 'pgadmin.browser.server.variable',
|
||||
'path': url_for('browser.index') + 'server/static/js/variable',
|
||||
'when': self.node_type
|
||||
'name': 'pgadmin.browser.server.variable',
|
||||
'path': url_for('browser.index') + 'server/static/js/variable',
|
||||
'when': self.node_type
|
||||
}])
|
||||
|
||||
for module in self.submodules:
|
||||
@@ -175,6 +175,7 @@ class ServerModule(sg.ServerGroupPluginModule):
|
||||
"""
|
||||
ServerType.register_preferences()
|
||||
|
||||
|
||||
class ServerMenuItem(MenuItem):
|
||||
def __init__(self, **kwargs):
|
||||
kwargs.setdefault("type", ServerModule.NODE_TYPE)
|
||||
@@ -183,6 +184,7 @@ class ServerMenuItem(MenuItem):
|
||||
|
||||
blueprint = ServerModule(__name__)
|
||||
|
||||
|
||||
class ServerNode(PGChildNodeView):
|
||||
node_type = ServerModule.NODE_TYPE
|
||||
|
||||
@@ -207,7 +209,7 @@ class ServerNode(PGChildNodeView):
|
||||
[{'post': 'create_restore_point'}],
|
||||
'connect': [{
|
||||
'get': 'connect_status', 'post': 'connect', 'delete': 'disconnect'
|
||||
}],
|
||||
}],
|
||||
'change_password': [{'post': 'change_password'}],
|
||||
'wal_replay': [{
|
||||
'delete': 'pause_wal_replay', 'put': 'resume_wal_replay'
|
||||
@@ -265,26 +267,26 @@ class ServerNode(PGChildNodeView):
|
||||
user=manager.user_info if connected else None,
|
||||
in_recovery=in_recovery,
|
||||
wal_pause=wal_paused
|
||||
)
|
||||
)
|
||||
)
|
||||
return make_json_response(result=res)
|
||||
|
||||
def node(self, gid, sid):
|
||||
"""Return a JSON document listing the server groups for the user"""
|
||||
server = Server.query.filter_by(user_id=current_user.id,
|
||||
servergroup_id=gid,
|
||||
id=sid).first()
|
||||
servergroup_id=gid,
|
||||
id=sid).first()
|
||||
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
status=410,
|
||||
success=0,
|
||||
errormsg=gettext(
|
||||
gettext(
|
||||
"Couldn't find the server with id# %s!"
|
||||
).format(sid)
|
||||
)
|
||||
status=410,
|
||||
success=0,
|
||||
errormsg=gettext(
|
||||
gettext(
|
||||
"Couldn't find the server with id# %s!"
|
||||
).format(sid)
|
||||
)
|
||||
)
|
||||
|
||||
from pgadmin.utils.driver import get_driver
|
||||
manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(server.id)
|
||||
@@ -310,23 +312,23 @@ class ServerNode(PGChildNodeView):
|
||||
wal_paused = None
|
||||
|
||||
return make_json_response(
|
||||
result=self.blueprint.generate_browser_node(
|
||||
"%d" % (server.id),
|
||||
gid,
|
||||
server.name,
|
||||
"icon-server-not-connected" if not connected else
|
||||
"icon-{0}".format(manager.server_type),
|
||||
True,
|
||||
self.node_type,
|
||||
connected=connected,
|
||||
server_type=manager.server_type if connected else 'pg',
|
||||
version=manager.version,
|
||||
db=manager.db,
|
||||
user=manager.user_info if connected else None,
|
||||
in_recovery=in_recovery,
|
||||
wal_pause=wal_paused
|
||||
)
|
||||
)
|
||||
result=self.blueprint.generate_browser_node(
|
||||
"%d" % (server.id),
|
||||
gid,
|
||||
server.name,
|
||||
"icon-server-not-connected" if not connected else
|
||||
"icon-{0}".format(manager.server_type),
|
||||
True,
|
||||
self.node_type,
|
||||
connected=connected,
|
||||
server_type=manager.server_type if connected else 'pg',
|
||||
version=manager.version,
|
||||
db=manager.db,
|
||||
user=manager.user_info if connected else None,
|
||||
in_recovery=in_recovery,
|
||||
wal_pause=wal_paused
|
||||
)
|
||||
)
|
||||
|
||||
def delete(self, gid, sid):
|
||||
"""Delete a server node in the settings database."""
|
||||
@@ -365,7 +367,7 @@ class ServerNode(PGChildNodeView):
|
||||
def update(self, gid, sid):
|
||||
"""Update the server settings"""
|
||||
server = Server.query.filter_by(
|
||||
user_id=current_user.id, id=sid).first()
|
||||
user_id=current_user.id, id=sid).first()
|
||||
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
@@ -384,7 +386,7 @@ class ServerNode(PGChildNodeView):
|
||||
'gid': 'servergroup_id',
|
||||
'comment': 'comment',
|
||||
'role': 'role'
|
||||
}
|
||||
}
|
||||
|
||||
disp_lbl = {
|
||||
'name': gettext('name'),
|
||||
@@ -408,13 +410,13 @@ class ServerNode(PGChildNodeView):
|
||||
if connected:
|
||||
for arg in (
|
||||
'host', 'port', 'db', 'username', 'sslmode', 'role'
|
||||
):
|
||||
):
|
||||
if arg in data:
|
||||
return forbidden(
|
||||
errormsg=gettext(
|
||||
"'{0}' is not allowed to modify, when server is connected."
|
||||
).format(disp_lbl[arg])
|
||||
)
|
||||
errormsg=gettext(
|
||||
"'{0}' is not allowed to modify, when server is connected."
|
||||
).format(disp_lbl[arg])
|
||||
)
|
||||
|
||||
for arg in config_param_map:
|
||||
if arg in data:
|
||||
@@ -461,12 +463,12 @@ class ServerNode(PGChildNodeView):
|
||||
Return list of attributes of all servers.
|
||||
"""
|
||||
servers = Server.query.filter_by(
|
||||
user_id=current_user.id,
|
||||
servergroup_id=gid).order_by(Server.name)
|
||||
user_id=current_user.id,
|
||||
servergroup_id=gid).order_by(Server.name)
|
||||
sg = ServerGroup.query.filter_by(
|
||||
user_id=current_user.id,
|
||||
id=gid
|
||||
).first()
|
||||
user_id=current_user.id,
|
||||
id=gid
|
||||
).first()
|
||||
res = []
|
||||
|
||||
from pgadmin.utils.driver import get_driver
|
||||
@@ -491,10 +493,10 @@ class ServerNode(PGChildNodeView):
|
||||
'connected': connected,
|
||||
'version': manager.ver,
|
||||
'server_type': manager.server_type if connected else 'pg'
|
||||
})
|
||||
})
|
||||
|
||||
return ajax_response(
|
||||
response=res
|
||||
response=res
|
||||
)
|
||||
|
||||
def properties(self, gid, sid):
|
||||
@@ -599,9 +601,9 @@ class ServerNode(PGChildNodeView):
|
||||
password = None
|
||||
|
||||
status, errmsg = conn.connect(
|
||||
password=password,
|
||||
server_types=ServerType.types()
|
||||
)
|
||||
password=password,
|
||||
server_types=ServerType.types()
|
||||
)
|
||||
|
||||
if not status:
|
||||
db.session.delete(server)
|
||||
@@ -617,17 +619,17 @@ class ServerNode(PGChildNodeView):
|
||||
icon = "icon-pg"
|
||||
|
||||
return jsonify(
|
||||
node=self.blueprint.generate_browser_node(
|
||||
"%d" % server.id, server.servergroup_id,
|
||||
server.name,
|
||||
icon,
|
||||
True,
|
||||
self.node_type,
|
||||
user=user,
|
||||
connected=connected,
|
||||
server_type='pg' # Default server type
|
||||
)
|
||||
)
|
||||
node=self.blueprint.generate_browser_node(
|
||||
"%d" % server.id, server.servergroup_id,
|
||||
server.name,
|
||||
icon,
|
||||
True,
|
||||
self.node_type,
|
||||
user=user,
|
||||
connected=connected,
|
||||
server_type='pg' # Default server type
|
||||
)
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
if server:
|
||||
@@ -659,10 +661,10 @@ class ServerNode(PGChildNodeView):
|
||||
'servers/sql',
|
||||
'9.2_plus' if manager.version >= 90200 else '9.1_plus',
|
||||
'stats.sql'
|
||||
]),
|
||||
]),
|
||||
conn=conn, _=gettext
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -672,8 +674,8 @@ class ServerNode(PGChildNodeView):
|
||||
return make_json_response(
|
||||
info=gettext(
|
||||
"Server has no active connection for generating statistics."
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def dependencies(self, gid, sid):
|
||||
return make_json_response(data='')
|
||||
@@ -691,14 +693,14 @@ class ServerNode(PGChildNodeView):
|
||||
username = current_user.email.split('@')[0]
|
||||
|
||||
return make_response(
|
||||
render_template(
|
||||
"servers/servers.js",
|
||||
server_types=ServerType.types(),
|
||||
_=gettext,
|
||||
username=username,
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"servers/servers.js",
|
||||
server_types=ServerType.types(),
|
||||
_=gettext,
|
||||
username=username,
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def connect_status(self, gid, sid):
|
||||
"""Check and return the connection status."""
|
||||
@@ -725,8 +727,8 @@ class ServerNode(PGChildNodeView):
|
||||
store the password.
|
||||
"""
|
||||
current_app.logger.info(
|
||||
'Connection Request for server#{0}'.format(sid)
|
||||
)
|
||||
'Connection Request for server#{0}'.format(sid)
|
||||
)
|
||||
|
||||
# Fetch Server Details
|
||||
server = Server.query.filter_by(id=sid).first()
|
||||
@@ -749,25 +751,25 @@ class ServerNode(PGChildNodeView):
|
||||
# Return the password template in case password is not
|
||||
# provided, or password has not been saved earlier.
|
||||
return make_json_response(
|
||||
success=0,
|
||||
status=428,
|
||||
result=render_template(
|
||||
'servers/password.html',
|
||||
server_label=server.name,
|
||||
username=server.username,
|
||||
_=gettext
|
||||
)
|
||||
)
|
||||
success=0,
|
||||
status=428,
|
||||
result=render_template(
|
||||
'servers/password.html',
|
||||
server_label=server.name,
|
||||
username=server.username,
|
||||
_=gettext
|
||||
)
|
||||
)
|
||||
else:
|
||||
password = data['password'] if 'password' in data else None
|
||||
save_password = \
|
||||
data['save_password'] if password and \
|
||||
'save_password' in data else False
|
||||
'save_password' in data else False
|
||||
|
||||
# Encrypt the password before saving with user's login password key.
|
||||
try:
|
||||
password = encrypt(password, user.password) \
|
||||
if password is not None else server.password
|
||||
if password is not None else server.password
|
||||
except Exception as e:
|
||||
current_app.logger.exception(e)
|
||||
return internal_server_error(errormsg=e.message)
|
||||
@@ -779,9 +781,9 @@ class ServerNode(PGChildNodeView):
|
||||
|
||||
try:
|
||||
status, errmsg = conn.connect(
|
||||
password=password,
|
||||
server_types=ServerType.types()
|
||||
)
|
||||
password=password,
|
||||
server_types=ServerType.types()
|
||||
)
|
||||
except Exception as e:
|
||||
current_app.logger.exception(e)
|
||||
# TODO::
|
||||
@@ -795,21 +797,21 @@ class ServerNode(PGChildNodeView):
|
||||
if not status:
|
||||
current_app.logger.error(
|
||||
"Could not connected to server(#{0}) - '{1}'.\nError: {2}".format(
|
||||
server.id, server.name, errmsg
|
||||
)
|
||||
server.id, server.name, errmsg
|
||||
)
|
||||
)
|
||||
|
||||
return make_json_response(
|
||||
success=0,
|
||||
status=401,
|
||||
result=render_template(
|
||||
'servers/password.html',
|
||||
server_label=server.name,
|
||||
username=server.username,
|
||||
errmsg=errmsg,
|
||||
_=gettext
|
||||
)
|
||||
)
|
||||
success=0,
|
||||
status=401,
|
||||
result=render_template(
|
||||
'servers/password.html',
|
||||
server_label=server.name,
|
||||
username=server.username,
|
||||
errmsg=errmsg,
|
||||
_=gettext
|
||||
)
|
||||
)
|
||||
else:
|
||||
if save_password:
|
||||
try:
|
||||
@@ -846,21 +848,21 @@ class ServerNode(PGChildNodeView):
|
||||
wal_paused = None
|
||||
|
||||
return make_json_response(
|
||||
success=1,
|
||||
info=gettext("Server connected."),
|
||||
data={
|
||||
'icon': 'icon-{0}'.format(
|
||||
manager.server_type
|
||||
),
|
||||
'connected': True,
|
||||
'type': manager.server_type,
|
||||
'version': manager.version,
|
||||
'db': manager.db,
|
||||
'user': manager.user_info,
|
||||
'in_recovery': in_recovery,
|
||||
'wal_pause': wal_paused
|
||||
}
|
||||
)
|
||||
success=1,
|
||||
info=gettext("Server connected."),
|
||||
data={
|
||||
'icon': 'icon-{0}'.format(
|
||||
manager.server_type
|
||||
),
|
||||
'connected': True,
|
||||
'type': manager.server_type,
|
||||
'version': manager.version,
|
||||
'db': manager.db,
|
||||
'user': manager.user_info,
|
||||
'in_recovery': in_recovery,
|
||||
'wal_pause': wal_paused
|
||||
}
|
||||
)
|
||||
|
||||
def disconnect(self, gid, sid):
|
||||
"""Disconnect the Server."""
|
||||
@@ -879,13 +881,13 @@ class ServerNode(PGChildNodeView):
|
||||
return unauthorized(gettext("Server could not be disconnected."))
|
||||
else:
|
||||
return make_json_response(
|
||||
success=1,
|
||||
info=gettext("Server disconnected."),
|
||||
data={
|
||||
'icon': 'icon-server-not-connected',
|
||||
'connected': False
|
||||
}
|
||||
)
|
||||
success=1,
|
||||
info=gettext("Server disconnected."),
|
||||
data={
|
||||
'icon': 'icon-server-not-connected',
|
||||
'connected': False
|
||||
}
|
||||
)
|
||||
|
||||
def reload_configuration(self, gid, sid):
|
||||
"""Reload the server configuration"""
|
||||
@@ -901,15 +903,16 @@ class ServerNode(PGChildNodeView):
|
||||
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
gettext("Could not reload the server configuration.")
|
||||
)
|
||||
gettext("Could not reload the server configuration.")
|
||||
)
|
||||
else:
|
||||
return make_json_response(data={'status': True,
|
||||
'result': gettext('Server configuration reloaded.')})
|
||||
'result': gettext('Server configuration reloaded.')})
|
||||
|
||||
else:
|
||||
return make_json_response(data={'status': False,
|
||||
'result': gettext('Not connected to the server or the connection to the server has been closed.')})
|
||||
'result': gettext(
|
||||
'Not connected to the server or the connection to the server has been closed.')})
|
||||
|
||||
def create_restore_point(self, gid, sid):
|
||||
"""
|
||||
@@ -947,7 +950,7 @@ class ServerNode(PGChildNodeView):
|
||||
'status': 1,
|
||||
'result': gettext(
|
||||
'Named restore point created: {0}'.format(
|
||||
restore_point_name))
|
||||
restore_point_name))
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
@@ -968,11 +971,11 @@ class ServerNode(PGChildNodeView):
|
||||
try:
|
||||
data = json.loads(request.form['data'])
|
||||
if data and ('password' not in data or
|
||||
data['password'] == '' or
|
||||
'newPassword' not in data or
|
||||
data['newPassword'] == '' or
|
||||
'confirmPassword' not in data or
|
||||
data['confirmPassword'] == ''):
|
||||
data['password'] == '' or
|
||||
'newPassword' not in data or
|
||||
data['newPassword'] == '' or
|
||||
'confirmPassword' not in data or
|
||||
data['confirmPassword'] == ''):
|
||||
return make_json_response(
|
||||
status=400,
|
||||
success=0,
|
||||
@@ -1019,10 +1022,10 @@ class ServerNode(PGChildNodeView):
|
||||
password = pqencryptpassword(data['newPassword'], manager.user)
|
||||
|
||||
SQL = render_template("/".join([
|
||||
'servers/sql',
|
||||
'9.2_plus' if manager.version >= 90200 else '9.1_plus',
|
||||
'change_password.sql'
|
||||
]),
|
||||
'servers/sql',
|
||||
'9.2_plus' if manager.version >= 90200 else '9.1_plus',
|
||||
'change_password.sql'
|
||||
]),
|
||||
conn=conn, _=gettext,
|
||||
user=manager.user, encrypted_password=password)
|
||||
|
||||
@@ -1042,12 +1045,12 @@ class ServerNode(PGChildNodeView):
|
||||
manager.update_session()
|
||||
|
||||
return make_json_response(
|
||||
status=200,
|
||||
success=1,
|
||||
info=gettext(
|
||||
"Password changed successfully."
|
||||
)
|
||||
status=200,
|
||||
success=1,
|
||||
info=gettext(
|
||||
"Password changed successfully."
|
||||
)
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -1128,5 +1131,4 @@ class ServerNode(PGChildNodeView):
|
||||
return self.wal_replay(sid, True)
|
||||
|
||||
|
||||
|
||||
ServerNode.register_node_view(blueprint)
|
||||
|
||||
@@ -61,17 +61,17 @@ class DatabaseModule(CollectionNodeModule):
|
||||
Returns a snippet of css to include in the page
|
||||
"""
|
||||
snippets = [
|
||||
render_template(
|
||||
"browser/css/collection.css",
|
||||
node_type=self.node_type,
|
||||
_=_
|
||||
),
|
||||
render_template(
|
||||
"databases/css/database.css",
|
||||
node_type=self.node_type,
|
||||
_=_
|
||||
)
|
||||
]
|
||||
render_template(
|
||||
"browser/css/collection.css",
|
||||
node_type=self.node_type,
|
||||
_=_
|
||||
),
|
||||
render_template(
|
||||
"databases/css/database.css",
|
||||
node_type=self.node_type,
|
||||
_=_
|
||||
)
|
||||
]
|
||||
|
||||
for submodule in self.submodules:
|
||||
snippets.extend(submodule.csssnippets)
|
||||
@@ -86,12 +86,12 @@ class DatabaseView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'did'}
|
||||
]
|
||||
{'type': 'int', 'id': 'did'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -108,7 +108,7 @@ class DatabaseView(PGChildNodeView):
|
||||
'module.js': [{}, {}, {'get': 'module_js'}],
|
||||
'connect': [{
|
||||
'get': 'connect_status', 'post': 'connect', 'delete': 'disconnect'
|
||||
}],
|
||||
}],
|
||||
'get_encodings': [{'get': 'get_encodings'}, {'get': 'get_encodings'}],
|
||||
'get_ctypes': [{'get': 'get_ctypes'}, {'get': 'get_ctypes'}],
|
||||
'vopts': [{}, {'get': 'variable_options'}]
|
||||
@@ -120,6 +120,7 @@ class DatabaseView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
def wrap(f):
|
||||
@wraps(f)
|
||||
def wrapped(self, *args, **kwargs):
|
||||
@@ -135,7 +136,7 @@ class DatabaseView(PGChildNodeView):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
_("Connection to the server has been lost!")
|
||||
)
|
||||
)
|
||||
|
||||
ver = self.manager.version
|
||||
# we will set template path for sql scripts
|
||||
@@ -146,7 +147,9 @@ class DatabaseView(PGChildNodeView):
|
||||
else:
|
||||
self.template_path = 'databases/sql/9.1_plus'
|
||||
return f(self, *args, **kwargs)
|
||||
|
||||
return wrapped
|
||||
|
||||
return wrap
|
||||
|
||||
@check_precondition(action="list")
|
||||
@@ -156,16 +159,16 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
conn=self.conn, last_system_oid=last_system_oid
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition(action="nodes")
|
||||
def nodes(self, gid, sid):
|
||||
@@ -176,7 +179,7 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
last_system_oid=last_system_oid
|
||||
)
|
||||
)
|
||||
status, rset = self.conn.execute_dict(SQL)
|
||||
|
||||
if not status:
|
||||
@@ -192,31 +195,31 @@ class DatabaseView(PGChildNodeView):
|
||||
canDisConn = True
|
||||
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['did'],
|
||||
sid,
|
||||
row['name'],
|
||||
icon="icon-database-not-connected" if not connected
|
||||
else "pg-icon-database",
|
||||
connected=connected,
|
||||
tablespace=row['spcname'],
|
||||
allowConn=row['datallowconn'],
|
||||
canCreate=row['cancreate'],
|
||||
canDisconn=canDisConn
|
||||
)
|
||||
)
|
||||
self.blueprint.generate_browser_node(
|
||||
row['did'],
|
||||
sid,
|
||||
row['name'],
|
||||
icon="icon-database-not-connected" if not connected
|
||||
else "pg-icon-database",
|
||||
connected=connected,
|
||||
tablespace=row['spcname'],
|
||||
allowConn=row['datallowconn'],
|
||||
canCreate=row['cancreate'],
|
||||
canDisconn=canDisConn
|
||||
)
|
||||
)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition(action="node")
|
||||
def node(self, gid, sid, did):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
did=did, conn=self.conn, last_system_oid=0
|
||||
)
|
||||
)
|
||||
status, rset = self.conn.execute_2darray(SQL)
|
||||
|
||||
if not status:
|
||||
@@ -224,34 +227,33 @@ class DatabaseView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
if self.manager.db == row['name']:
|
||||
connected=True
|
||||
connected = True
|
||||
else:
|
||||
conn=self.manager.connection(row['name'])
|
||||
connected=conn.connected()
|
||||
conn = self.manager.connection(row['name'])
|
||||
connected = conn.connected()
|
||||
return make_json_response(
|
||||
data=self.blueprint.generate_browser_node(
|
||||
row['did'],
|
||||
sid,
|
||||
row['name'],
|
||||
icon="icon-database-not-connected" if not connected \
|
||||
else "pg-icon-database",
|
||||
connected=connected,
|
||||
spcname=row['spcname'],
|
||||
allowConn=row['datallowconn'],
|
||||
canCreate=row['cancreate']
|
||||
),
|
||||
status=200
|
||||
)
|
||||
data=self.blueprint.generate_browser_node(
|
||||
row['did'],
|
||||
sid,
|
||||
row['name'],
|
||||
icon="icon-database-not-connected" if not connected \
|
||||
else "pg-icon-database",
|
||||
connected=connected,
|
||||
spcname=row['spcname'],
|
||||
allowConn=row['datallowconn'],
|
||||
canCreate=row['cancreate']
|
||||
),
|
||||
status=200
|
||||
)
|
||||
|
||||
return gone(errormsg=_("Could not find the database on the server."))
|
||||
|
||||
|
||||
@check_precondition(action="properties")
|
||||
def properties(self, gid, sid, did):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
did=did, conn=self.conn, last_system_oid=0
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
if not status:
|
||||
@@ -260,7 +262,7 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'acl.sql']),
|
||||
did=did, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, dataclres = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -270,7 +272,7 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'defacl.sql']),
|
||||
did=did, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, defaclres = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -282,7 +284,7 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'get_variables.sql']),
|
||||
did=did, conn=self.conn
|
||||
)
|
||||
)
|
||||
|
||||
status, res1 = self.conn.execute_dict(SQL)
|
||||
|
||||
@@ -300,9 +302,9 @@ class DatabaseView(PGChildNodeView):
|
||||
result.update(frmtd_variables)
|
||||
|
||||
return ajax_response(
|
||||
response=result,
|
||||
status=200
|
||||
)
|
||||
response=result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def formatdbacl(res, dbacl):
|
||||
@@ -317,12 +319,12 @@ class DatabaseView(PGChildNodeView):
|
||||
Override this property for your own logic.
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"databases/js/databases.js",
|
||||
_=_
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"databases/js/databases.js",
|
||||
_=_
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def connect(self, gid, sid, did):
|
||||
"""Connect the Database."""
|
||||
@@ -334,9 +336,9 @@ class DatabaseView(PGChildNodeView):
|
||||
if not status:
|
||||
current_app.logger.error(
|
||||
"Could not connected to database(#{0}).\nError: {1}".format(
|
||||
did, errmsg
|
||||
)
|
||||
did, errmsg
|
||||
)
|
||||
)
|
||||
|
||||
return internal_server_error(errmsg)
|
||||
else:
|
||||
@@ -344,13 +346,13 @@ class DatabaseView(PGChildNodeView):
|
||||
%s' % (did))
|
||||
|
||||
return make_json_response(
|
||||
success=1,
|
||||
info=_("Database connected."),
|
||||
data={
|
||||
'icon': 'pg-icon-database',
|
||||
'connected': True
|
||||
}
|
||||
)
|
||||
success=1,
|
||||
info=_("Database connected."),
|
||||
data={
|
||||
'icon': 'pg-icon-database',
|
||||
'connected': True
|
||||
}
|
||||
)
|
||||
|
||||
def disconnect(self, gid, sid, did):
|
||||
"""Disconnect the database."""
|
||||
@@ -365,37 +367,37 @@ class DatabaseView(PGChildNodeView):
|
||||
return unauthorized(_("Database could not be disconnected."))
|
||||
else:
|
||||
return make_json_response(
|
||||
success=1,
|
||||
info=_("Database disconnected."),
|
||||
data={
|
||||
'icon': 'icon-database-not-connected',
|
||||
'connected': False
|
||||
}
|
||||
)
|
||||
success=1,
|
||||
info=_("Database disconnected."),
|
||||
data={
|
||||
'icon': 'icon-database-not-connected',
|
||||
'connected': False
|
||||
}
|
||||
)
|
||||
|
||||
@check_precondition(action="get_encodings")
|
||||
def get_encodings(self, gid, sid, did=None):
|
||||
"""
|
||||
This function to return list of avialable encodings
|
||||
"""
|
||||
res = [{ 'label': '', 'value': '' }]
|
||||
res = [{'label': '', 'value': ''}]
|
||||
try:
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'get_encodings.sql'])
|
||||
)
|
||||
)
|
||||
status, rset = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
{ 'label': row['encoding'], 'value': row['encoding'] }
|
||||
)
|
||||
{'label': row['encoding'], 'value': row['encoding']}
|
||||
)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -405,16 +407,16 @@ class DatabaseView(PGChildNodeView):
|
||||
"""
|
||||
This function to return list of available collation/character types
|
||||
"""
|
||||
res = [{ 'label': '', 'value': '' }]
|
||||
res = [{'label': '', 'value': ''}]
|
||||
default_list = ['C', 'POSIX']
|
||||
for val in default_list:
|
||||
res.append(
|
||||
{'label': val, 'value': val}
|
||||
)
|
||||
{'label': val, 'value': val}
|
||||
)
|
||||
try:
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'get_ctypes.sql'])
|
||||
)
|
||||
)
|
||||
status, rset = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -424,9 +426,9 @@ class DatabaseView(PGChildNodeView):
|
||||
res.append({'label': row['cname'], 'value': row['cname']})
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -454,7 +456,7 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
data=data, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, msg = self.conn.execute_scalar(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=msg)
|
||||
@@ -466,7 +468,7 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'grant.sql']),
|
||||
data=data, conn=self.conn
|
||||
)
|
||||
)
|
||||
SQL = SQL.strip('\n').strip(' ')
|
||||
if SQL and SQL != "":
|
||||
status, msg = self.conn.execute_scalar(SQL)
|
||||
@@ -477,7 +479,7 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
name=data['name'], conn=self.conn, last_system_oid=0
|
||||
)
|
||||
)
|
||||
SQL = SQL.strip('\n').strip(' ')
|
||||
if SQL and SQL != "":
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
@@ -497,8 +499,8 @@ class DatabaseView(PGChildNodeView):
|
||||
allowConn=True,
|
||||
canCreate=response['cancreate'],
|
||||
canDisconn=True
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return make_json_response(
|
||||
@@ -513,7 +515,7 @@ class DatabaseView(PGChildNodeView):
|
||||
|
||||
data = request.form if request.form else json.loads(
|
||||
request.data.decode()
|
||||
)
|
||||
)
|
||||
info = "nothing to update."
|
||||
|
||||
if did is not None:
|
||||
@@ -522,15 +524,15 @@ class DatabaseView(PGChildNodeView):
|
||||
render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
did=did, conn=self.conn, last_system_oid=0
|
||||
)
|
||||
)
|
||||
)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=rset)
|
||||
|
||||
if len(rset['rows']) == 0:
|
||||
return gone(
|
||||
_("Couldnot find the database on the server.")
|
||||
)
|
||||
)
|
||||
|
||||
data['old_name'] = (rset['rows'][0])['name']
|
||||
if 'name' not in data:
|
||||
@@ -563,7 +565,7 @@ class DatabaseView(PGChildNodeView):
|
||||
|
||||
return make_json_response(
|
||||
success=1,
|
||||
info = info,
|
||||
info=info,
|
||||
data={
|
||||
'id': did,
|
||||
'sid': sid,
|
||||
@@ -586,7 +588,7 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
did=did, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, res = default_conn.execute_scalar(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -605,7 +607,7 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
datname=res, conn=self.conn
|
||||
)
|
||||
)
|
||||
|
||||
status, msg = default_conn.execute_scalar(SQL)
|
||||
if not status:
|
||||
@@ -642,15 +644,15 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = res.strip('\n').strip(' ')
|
||||
|
||||
return make_json_response(
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
current_app.logger.exception(e)
|
||||
return make_json_response(
|
||||
data=_("-- modified SQL"),
|
||||
status=200
|
||||
)
|
||||
data=_("-- modified SQL"),
|
||||
status=200
|
||||
)
|
||||
|
||||
def get_sql(self, gid, sid, data, did=None):
|
||||
SQL = ''
|
||||
@@ -660,15 +662,15 @@ class DatabaseView(PGChildNodeView):
|
||||
render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
did=did, conn=self.conn, last_system_oid=0
|
||||
)
|
||||
)
|
||||
)
|
||||
if not status:
|
||||
return False, internal_server_error(errormsg=rset)
|
||||
|
||||
if len(rset['rows']) == 0:
|
||||
return False, gone(
|
||||
_("Could not find the database on the server.")
|
||||
)
|
||||
)
|
||||
|
||||
data['old_name'] = (rset['rows'][0])['name']
|
||||
if 'name' not in data:
|
||||
@@ -689,8 +691,8 @@ class DatabaseView(PGChildNodeView):
|
||||
Generates sql for creating new database.
|
||||
"""
|
||||
required_args = [
|
||||
u'name'
|
||||
]
|
||||
u'name'
|
||||
]
|
||||
|
||||
for arg in required_args:
|
||||
if arg not in data:
|
||||
@@ -700,7 +702,7 @@ class DatabaseView(PGChildNodeView):
|
||||
try:
|
||||
acls = render_template(
|
||||
"/".join([self.template_path, 'allowed_privs.json'])
|
||||
)
|
||||
)
|
||||
acls = json.loads(acls)
|
||||
except Exception as e:
|
||||
current_app.logger.exception(e)
|
||||
@@ -711,17 +713,17 @@ class DatabaseView(PGChildNodeView):
|
||||
allowedacl = acls[aclcol]
|
||||
data[aclcol] = parse_priv_to_db(
|
||||
data[aclcol], allowedacl['acl']
|
||||
)
|
||||
)
|
||||
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
data=data, conn=self.conn
|
||||
)
|
||||
)
|
||||
SQL += "\n"
|
||||
SQL += render_template(
|
||||
"/".join([self.template_path, 'grant.sql']),
|
||||
data=data, conn=self.conn
|
||||
)
|
||||
)
|
||||
return SQL
|
||||
|
||||
def get_online_sql(self, gid, sid, data, did=None):
|
||||
@@ -733,7 +735,7 @@ class DatabaseView(PGChildNodeView):
|
||||
try:
|
||||
acls = render_template(
|
||||
"/".join([self.template_path, 'allowed_privs.json'])
|
||||
)
|
||||
)
|
||||
acls = json.loads(acls)
|
||||
except Exception as e:
|
||||
current_app.logger.exception(e)
|
||||
@@ -747,12 +749,12 @@ class DatabaseView(PGChildNodeView):
|
||||
if key in data[aclcol]:
|
||||
data[aclcol][key] = parse_priv_to_db(
|
||||
data[aclcol][key], allowedacl['acl']
|
||||
)
|
||||
)
|
||||
|
||||
return render_template(
|
||||
"/".join([self.template_path, 'alter_online.sql']),
|
||||
data=data, conn=self.conn
|
||||
)
|
||||
)
|
||||
|
||||
def get_offline_sql(self, gid, sid, data, did=None, action=None):
|
||||
"""
|
||||
@@ -763,22 +765,22 @@ class DatabaseView(PGChildNodeView):
|
||||
return render_template(
|
||||
"/".join([self.template_path, 'alter_offline.sql']),
|
||||
data=data, conn=self.conn, action=action
|
||||
)
|
||||
)
|
||||
|
||||
@check_precondition(action="variable_options")
|
||||
def variable_options(self, gid, sid):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'variables.sql'])
|
||||
)
|
||||
)
|
||||
status, rset = self.conn.execute_dict(SQL)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=rset)
|
||||
|
||||
return make_json_response(
|
||||
data=rset['rows'],
|
||||
status=200
|
||||
)
|
||||
data=rset['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition()
|
||||
def statistics(self, gid, sid, did=None):
|
||||
@@ -794,16 +796,16 @@ class DatabaseView(PGChildNodeView):
|
||||
render_template(
|
||||
"/".join([self.template_path, 'stats.sql']),
|
||||
did=did, conn=self.conn, last_system_oid=last_system_oid
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition(action="sql")
|
||||
def sql(self, gid, sid, did):
|
||||
@@ -813,7 +815,7 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
did=did, conn=self.conn, last_system_oid=0
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -821,7 +823,7 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'acl.sql']),
|
||||
did=did, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, dataclres = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -830,7 +832,7 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'defacl.sql']),
|
||||
did=did, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, defaclres = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -842,7 +844,7 @@ class DatabaseView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'get_variables.sql']),
|
||||
did=did, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, res1 = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res1)
|
||||
@@ -875,9 +877,9 @@ class DatabaseView(PGChildNodeView):
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, did)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition()
|
||||
def dependencies(self, gid, sid, did):
|
||||
@@ -892,8 +894,9 @@ class DatabaseView(PGChildNodeView):
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, did)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
DatabaseView.register_node_view(blueprint)
|
||||
|
||||
@@ -621,13 +621,13 @@ class CastView(PGChildNodeView):
|
||||
return internal_server_error(
|
||||
_("Could not generate reversed engineered SQL for the cast.\n\n{0}").format(
|
||||
res
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if res is None:
|
||||
return gone(
|
||||
_("Could not generate reversed engineered SQL for the cast node.\n")
|
||||
)
|
||||
)
|
||||
|
||||
return ajax_response(response=res)
|
||||
|
||||
@@ -648,9 +648,9 @@ class CastView(PGChildNodeView):
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, cid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, cid):
|
||||
@@ -666,10 +666,9 @@ class CastView(PGChildNodeView):
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, cid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
CastView.register_node_view(blueprint)
|
||||
|
||||
@@ -143,13 +143,13 @@ class EventTriggerView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'etid'}
|
||||
]
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -172,12 +172,12 @@ class EventTriggerView(PGChildNodeView):
|
||||
Returns the javascript module for event trigger.
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"event_triggers/js/event_trigger.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"event_triggers/js/event_trigger.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def check_precondition(f):
|
||||
"""
|
||||
@@ -185,6 +185,7 @@ class EventTriggerView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -196,7 +197,7 @@ class EventTriggerView(PGChildNodeView):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -205,8 +206,8 @@ class EventTriggerView(PGChildNodeView):
|
||||
self.template_path = 'event_triggers/sql/9.3_plus'
|
||||
|
||||
return f(*args, **kwargs)
|
||||
return wrap
|
||||
|
||||
return wrap
|
||||
|
||||
@check_precondition
|
||||
def list(self, gid, sid, did):
|
||||
@@ -229,9 +230,9 @@ class EventTriggerView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did):
|
||||
@@ -256,17 +257,17 @@ class EventTriggerView(PGChildNodeView):
|
||||
|
||||
for row in res['rows']:
|
||||
result.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
did,
|
||||
row['name'],
|
||||
icon="icon-%s" % self.node_type
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
did,
|
||||
row['name'],
|
||||
icon="icon-%s" % self.node_type
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=result,
|
||||
status=200
|
||||
)
|
||||
data=result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, etid):
|
||||
@@ -297,12 +298,12 @@ class EventTriggerView(PGChildNodeView):
|
||||
sec_labels.append({
|
||||
'provider': sec.group(1),
|
||||
'securitylabel': sec.group(2)
|
||||
})
|
||||
})
|
||||
result.update({"seclabels": sec_labels})
|
||||
return ajax_response(
|
||||
response=result,
|
||||
status=200
|
||||
)
|
||||
response=result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def create(self, gid, sid, did):
|
||||
@@ -320,11 +321,11 @@ class EventTriggerView(PGChildNodeView):
|
||||
"""
|
||||
data = request.form if request.form else json.loads(request.data.decode())
|
||||
required_args = {
|
||||
'name':'Name',
|
||||
'eventowner':'Owner',
|
||||
'eventfunname':'Trigger function',
|
||||
'enabled':'Enabled status',
|
||||
'eventname':'Events'
|
||||
'name': 'Name',
|
||||
'eventowner': 'Owner',
|
||||
'eventfunname': 'Trigger function',
|
||||
'enabled': 'Enabled status',
|
||||
'eventname': 'Events'
|
||||
}
|
||||
err = []
|
||||
for arg in required_args:
|
||||
@@ -332,12 +333,12 @@ class EventTriggerView(PGChildNodeView):
|
||||
err.append(required_args.get(arg, arg))
|
||||
if err:
|
||||
return make_json_response(
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=gettext(
|
||||
"Could not find the required parameter %s." % err
|
||||
)
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=gettext(
|
||||
"Could not find the required parameter %s." % err
|
||||
)
|
||||
)
|
||||
try:
|
||||
sql = render_template("/".join([self.template_path, 'create.sql']), data=data, conn=self.conn)
|
||||
status, res = self.conn.execute_scalar(sql)
|
||||
@@ -395,13 +396,13 @@ class EventTriggerView(PGChildNodeView):
|
||||
status, etid = self.conn.execute_scalar(sql)
|
||||
|
||||
return jsonify(
|
||||
node=self.blueprint.generate_browser_node(
|
||||
etid,
|
||||
did,
|
||||
data['name'],
|
||||
icon="icon-%s" % self.node_type
|
||||
)
|
||||
node=self.blueprint.generate_browser_node(
|
||||
etid,
|
||||
did,
|
||||
data['name'],
|
||||
icon="icon-%s" % self.node_type
|
||||
)
|
||||
)
|
||||
else:
|
||||
return make_json_response(
|
||||
success=1,
|
||||
@@ -417,7 +418,6 @@ class EventTriggerView(PGChildNodeView):
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
|
||||
@check_precondition
|
||||
def delete(self, gid, sid, did, etid):
|
||||
"""
|
||||
@@ -464,7 +464,7 @@ class EventTriggerView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@check_precondition
|
||||
def msql(self, gid, sid, did, etid = None):
|
||||
def msql(self, gid, sid, did, etid=None):
|
||||
"""
|
||||
This function is used to return modified SQL for the selected
|
||||
event trigger node.
|
||||
@@ -489,9 +489,9 @@ class EventTriggerView(PGChildNodeView):
|
||||
sql = sql.strip('\n').strip(' ')
|
||||
|
||||
return make_json_response(
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -523,11 +523,11 @@ class EventTriggerView(PGChildNodeView):
|
||||
sql = render_template("/".join([self.template_path, 'update.sql']), data=data, o_data=old_data)
|
||||
else:
|
||||
required_args = {
|
||||
'name':'Name',
|
||||
'eventowner':'Owner',
|
||||
'eventfunname':'Trigger function',
|
||||
'enabled':'Enabled status',
|
||||
'eventname':'Events'
|
||||
'name': 'Name',
|
||||
'eventowner': 'Owner',
|
||||
'eventfunname': 'Trigger function',
|
||||
'enabled': 'Enabled status',
|
||||
'eventname': 'Events'
|
||||
}
|
||||
err = []
|
||||
for arg in required_args:
|
||||
@@ -535,12 +535,12 @@ class EventTriggerView(PGChildNodeView):
|
||||
err.append(required_args.get(arg, arg))
|
||||
if err:
|
||||
return make_json_response(
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=gettext(
|
||||
"Could not find the required parameter %s." % err
|
||||
)
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=gettext(
|
||||
"Could not find the required parameter %s." % err
|
||||
)
|
||||
)
|
||||
sql = render_template("/".join([self.template_path, 'create.sql']), data=data)
|
||||
sql += "\n"
|
||||
sql += render_template("/".join([self.template_path, 'grant.sql']), data=data)
|
||||
@@ -581,8 +581,8 @@ class EventTriggerView(PGChildNodeView):
|
||||
sql_header = "-- Event Trigger: {0} on database {1}\n\n-- ".format(result['name'], db_name)
|
||||
|
||||
sql_header += render_template(
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
name=result['name'], )
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
name=result['name'], )
|
||||
sql_header += "\n"
|
||||
|
||||
sql = sql_header + sql
|
||||
@@ -592,7 +592,6 @@ class EventTriggerView(PGChildNodeView):
|
||||
except Exception as e:
|
||||
return ajax_response(response=str(e))
|
||||
|
||||
|
||||
@check_precondition
|
||||
def get_event_funcs(self, gid, sid, did, etid=None):
|
||||
"""
|
||||
@@ -608,7 +607,7 @@ class EventTriggerView(PGChildNodeView):
|
||||
Returns:
|
||||
|
||||
"""
|
||||
res = [{ 'label': '', 'value': '' }]
|
||||
res = [{'label': '', 'value': ''}]
|
||||
sql = render_template("/".join([self.template_path, 'eventfunctions.sql']))
|
||||
status, rest = self.conn.execute_2darray(sql)
|
||||
if not status:
|
||||
@@ -618,9 +617,9 @@ class EventTriggerView(PGChildNodeView):
|
||||
{'label': row['tfname'], 'value': row['tfname']}
|
||||
)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependents(self, gid, sid, did, etid=None):
|
||||
@@ -636,9 +635,9 @@ class EventTriggerView(PGChildNodeView):
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, etid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, etid):
|
||||
@@ -654,8 +653,9 @@ class EventTriggerView(PGChildNodeView):
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, etid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
EventTriggerView.register_node_view(blueprint)
|
||||
|
||||
@@ -104,13 +104,13 @@ class ExtensionView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'eid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'eid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -136,17 +136,19 @@ class ExtensionView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
self = args[0]
|
||||
self.manager = get_driver(
|
||||
PG_DEFAULT_DRIVER
|
||||
).connection_manager(kwargs['sid'])
|
||||
PG_DEFAULT_DRIVER
|
||||
).connection_manager(kwargs['sid'])
|
||||
self.conn = self.manager.connection(did=kwargs['did'])
|
||||
self.template_path = 'extensions/sql'
|
||||
|
||||
return f(*args, **kwargs)
|
||||
|
||||
return wrap
|
||||
|
||||
@check_precondition
|
||||
@@ -160,9 +162,9 @@ class ExtensionView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did):
|
||||
@@ -177,17 +179,17 @@ class ExtensionView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['eid'],
|
||||
did,
|
||||
row['name'],
|
||||
'icon-extension'
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['eid'],
|
||||
did,
|
||||
row['name'],
|
||||
'icon-extension'
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, eid):
|
||||
@@ -201,9 +203,9 @@ class ExtensionView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def create(self, gid, sid, did):
|
||||
@@ -230,8 +232,8 @@ class ExtensionView(PGChildNodeView):
|
||||
render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
data=data
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -248,12 +250,12 @@ class ExtensionView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
return jsonify(
|
||||
node=self.blueprint.generate_browser_node(
|
||||
node=self.blueprint.generate_browser_node(
|
||||
row['eid'],
|
||||
did,
|
||||
row['name'],
|
||||
'icon-extension'
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
@@ -310,8 +312,8 @@ class ExtensionView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=name)
|
||||
# drop extension
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'delete.sql']
|
||||
), name=name, cascade=cascade)
|
||||
[self.template_path, 'delete.sql']
|
||||
), name=name, cascade=cascade)
|
||||
status, res = self.conn.execute_scalar(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -339,14 +341,14 @@ class ExtensionView(PGChildNodeView):
|
||||
if SQL and isinstance(SQL, basestring) and SQL.strip('\n') \
|
||||
and SQL.strip(' '):
|
||||
return make_json_response(
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
else:
|
||||
return make_json_response(
|
||||
data=gettext('-- Modified SQL --'),
|
||||
status=200
|
||||
)
|
||||
data=gettext('-- Modified SQL --'),
|
||||
status=200
|
||||
)
|
||||
|
||||
def getSQL(self, gid, sid, data, did, eid=None):
|
||||
"""
|
||||
@@ -358,8 +360,8 @@ class ExtensionView(PGChildNodeView):
|
||||
try:
|
||||
if eid is not None:
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'properties.sql']
|
||||
), eid=eid)
|
||||
[self.template_path, 'properties.sql']
|
||||
), eid=eid)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -368,12 +370,12 @@ class ExtensionView(PGChildNodeView):
|
||||
if arg not in data:
|
||||
data[arg] = old_data[arg]
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'update.sql']
|
||||
), data=data, o_data=old_data)
|
||||
[self.template_path, 'update.sql']
|
||||
), data=data, o_data=old_data)
|
||||
else:
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'create.sql']
|
||||
), data=data)
|
||||
[self.template_path, 'create.sql']
|
||||
), data=data)
|
||||
return SQL
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -388,9 +390,9 @@ class ExtensionView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=rset)
|
||||
return make_json_response(
|
||||
data=rset['rows'],
|
||||
status=200
|
||||
)
|
||||
data=rset['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def schemas(self, gid, sid, did):
|
||||
@@ -402,21 +404,21 @@ class ExtensionView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=rset)
|
||||
return make_json_response(
|
||||
data=rset['rows'],
|
||||
status=200
|
||||
)
|
||||
data=rset['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
def module_js(self):
|
||||
"""
|
||||
This property defines whether javascript exists for this node.
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"extensions/js/extensions.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"extensions/js/extensions.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def sql(self, gid, sid, did, eid):
|
||||
@@ -424,8 +426,8 @@ class ExtensionView(PGChildNodeView):
|
||||
This function will generate sql for the sql panel
|
||||
"""
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'properties.sql']
|
||||
), eid=eid)
|
||||
[self.template_path, 'properties.sql']
|
||||
), eid=eid)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -433,8 +435,8 @@ class ExtensionView(PGChildNodeView):
|
||||
result = res['rows'][0]
|
||||
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'create.sql']
|
||||
),
|
||||
[self.template_path, 'create.sql']
|
||||
),
|
||||
data=result,
|
||||
conn=self.conn,
|
||||
display_comments=True
|
||||
@@ -458,7 +460,7 @@ class ExtensionView(PGChildNodeView):
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, eid):
|
||||
@@ -476,7 +478,8 @@ class ExtensionView(PGChildNodeView):
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# Register and add ExtensionView as blueprint
|
||||
ExtensionView.register_node_view(blueprint)
|
||||
|
||||
@@ -83,6 +83,7 @@ class ForeignDataWrapperModule(CollectionNodeModule):
|
||||
"""
|
||||
return servers.ServerModule.NODE_TYPE
|
||||
|
||||
|
||||
blueprint = ForeignDataWrapperModule(__name__)
|
||||
|
||||
|
||||
@@ -155,13 +156,13 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'fid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'fid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -169,7 +170,7 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
{'get': 'list', 'post': 'create'}
|
||||
],
|
||||
'delete': [{
|
||||
'delete': 'delete'
|
||||
'delete': 'delete'
|
||||
}],
|
||||
'nodes': [{'get': 'node'}, {'get': 'nodes'}],
|
||||
'children': [{'get': 'children'}],
|
||||
@@ -189,12 +190,12 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
Override this property for your own logic.
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"foreign_data_wrappers/js/foreign_data_wrappers.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"foreign_data_wrappers/js/foreign_data_wrappers.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def check_precondition(f):
|
||||
"""
|
||||
@@ -202,6 +203,7 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -213,7 +215,7 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -225,6 +227,7 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
self.template_path = 'foreign_data_wrappers/sql/9.1_plus'
|
||||
|
||||
return f(*args, **kwargs)
|
||||
|
||||
return wrap
|
||||
|
||||
@check_precondition
|
||||
@@ -248,9 +251,9 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
row['fdwoptions'] = self.tokenize_options(row['fdwoptions'])
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did):
|
||||
@@ -271,17 +274,17 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
|
||||
for row in r_set['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['fdwoid'],
|
||||
did,
|
||||
row['name'],
|
||||
icon="icon-foreign_data_wrapper"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['fdwoid'],
|
||||
did,
|
||||
row['name'],
|
||||
icon="icon-foreign_data_wrapper"
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
def tokenize_options(self, option_value):
|
||||
"""
|
||||
@@ -334,9 +337,9 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
res['rows'][0][row['deftype']] = [privilege]
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def create(self, gid, sid, did):
|
||||
@@ -431,7 +434,7 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
success=1,
|
||||
info="Foreign Data Wrapper updated",
|
||||
data={
|
||||
'id': fid,
|
||||
'id': fid,
|
||||
'did': did,
|
||||
'sid': sid,
|
||||
'gid': gid
|
||||
@@ -442,7 +445,7 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
success=1,
|
||||
info="Nothing to update",
|
||||
data={
|
||||
'id': fid,
|
||||
'id': fid,
|
||||
'did': did,
|
||||
'sid': sid,
|
||||
'gid': gid
|
||||
@@ -516,9 +519,9 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
|
||||
sql = self.get_sql(gid, sid, data, did, fid)
|
||||
if sql and sql.strip('\n') and sql.strip(' '):
|
||||
return make_json_response(data=sql,status=200)
|
||||
return make_json_response(data=sql, status=200)
|
||||
else:
|
||||
return make_json_response(data='-- Modified SQL --',status=200)
|
||||
return make_json_response(data='-- Modified SQL --', status=200)
|
||||
|
||||
def get_sql(self, gid, sid, data, did, fid=None):
|
||||
"""
|
||||
@@ -547,11 +550,11 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
for key in ['fdwacl']:
|
||||
if key in data and data[key] is not None:
|
||||
if 'added' in data[key]:
|
||||
data[key]['added'] = parse_priv_to_db(data[key]['added'], ['U'])
|
||||
data[key]['added'] = parse_priv_to_db(data[key]['added'], ['U'])
|
||||
if 'changed' in data[key]:
|
||||
data[key]['changed'] = parse_priv_to_db(data[key]['changed'], ['U'])
|
||||
data[key]['changed'] = parse_priv_to_db(data[key]['changed'], ['U'])
|
||||
if 'deleted' in data[key]:
|
||||
data[key]['deleted'] = parse_priv_to_db(data[key]['deleted'], ['U'])
|
||||
data[key]['deleted'] = parse_priv_to_db(data[key]['deleted'], ['U'])
|
||||
|
||||
old_data = res['rows'][0]
|
||||
for arg in required_args:
|
||||
@@ -688,7 +691,7 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
for row in r_set['rows']:
|
||||
res.append({'label': row['fdwvalue'], 'value': row['fdwvalue']})
|
||||
|
||||
return make_json_response( data=res, status=200)
|
||||
return make_json_response(data=res, status=200)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -715,9 +718,9 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
res.append({'label': row['fdwhan'], 'value': row['fdwhan']})
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -736,9 +739,9 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, fid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, fid):
|
||||
@@ -754,8 +757,9 @@ class ForeignDataWrapperView(PGChildNodeView):
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, fid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
ForeignDataWrapperView.register_node_view(blueprint)
|
||||
|
||||
@@ -84,6 +84,7 @@ class ForeignServerModule(CollectionNodeModule):
|
||||
"""
|
||||
return databases.DatabaseModule.NODE_TYPE
|
||||
|
||||
|
||||
blueprint = ForeignServerModule(__name__)
|
||||
|
||||
|
||||
@@ -150,14 +151,14 @@ class ForeignServerView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'fid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'fid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'fsid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'fsid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -165,7 +166,7 @@ class ForeignServerView(PGChildNodeView):
|
||||
{'get': 'list', 'post': 'create'}
|
||||
],
|
||||
'delete': [{
|
||||
'delete': 'delete'
|
||||
'delete': 'delete'
|
||||
}],
|
||||
'nodes': [{'get': 'node'}, {'get': 'nodes'}],
|
||||
'children': [{'get': 'children'}],
|
||||
@@ -183,12 +184,12 @@ class ForeignServerView(PGChildNodeView):
|
||||
Override this property for your own logic.
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"foreign_servers/js/foreign_servers.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"foreign_servers/js/foreign_servers.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def check_precondition(f):
|
||||
"""
|
||||
@@ -196,6 +197,7 @@ class ForeignServerView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -207,7 +209,7 @@ class ForeignServerView(PGChildNodeView):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -219,6 +221,7 @@ class ForeignServerView(PGChildNodeView):
|
||||
self.template_path = 'foreign_servers/sql/9.1_plus'
|
||||
|
||||
return f(*args, **kwargs)
|
||||
|
||||
return wrap
|
||||
|
||||
@check_precondition
|
||||
@@ -240,9 +243,9 @@ class ForeignServerView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did, fid):
|
||||
@@ -266,17 +269,17 @@ class ForeignServerView(PGChildNodeView):
|
||||
|
||||
for row in r_set['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['fsrvid'],
|
||||
fid,
|
||||
row['name'],
|
||||
icon="icon-foreign_server"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['fsrvid'],
|
||||
fid,
|
||||
row['name'],
|
||||
icon="icon-foreign_server"
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
def tokenizeOptions(self, option_value):
|
||||
"""
|
||||
@@ -333,9 +336,9 @@ class ForeignServerView(PGChildNodeView):
|
||||
res['rows'][0][row['deftype']] = [privilege]
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def create(self, gid, sid, did, fid):
|
||||
@@ -437,7 +440,7 @@ class ForeignServerView(PGChildNodeView):
|
||||
success=1,
|
||||
info="Foreign server updated",
|
||||
data={
|
||||
'id': fsid,
|
||||
'id': fsid,
|
||||
'fid': fid,
|
||||
'did': did,
|
||||
'sid': sid,
|
||||
@@ -449,7 +452,7 @@ class ForeignServerView(PGChildNodeView):
|
||||
success=1,
|
||||
info="Nothing to update",
|
||||
data={
|
||||
'id': fsid,
|
||||
'id': fsid,
|
||||
'fid': fid,
|
||||
'did': did,
|
||||
'sid': sid,
|
||||
@@ -530,14 +533,14 @@ class ForeignServerView(PGChildNodeView):
|
||||
sql = self.get_sql(gid, sid, data, did, fid, fsid)
|
||||
if sql and sql.strip('\n') and sql.strip(' '):
|
||||
return make_json_response(
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
else:
|
||||
return make_json_response(
|
||||
data='-- Modified SQL --',
|
||||
status=200
|
||||
)
|
||||
data='-- Modified SQL --',
|
||||
status=200
|
||||
)
|
||||
|
||||
def get_sql(self, gid, sid, data, did, fid, fsid=None):
|
||||
"""
|
||||
@@ -568,11 +571,11 @@ class ForeignServerView(PGChildNodeView):
|
||||
for key in ['fsrvacl']:
|
||||
if key in data and data[key] is not None:
|
||||
if 'added' in data[key]:
|
||||
data[key]['added'] = parse_priv_to_db(data[key]['added'], ['U'])
|
||||
data[key]['added'] = parse_priv_to_db(data[key]['added'], ['U'])
|
||||
if 'changed' in data[key]:
|
||||
data[key]['changed'] = parse_priv_to_db(data[key]['changed'], ['U'])
|
||||
data[key]['changed'] = parse_priv_to_db(data[key]['changed'], ['U'])
|
||||
if 'deleted' in data[key]:
|
||||
data[key]['deleted'] = parse_priv_to_db(data[key]['deleted'], ['U'])
|
||||
data[key]['deleted'] = parse_priv_to_db(data[key]['deleted'], ['U'])
|
||||
|
||||
old_data = res['rows'][0]
|
||||
for arg in required_args:
|
||||
@@ -727,12 +730,13 @@ class ForeignServerView(PGChildNodeView):
|
||||
internal_server_error(errormsg=result)
|
||||
|
||||
for row in result['rows']:
|
||||
dependents_result.append({'type': 'user_mapping', 'name': row['name'], 'field': 'normal' if (row['deptype'] == 'n') else ''})
|
||||
dependents_result.append(
|
||||
{'type': 'user_mapping', 'name': row['name'], 'field': 'normal' if (row['deptype'] == 'n') else ''})
|
||||
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, fid, fsid):
|
||||
@@ -749,8 +753,9 @@ class ForeignServerView(PGChildNodeView):
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, fsid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
ForeignServerView.register_node_view(blueprint)
|
||||
|
||||
@@ -97,6 +97,7 @@ class UserMappingModule(CollectionNodeModule):
|
||||
|
||||
return servers.ServerModule.NODE_TYPE
|
||||
|
||||
|
||||
blueprint = UserMappingModule(__name__)
|
||||
|
||||
|
||||
@@ -163,15 +164,15 @@ class UserMappingView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'fid'},
|
||||
{'type': 'int', 'id': 'fsid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'fid'},
|
||||
{'type': 'int', 'id': 'fsid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'umid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'umid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -179,7 +180,7 @@ class UserMappingView(PGChildNodeView):
|
||||
{'get': 'list', 'post': 'create'}
|
||||
],
|
||||
'delete': [{
|
||||
'delete': 'delete'
|
||||
'delete': 'delete'
|
||||
}],
|
||||
'nodes': [{'get': 'node'}, {'get': 'nodes'}],
|
||||
'children': [{'get': 'children'}],
|
||||
@@ -197,12 +198,12 @@ class UserMappingView(PGChildNodeView):
|
||||
Override this property for your own logic.
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"user_mappings/js/user_mappings.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"user_mappings/js/user_mappings.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def check_precondition(f):
|
||||
"""
|
||||
@@ -210,6 +211,7 @@ class UserMappingView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -221,7 +223,7 @@ class UserMappingView(PGChildNodeView):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -233,6 +235,7 @@ class UserMappingView(PGChildNodeView):
|
||||
self.template_path = 'user_mappings/sql/9.1_plus'
|
||||
|
||||
return f(*args, **kwargs)
|
||||
|
||||
return wrap
|
||||
|
||||
@check_precondition
|
||||
@@ -255,9 +258,9 @@ class UserMappingView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did, fid, fsid):
|
||||
@@ -282,17 +285,17 @@ class UserMappingView(PGChildNodeView):
|
||||
|
||||
for row in r_set['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['um_oid'],
|
||||
fsid,
|
||||
row['name'],
|
||||
icon="icon-user_mapping"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['um_oid'],
|
||||
fsid,
|
||||
row['name'],
|
||||
icon="icon-user_mapping"
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
def tokenizeOptions(self, option_value):
|
||||
"""
|
||||
@@ -310,7 +313,7 @@ class UserMappingView(PGChildNodeView):
|
||||
um_options = []
|
||||
for um_option in option_str:
|
||||
k, v = um_option.split('=', 1)
|
||||
um_options.append({'umoption': k,'umvalue': v})
|
||||
um_options.append({'umoption': k, 'umvalue': v})
|
||||
return um_options
|
||||
|
||||
@check_precondition
|
||||
@@ -340,9 +343,9 @@ class UserMappingView(PGChildNodeView):
|
||||
res['rows'][0]['umoptions'] = self.tokenizeOptions(res['rows'][0]['umoptions'])
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def create(self, gid, sid, did, fid, fsid):
|
||||
@@ -415,8 +418,8 @@ class UserMappingView(PGChildNodeView):
|
||||
fsid,
|
||||
row['name'],
|
||||
icon='icon-user_mapping'
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -447,7 +450,7 @@ class UserMappingView(PGChildNodeView):
|
||||
success=1,
|
||||
info="User Mapping updated",
|
||||
data={
|
||||
'id': umid,
|
||||
'id': umid,
|
||||
'fsid': fsid,
|
||||
'fid': fid,
|
||||
'did': did,
|
||||
@@ -460,7 +463,7 @@ class UserMappingView(PGChildNodeView):
|
||||
success=1,
|
||||
info="Nothing to update",
|
||||
data={
|
||||
'id': umid,
|
||||
'id': umid,
|
||||
'fsid': fsid,
|
||||
'fid': fid,
|
||||
'did': did,
|
||||
@@ -553,14 +556,14 @@ class UserMappingView(PGChildNodeView):
|
||||
sql = self.get_sql(gid, sid, data, did, fid, fsid, umid)
|
||||
if sql and sql.strip('\n') and sql.strip(' '):
|
||||
return make_json_response(
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
else:
|
||||
return make_json_response(
|
||||
data='-- Modified SQL --',
|
||||
status=200
|
||||
)
|
||||
data='-- Modified SQL --',
|
||||
status=200
|
||||
)
|
||||
|
||||
def get_sql(self, gid, sid, data, did, fid, fsid, umid=None):
|
||||
"""
|
||||
@@ -728,9 +731,9 @@ class UserMappingView(PGChildNodeView):
|
||||
|
||||
dependents_result = self.get_dependents(self.conn, umid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, fid, fsid, umid):
|
||||
@@ -748,8 +751,9 @@ class UserMappingView(PGChildNodeView):
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, umid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
UserMappingView.register_node_view(blueprint)
|
||||
|
||||
@@ -94,6 +94,7 @@ class LanguageModule(CollectionNodeModule):
|
||||
"""
|
||||
return databases.DatabaseModule.NODE_TYPE
|
||||
|
||||
|
||||
blueprint = LanguageModule(__name__)
|
||||
|
||||
|
||||
@@ -154,13 +155,13 @@ class LanguageView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'lid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'lid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -196,12 +197,12 @@ class LanguageView(PGChildNodeView):
|
||||
This property defines whether javascript exists for this node.
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"languages/js/languages.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"languages/js/languages.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def check_precondition(f):
|
||||
"""
|
||||
@@ -209,6 +210,7 @@ class LanguageView(PGChildNodeView):
|
||||
database connection before running the view. It also attaches
|
||||
manager, conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -221,7 +223,7 @@ class LanguageView(PGChildNodeView):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -233,6 +235,7 @@ class LanguageView(PGChildNodeView):
|
||||
self.template_path = 'languages/sql/9.1_plus'
|
||||
|
||||
return f(*args, **kwargs)
|
||||
|
||||
return wrap
|
||||
|
||||
@check_precondition
|
||||
@@ -251,9 +254,9 @@ class LanguageView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did):
|
||||
@@ -274,17 +277,17 @@ class LanguageView(PGChildNodeView):
|
||||
|
||||
for row in result['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
did,
|
||||
row['name'],
|
||||
icon="icon-language"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
did,
|
||||
row['name'],
|
||||
icon="icon-language"
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, lid):
|
||||
@@ -323,9 +326,9 @@ class LanguageView(PGChildNodeView):
|
||||
res['rows'][0][row['deftype']] = [priv]
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def update(self, gid, sid, did, lid):
|
||||
@@ -393,14 +396,14 @@ class LanguageView(PGChildNodeView):
|
||||
sql = self.get_sql(data, lid)
|
||||
if sql and sql.strip('\n') and sql.strip(' '):
|
||||
return make_json_response(
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
else:
|
||||
return make_json_response(
|
||||
data='-- Modified SQL --',
|
||||
status=200
|
||||
)
|
||||
data='-- Modified SQL --',
|
||||
status=200
|
||||
)
|
||||
|
||||
def get_sql(self, data, lid=None):
|
||||
"""
|
||||
@@ -455,9 +458,9 @@ class LanguageView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=result)
|
||||
return make_json_response(
|
||||
data=result['rows'],
|
||||
status=200
|
||||
)
|
||||
data=result['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def sql(self, gid, sid, did, lid):
|
||||
@@ -495,9 +498,9 @@ class LanguageView(PGChildNodeView):
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, lid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, lid):
|
||||
@@ -513,8 +516,9 @@ class LanguageView(PGChildNodeView):
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, lid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
LanguageView.register_node_view(blueprint)
|
||||
|
||||
@@ -120,6 +120,7 @@ def check_precondition(f):
|
||||
Assumptions:
|
||||
This function will always be used as decorator of a class method.
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -139,7 +140,7 @@ def check_precondition(f):
|
||||
self.ppas_template_path(self.manager.version)
|
||||
if self.manager.server_type == 'ppas' else
|
||||
self.pg_template_path(self.manager.version)
|
||||
)
|
||||
)
|
||||
|
||||
return f(*args, **kwargs)
|
||||
|
||||
@@ -201,20 +202,20 @@ class SchemaView(PGChildNodeView):
|
||||
node_type = schema_blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'scid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'scid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
{'get': 'properties', 'delete': 'delete', 'put': 'update'},
|
||||
{'get': 'list', 'post': 'create'}
|
||||
],
|
||||
'children': [{ 'get': 'children'}],
|
||||
'children': [{'get': 'children'}],
|
||||
'nodes': [{'get': 'nodes'}, {'get': 'nodes'}],
|
||||
'sql': [{'get': 'sql'}],
|
||||
'msql': [{'get': 'msql'}, {'get': 'msql'}],
|
||||
@@ -237,7 +238,6 @@ class SchemaView(PGChildNodeView):
|
||||
self.template_path = None
|
||||
self.template_initial = 'schema'
|
||||
|
||||
|
||||
@staticmethod
|
||||
def ppas_template_path(ver):
|
||||
"""
|
||||
@@ -261,7 +261,7 @@ class SchemaView(PGChildNodeView):
|
||||
try:
|
||||
acls = render_template(
|
||||
"/".join([self.template_path, 'allowed_privs.json'])
|
||||
)
|
||||
)
|
||||
acls = json.loads(acls)
|
||||
except Exception as e:
|
||||
current_app.logger.exception(e)
|
||||
@@ -278,7 +278,7 @@ class SchemaView(PGChildNodeView):
|
||||
if modifier in data[aclcol]:
|
||||
data[aclcol][modifier] = parse_priv_to_db(
|
||||
data[aclcol][modifier], allowedacl['acl']
|
||||
)
|
||||
)
|
||||
else:
|
||||
data[aclcol] = parse_priv_to_db(data[aclcol], allowedacl['acl'])
|
||||
|
||||
@@ -322,7 +322,7 @@ class SchemaView(PGChildNodeView):
|
||||
seclabels.append({
|
||||
'provider': sec.group(1),
|
||||
'label': sec.group(2)
|
||||
})
|
||||
})
|
||||
|
||||
data['seclabels'] = seclabels
|
||||
|
||||
@@ -331,7 +331,7 @@ class SchemaView(PGChildNodeView):
|
||||
"/".join([self.template_path, 'sql/acl.sql']),
|
||||
_=gettext,
|
||||
scid=scid
|
||||
)
|
||||
)
|
||||
status, acl = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=acl)
|
||||
@@ -350,7 +350,7 @@ class SchemaView(PGChildNodeView):
|
||||
"/".join([self.template_path, 'sql/defacl.sql']),
|
||||
_=gettext,
|
||||
scid=scid
|
||||
)
|
||||
)
|
||||
|
||||
status, defacl = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
@@ -377,15 +377,15 @@ class SchemaView(PGChildNodeView):
|
||||
"/".join([self.template_path, 'sql/properties.sql']),
|
||||
_=gettext,
|
||||
show_sysobj=self.blueprint.show_system_objects
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did, scid=None):
|
||||
@@ -407,7 +407,7 @@ class SchemaView(PGChildNodeView):
|
||||
show_sysobj=self.blueprint.show_system_objects,
|
||||
_=gettext,
|
||||
scid=scid
|
||||
)
|
||||
)
|
||||
|
||||
status, rset = self.conn.execute_2darray(SQL)
|
||||
if not status:
|
||||
@@ -431,13 +431,13 @@ It may have been removed by another user.
|
||||
icon=icon,
|
||||
can_create=row['can_create'],
|
||||
has_usage=row['has_usage']
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, scid):
|
||||
@@ -458,7 +458,7 @@ It may have been removed by another user.
|
||||
scid=scid,
|
||||
_=gettext,
|
||||
show_sysobj=self.blueprint.show_system_objects
|
||||
)
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
@@ -476,9 +476,9 @@ It may have been removed by another user.
|
||||
copy_data = self._formatter(copy_data, scid)
|
||||
|
||||
return ajax_response(
|
||||
response=copy_data,
|
||||
status=200
|
||||
)
|
||||
response=copy_data,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def create(self, gid, sid, did):
|
||||
@@ -512,22 +512,22 @@ It may have been removed by another user.
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'sql/create.sql']),
|
||||
data=data, conn=self.conn, _=gettext
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_scalar(SQL)
|
||||
if not status:
|
||||
return make_json_response(
|
||||
status=410,
|
||||
success=0,
|
||||
errormsg=res + '\n' +
|
||||
'Operation failed while running create statement'
|
||||
)
|
||||
'Operation failed while running create statement'
|
||||
)
|
||||
|
||||
# we need oid to to add object in tree at browser,
|
||||
# below sql will gives the same
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'sql/oid.sql']),
|
||||
schema=data['name'], _=gettext
|
||||
)
|
||||
)
|
||||
|
||||
status, scid = self.conn.execute_scalar(SQL)
|
||||
if not status:
|
||||
@@ -611,7 +611,7 @@ It may have been removed by another user.
|
||||
"/".join([self.template_path, 'sql/get_name.sql']),
|
||||
_=gettext,
|
||||
scid=scid
|
||||
)
|
||||
)
|
||||
|
||||
status, name = self.conn.execute_scalar(SQL)
|
||||
if not status:
|
||||
@@ -621,7 +621,7 @@ It may have been removed by another user.
|
||||
"/".join([self.template_path, 'sql/delete.sql']),
|
||||
_=gettext, name=name, conn=self.conn,
|
||||
cascade=True if self.cmd == 'delete' else False
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_scalar(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -665,9 +665,9 @@ It may have been removed by another user.
|
||||
SQL = self.get_sql(gid, sid, data, scid)
|
||||
if SQL and SQL.strip('\n') and SQL.strip(' '):
|
||||
return make_json_response(
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -680,7 +680,7 @@ It may have been removed by another user.
|
||||
"/".join([self.template_path, 'sql/properties.sql']),
|
||||
_=gettext, scid=scid,
|
||||
show_sysobj=self.blueprint.show_system_objects
|
||||
)
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
@@ -699,7 +699,7 @@ It may have been removed by another user.
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'sql/update.sql']),
|
||||
_=gettext, data=data, o_data=old_data, conn=self.conn
|
||||
)
|
||||
)
|
||||
else:
|
||||
required_args = ['name']
|
||||
|
||||
@@ -713,7 +713,7 @@ It may have been removed by another user.
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'sql/create.sql']),
|
||||
data=data, conn=self.conn, _=gettext
|
||||
)
|
||||
)
|
||||
|
||||
return SQL
|
||||
|
||||
@@ -732,7 +732,7 @@ It may have been removed by another user.
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'sql/properties.sql']),
|
||||
scid=scid, _=gettext
|
||||
)
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
@@ -755,7 +755,7 @@ It may have been removed by another user.
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'sql/create.sql']),
|
||||
_=gettext, data=data, conn=self.conn
|
||||
)
|
||||
)
|
||||
|
||||
sql_header = """
|
||||
-- SCHEMA: {0}
|
||||
@@ -782,9 +782,9 @@ It may have been removed by another user.
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, scid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid):
|
||||
@@ -800,9 +800,9 @@ It may have been removed by another user.
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, scid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def children(self, **kwargs):
|
||||
@@ -811,7 +811,7 @@ It may have been removed by another user.
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'sql/is_catalog.sql']),
|
||||
scid=kwargs['scid'], _=gettext
|
||||
)
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
@@ -882,7 +882,6 @@ class CatalogView(SchemaView):
|
||||
|
||||
self.template_initial = 'catalog'
|
||||
|
||||
|
||||
def _formatter(self, data, scid=None):
|
||||
|
||||
"""
|
||||
@@ -917,7 +916,7 @@ class CatalogView(SchemaView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'sql/properties.sql']),
|
||||
scid=scid, _=gettext
|
||||
)
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
@@ -940,7 +939,7 @@ It may have been removed by another user.
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'sql/create.sql']),
|
||||
_=gettext, data=old_data, conn=self.conn
|
||||
)
|
||||
)
|
||||
|
||||
sql_header = """
|
||||
-- CATALOG: {0}
|
||||
|
||||
@@ -79,6 +79,7 @@ class CatalogObjectModule(SchemaChildModule):
|
||||
"""
|
||||
return database.DatabaseModule.NODE_TYPE
|
||||
|
||||
|
||||
blueprint = CatalogObjectModule(__name__)
|
||||
|
||||
|
||||
@@ -111,14 +112,14 @@ class CatalogObjectView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'coid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'coid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [{'get': 'properties'}, {'get': 'list'}],
|
||||
@@ -136,6 +137,7 @@ class CatalogObjectView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -148,12 +150,12 @@ class CatalogObjectView(PGChildNodeView):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
self.template_path = 'catalog_object/sql/{0}/9.1_plus'.format(
|
||||
'ppas' if self.manager.server_type == 'ppas' else 'pg'
|
||||
'ppas' if self.manager.server_type == 'ppas' else 'pg'
|
||||
)
|
||||
|
||||
return f(*args, **kwargs)
|
||||
@@ -177,8 +179,8 @@ class CatalogObjectView(PGChildNodeView):
|
||||
"""
|
||||
|
||||
SQL = render_template("/".join([
|
||||
self.template_path, 'properties.sql'
|
||||
]), scid=scid
|
||||
self.template_path, 'properties.sql'
|
||||
]), scid=scid
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
@@ -186,9 +188,9 @@ class CatalogObjectView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did, scid):
|
||||
@@ -216,17 +218,17 @@ class CatalogObjectView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
scid,
|
||||
row['name'],
|
||||
icon="icon-catalog_object"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
scid,
|
||||
row['name'],
|
||||
icon="icon-catalog_object"
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, scid, coid):
|
||||
@@ -255,9 +257,9 @@ class CatalogObjectView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependents(self, gid, sid, did, scid, coid):
|
||||
@@ -275,9 +277,9 @@ class CatalogObjectView(PGChildNodeView):
|
||||
dependents_result = self.get_dependents(self.conn, coid)
|
||||
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, coid):
|
||||
@@ -295,8 +297,9 @@ class CatalogObjectView(PGChildNodeView):
|
||||
dependencies_result = self.get_dependencies(self.conn, coid)
|
||||
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
CatalogObjectView.register_node_view(blueprint)
|
||||
|
||||
@@ -91,8 +91,9 @@ class CatalogObjectColumnsModule(CollectionNodeModule):
|
||||
# node preferences
|
||||
self.browser_preference = Preferences.module('browser')
|
||||
self.pref_show_system_objects = self.browser_preference.preference(
|
||||
'show_system_objects'
|
||||
)
|
||||
'show_system_objects'
|
||||
)
|
||||
|
||||
|
||||
blueprint = CatalogObjectColumnsModule(__name__)
|
||||
|
||||
@@ -131,15 +132,15 @@ class CatalogObjectColumnsView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'coid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'coid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'clid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'clid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [{'get': 'properties'}, {'get': 'list'}],
|
||||
@@ -156,6 +157,7 @@ class CatalogObjectColumnsView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -168,7 +170,7 @@ class CatalogObjectColumnsView(PGChildNodeView):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -201,9 +203,9 @@ class CatalogObjectColumnsView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did, scid, coid):
|
||||
@@ -230,17 +232,17 @@ class CatalogObjectColumnsView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['attnum'],
|
||||
coid,
|
||||
row['attname'],
|
||||
icon="icon-catalog_object_column"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['attnum'],
|
||||
coid,
|
||||
row['attname'],
|
||||
icon="icon-catalog_object_column"
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, scid, coid, clid):
|
||||
@@ -260,16 +262,16 @@ class CatalogObjectColumnsView(PGChildNodeView):
|
||||
JSON of selected column node
|
||||
"""
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
'properties.sql']),coid=coid, clid=clid)
|
||||
'properties.sql']), coid=coid, clid=clid)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependents(self, gid, sid, did, scid, coid, clid):
|
||||
@@ -319,9 +321,9 @@ class CatalogObjectColumnsView(PGChildNodeView):
|
||||
dependents_result.append({'type': 'sequence', 'name': ref_name, 'field': dep_type})
|
||||
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, coid, clid):
|
||||
@@ -348,9 +350,9 @@ class CatalogObjectColumnsView(PGChildNodeView):
|
||||
)
|
||||
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
CatalogObjectColumnsView.register_node_view(blueprint)
|
||||
|
||||
@@ -82,6 +82,7 @@ class CollationModule(SchemaChildModule):
|
||||
def node_inode(self):
|
||||
return False
|
||||
|
||||
|
||||
blueprint = CollationModule(__name__)
|
||||
|
||||
|
||||
@@ -142,14 +143,14 @@ class CollationView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'coid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'coid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -175,6 +176,7 @@ class CollationView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -187,7 +189,7 @@ class CollationView(PGChildNodeView):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -197,7 +199,6 @@ class CollationView(PGChildNodeView):
|
||||
|
||||
return wrap
|
||||
|
||||
|
||||
@check_precondition
|
||||
def list(self, gid, sid, did, scid):
|
||||
"""
|
||||
@@ -220,9 +221,9 @@ class CollationView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did, scid):
|
||||
@@ -249,17 +250,17 @@ class CollationView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
scid,
|
||||
row['name'],
|
||||
icon="icon-collation"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
scid,
|
||||
row['name'],
|
||||
icon="icon-collation"
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, scid, coid):
|
||||
@@ -288,9 +289,9 @@ class CollationView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -302,7 +303,7 @@ class CollationView(PGChildNodeView):
|
||||
as AJAX response.
|
||||
"""
|
||||
|
||||
res = [{ 'label': '', 'value': '' }]
|
||||
res = [{'label': '', 'value': ''}]
|
||||
try:
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
'get_collations.sql']))
|
||||
@@ -312,13 +313,13 @@ class CollationView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
{'label': row['copy_collation'],
|
||||
'value': row['copy_collation']}
|
||||
)
|
||||
{'label': row['copy_collation'],
|
||||
'value': row['copy_collation']}
|
||||
)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -364,7 +365,6 @@ class CollationView(PGChildNodeView):
|
||||
|
||||
return missing_definition_flag
|
||||
|
||||
|
||||
@check_precondition
|
||||
def create(self, gid, sid, did, scid):
|
||||
"""
|
||||
@@ -546,9 +546,9 @@ class CollationView(PGChildNodeView):
|
||||
SQL = self.get_sql(gid, sid, data, scid, coid)
|
||||
if SQL and SQL.strip('\n') and SQL.strip(' '):
|
||||
return make_json_response(
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -567,7 +567,7 @@ class CollationView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
data=data, o_data=old_data, conn=self.conn
|
||||
)
|
||||
)
|
||||
else:
|
||||
required_args = [
|
||||
'name'
|
||||
@@ -636,9 +636,9 @@ class CollationView(PGChildNodeView):
|
||||
)
|
||||
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, coid):
|
||||
@@ -658,8 +658,9 @@ class CollationView(PGChildNodeView):
|
||||
)
|
||||
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
CollationView.register_node_view(blueprint)
|
||||
|
||||
@@ -220,8 +220,8 @@ class DomainView(PGChildNodeView, DataTypeReader):
|
||||
# Coverts string into python list as expected.
|
||||
data[key] = json.loads(req[key])
|
||||
elif key == 'typnotnull':
|
||||
data[key] = True if req[key] == 'true' or req[key] is\
|
||||
True else\
|
||||
data[key] = True if req[key] == 'true' or req[key] is \
|
||||
True else \
|
||||
(False if req[key] == 'false' or req[key] is
|
||||
False else '')
|
||||
else:
|
||||
@@ -253,6 +253,7 @@ class DomainView(PGChildNodeView, DataTypeReader):
|
||||
Checks database connection status.
|
||||
Attach connection object and template path.
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
self = args[0]
|
||||
@@ -403,7 +404,7 @@ It may have been removed by another user or moved to another schema.
|
||||
|
||||
if basetype != '' and basetype.find("(") > 0:
|
||||
substr = basetype[basetype.find("(") + 1:len(
|
||||
basetype) - 1]
|
||||
basetype) - 1]
|
||||
typlen = substr.split(",")
|
||||
if len(typlen) > 1:
|
||||
typ_len = typlen[0]
|
||||
@@ -797,9 +798,9 @@ AND relkind != 'c'))"""
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, doid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, doid):
|
||||
@@ -816,8 +817,9 @@ AND relkind != 'c'))"""
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, doid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
DomainView.register_node_view(blueprint)
|
||||
|
||||
@@ -82,12 +82,11 @@ class DomainConstraintModule(CollectionNodeModule):
|
||||
Returns a snippet of css to include in the page
|
||||
"""
|
||||
return [
|
||||
render_template(
|
||||
"domain_constraints/css/domain_constraints.css",
|
||||
node_type=self.node_type
|
||||
)
|
||||
]
|
||||
|
||||
render_template(
|
||||
"domain_constraints/css/domain_constraints.css",
|
||||
node_type=self.node_type
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
blueprint = DomainConstraintModule(__name__)
|
||||
@@ -248,6 +247,7 @@ class DomainConstraintView(PGChildNodeView):
|
||||
Checks database connection status.
|
||||
Attach connection object and template path.
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
self = args[0]
|
||||
@@ -620,7 +620,7 @@ class DomainConstraintView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
data=data, o_data=old_data, conn=self.conn
|
||||
)
|
||||
)
|
||||
else:
|
||||
domain, schema = self._get_domain(doid)
|
||||
|
||||
@@ -665,9 +665,9 @@ class DomainConstraintView(PGChildNodeView):
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, coid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, doid, coid):
|
||||
@@ -685,8 +685,9 @@ class DomainConstraintView(PGChildNodeView):
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, coid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
DomainConstraintView.register_node_view(blueprint)
|
||||
|
||||
@@ -202,7 +202,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader):
|
||||
'get_collations': [
|
||||
{'get': 'get_collations'},
|
||||
{'get': 'get_collations'}
|
||||
],
|
||||
],
|
||||
'get_types': [{'get': 'types'}, {'get': 'types'}],
|
||||
'get_foreign_servers': [{'get': 'get_foreign_servers'},
|
||||
{'get': 'get_foreign_servers'}],
|
||||
@@ -225,6 +225,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader):
|
||||
|
||||
Above both the arguments will not be validated in the update action.
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(self, **kwargs):
|
||||
|
||||
@@ -264,7 +265,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader):
|
||||
if key in list_params and req[key] != '' \
|
||||
and req[key] is not None:
|
||||
# Coverts string into python list as expected.
|
||||
data[key] = [] if\
|
||||
data[key] = [] if \
|
||||
type(req[key]) == list and len(req[key]) == 0 else \
|
||||
json.loads(req[key])
|
||||
|
||||
@@ -297,7 +298,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader):
|
||||
|
||||
elif key == 'typnotnull':
|
||||
data[key] = True if (req[key] == 'true' or req[key]
|
||||
is True) else False if\
|
||||
is True) else False if \
|
||||
(req[key] == 'false' or req[key]) is False else ''
|
||||
else:
|
||||
data[key] = req[key]
|
||||
@@ -328,6 +329,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader):
|
||||
Checks the database connection status.
|
||||
Attaches the connection object and template path to the class object.
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
self = args[0]
|
||||
@@ -621,7 +623,7 @@ AND relkind != 'c'))"""
|
||||
exc_value,
|
||||
exc_traceback,
|
||||
limit=2
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
return internal_server_error(errormsg=str(exc_value))
|
||||
@@ -700,7 +702,7 @@ AND relkind != 'c'))"""
|
||||
try:
|
||||
# Fetch Name and Schema Name to delete the foreign table.
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
'delete.sql']), scid=scid, foid=foid)
|
||||
'delete.sql']), scid=scid, foid=foid)
|
||||
status, res = self.conn.execute_2darray(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -907,7 +909,8 @@ AND relkind != 'c'))"""
|
||||
|
||||
if 'coloptions' in c and len(c['coloptions']) > 0:
|
||||
for o in c['coloptions']:
|
||||
if o['option'] in old_col_frmt_options and o['value'] != old_col_frmt_options[o['option']]:
|
||||
if o['option'] in old_col_frmt_options and o['value'] != old_col_frmt_options[
|
||||
o['option']]:
|
||||
c['coloptions_updated']['changed'].append(o)
|
||||
elif o['option'] not in old_col_frmt_options:
|
||||
c['coloptions_updated']['added'].append(o)
|
||||
@@ -917,17 +920,16 @@ AND relkind != 'c'))"""
|
||||
for o in old_col_frmt_options:
|
||||
c['coloptions_updated']['deleted'].append({'option': o})
|
||||
|
||||
|
||||
# Parse Privileges
|
||||
if 'acl' in data and 'added' in data['acl']:
|
||||
data['acl']['added'] = parse_priv_to_db(data['acl']['added'],
|
||||
["a", "r", "w", "x"])
|
||||
["a", "r", "w", "x"])
|
||||
if 'acl' in data and 'changed' in data['acl']:
|
||||
data['acl']['changed'] = parse_priv_to_db(
|
||||
data['acl']['changed'],["a", "r", "w", "x"])
|
||||
data['acl']['changed'], ["a", "r", "w", "x"])
|
||||
if 'acl' in data and 'deleted' in data['acl']:
|
||||
data['acl']['deleted'] = parse_priv_to_db(
|
||||
data['acl']['deleted'],["a", "r", "w", "x"])
|
||||
data['acl']['deleted'], ["a", "r", "w", "x"])
|
||||
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
@@ -1002,7 +1004,6 @@ AND relkind != 'c'))"""
|
||||
|
||||
return cols
|
||||
|
||||
|
||||
def _fetch_properties(self, gid, sid, did, scid, foid, inherits=False):
|
||||
"""
|
||||
Returns the Foreign Table properties which will be used in
|
||||
@@ -1167,7 +1168,6 @@ AND relkind != 'c'))"""
|
||||
|
||||
return {"ftoptions": variables_lst}
|
||||
|
||||
|
||||
@check_precondition
|
||||
def select_sql(self, gid, sid, did, scid, foid):
|
||||
"""
|
||||
|
||||
@@ -83,6 +83,7 @@ class FtsConfigurationModule(SchemaChildModule):
|
||||
"""
|
||||
return databases.DatabaseModule.NODE_TYPE
|
||||
|
||||
|
||||
blueprint = FtsConfigurationModule(__name__)
|
||||
|
||||
|
||||
@@ -190,9 +191,9 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
'dependent': [{'get': 'dependents'}],
|
||||
'module.js': [{}, {}, {'get': 'module_js'}],
|
||||
'parsers': [{'get': 'parsers'},
|
||||
{'get': 'parsers'}],
|
||||
{'get': 'parsers'}],
|
||||
'copyConfig': [{'get': 'copyConfig'},
|
||||
{'get': 'copyConfig'}],
|
||||
{'get': 'copyConfig'}],
|
||||
'tokens': [{'get': 'tokens'}, {'get': 'tokens'}],
|
||||
'dictionaries': [{}, {'get': 'dictionaries'}],
|
||||
})
|
||||
@@ -255,9 +256,9 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
"""
|
||||
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
scid=scid
|
||||
)
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
scid=scid
|
||||
)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
|
||||
if not status:
|
||||
@@ -354,10 +355,10 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
"""
|
||||
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
scid=scid,
|
||||
cfgid=cfgid
|
||||
)
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
scid=scid,
|
||||
cfgid=cfgid
|
||||
)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
|
||||
if not status:
|
||||
@@ -371,8 +372,8 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
# In edit mode fetch token/dictionary list also
|
||||
if cfgid:
|
||||
sql = render_template("/".join([self.template_path,
|
||||
'tokenDictList.sql']),
|
||||
cfgid=cfgid)
|
||||
'tokenDictList.sql']),
|
||||
cfgid=cfgid)
|
||||
|
||||
status, rset = self.conn.execute_dict(sql)
|
||||
|
||||
@@ -561,7 +562,7 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'get_name.sql']),
|
||||
cfgid=cfgid
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -578,7 +579,7 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
name=result['name'],
|
||||
schema=result['schema'],
|
||||
cascade=cascade
|
||||
)
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_scalar(sql)
|
||||
if not status:
|
||||
@@ -679,7 +680,7 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'schema.sql']),
|
||||
data=old_data
|
||||
)
|
||||
)
|
||||
|
||||
status, old_schema = self.conn.execute_scalar(sql)
|
||||
if not status:
|
||||
@@ -691,14 +692,14 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
data=new_data, o_data=old_data
|
||||
)
|
||||
)
|
||||
# Fetch sql query for modified data
|
||||
else:
|
||||
# Fetch schema name from schema oid
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'schema.sql']),
|
||||
data=data
|
||||
)
|
||||
)
|
||||
|
||||
status, schema = self.conn.execute_scalar(sql)
|
||||
if not status:
|
||||
@@ -709,7 +710,7 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
new_data['schema'] = schema
|
||||
|
||||
if 'name' in new_data and \
|
||||
'schema' in new_data:
|
||||
'schema' in new_data:
|
||||
sql = render_template("/".join([self.template_path,
|
||||
'create.sql']),
|
||||
data=new_data,
|
||||
@@ -737,7 +738,7 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'parser.sql']),
|
||||
parser=True
|
||||
)
|
||||
)
|
||||
status, rset = self.conn.execute_dict(sql)
|
||||
|
||||
if not status:
|
||||
@@ -745,7 +746,7 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
|
||||
# Empty set is added before actual list as initially it will be visible
|
||||
# at parser control while creating a new FTS Configuration
|
||||
res = [{'label':'', 'value':''}]
|
||||
res = [{'label': '', 'value': ''}]
|
||||
for row in rset['rows']:
|
||||
if row['schemaoid'] > datlastsysoid:
|
||||
row['prsname'] = row['nspname'] + '.' + row['prsname']
|
||||
@@ -772,7 +773,7 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'copy_config.sql']),
|
||||
copy_config=True
|
||||
)
|
||||
)
|
||||
status, rset = self.conn.execute_dict(sql)
|
||||
|
||||
if not status:
|
||||
@@ -809,7 +810,7 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'parser.sql']),
|
||||
cfgid=cfgid
|
||||
)
|
||||
)
|
||||
status, parseroid = self.conn.execute_scalar(sql)
|
||||
|
||||
if not status:
|
||||
@@ -818,7 +819,7 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'tokens.sql']),
|
||||
parseroid=parseroid
|
||||
)
|
||||
)
|
||||
status, rset = self.conn.execute_dict(sql)
|
||||
|
||||
for row in rset['rows']:
|
||||
@@ -844,8 +845,8 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
:param scid: schema id
|
||||
"""
|
||||
sql = render_template(
|
||||
"/".join([self.template_path,'dictionaries.sql'])
|
||||
)
|
||||
"/".join([self.template_path, 'dictionaries.sql'])
|
||||
)
|
||||
status, rset = self.conn.execute_dict(sql)
|
||||
|
||||
if not status:
|
||||
@@ -881,7 +882,7 @@ class FtsConfigurationView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_(
|
||||
"ERROR: Couldn't generate reversed engineered query for the FTS Configuration!\n{0}"
|
||||
"ERROR: Couldn't generate reversed engineered query for the FTS Configuration!\n{0}"
|
||||
).format(
|
||||
res
|
||||
)
|
||||
|
||||
@@ -253,7 +253,6 @@ class FtsDictionaryView(PGChildNodeView):
|
||||
options.append({'option': k, 'value': v})
|
||||
return options
|
||||
|
||||
|
||||
@check_precondition
|
||||
def list(self, gid, sid, did, scid):
|
||||
"""
|
||||
@@ -348,11 +347,11 @@ class FtsDictionaryView(PGChildNodeView):
|
||||
for row in rset['rows']:
|
||||
return make_json_response(
|
||||
data=self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
did,
|
||||
row['name'],
|
||||
icon="icon-fts_dictionary"
|
||||
),
|
||||
row['oid'],
|
||||
did,
|
||||
row['name'],
|
||||
icon="icon-fts_dictionary"
|
||||
),
|
||||
status=200
|
||||
)
|
||||
|
||||
@@ -491,7 +490,7 @@ class FtsDictionaryView(PGChildNodeView):
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
dcid=dcid,
|
||||
scid=scid
|
||||
)
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
if not status:
|
||||
@@ -504,12 +503,12 @@ class FtsDictionaryView(PGChildNodeView):
|
||||
|
||||
data = res['rows'][0]
|
||||
return jsonify(
|
||||
node=self.blueprint.generate_browser_node(
|
||||
dcid,
|
||||
did,
|
||||
data['name'],
|
||||
icon="icon-fts_dictionary"
|
||||
)
|
||||
node=self.blueprint.generate_browser_node(
|
||||
dcid,
|
||||
did,
|
||||
data['name'],
|
||||
icon="icon-fts_dictionary"
|
||||
)
|
||||
)
|
||||
# In case FTS Dictionary node is not present
|
||||
else:
|
||||
@@ -555,7 +554,7 @@ class FtsDictionaryView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return gone(_("""
|
||||
return gone(_("""
|
||||
Could not find the FTS Dictionary node to delete.
|
||||
"""))
|
||||
|
||||
@@ -597,7 +596,7 @@ class FtsDictionaryView(PGChildNodeView):
|
||||
:param scid: schema id
|
||||
:param dcid: FTS Dictionary id
|
||||
"""
|
||||
#data = request.args
|
||||
# data = request.args
|
||||
data = {}
|
||||
for k, v in request.args.items():
|
||||
try:
|
||||
@@ -694,8 +693,8 @@ class FtsDictionaryView(PGChildNodeView):
|
||||
new_data['schema'] = schema
|
||||
|
||||
if 'template' in new_data and \
|
||||
'name' in new_data and \
|
||||
'schema' in new_data:
|
||||
'name' in new_data and \
|
||||
'schema' in new_data:
|
||||
sql = render_template("/".join([self.template_path,
|
||||
'create.sql']),
|
||||
data=new_data,
|
||||
@@ -731,7 +730,7 @@ class FtsDictionaryView(PGChildNodeView):
|
||||
# at template control while creating a new FTS Dictionary
|
||||
res = [{'label': '', 'value': ''}]
|
||||
for row in rset['rows']:
|
||||
if row['schemaoid'] > datlastsysoid :
|
||||
if row['schemaoid'] > datlastsysoid:
|
||||
row['tmplname'] = row['nspname'] + '.' + row['tmplname']
|
||||
|
||||
res.append({'label': row['tmplname'],
|
||||
@@ -794,9 +793,9 @@ class FtsDictionaryView(PGChildNodeView):
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, dcid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, dcid):
|
||||
@@ -813,8 +812,9 @@ class FtsDictionaryView(PGChildNodeView):
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, dcid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
FtsDictionaryView.register_node_view(blueprint)
|
||||
|
||||
@@ -238,9 +238,9 @@ class FtsParserView(PGChildNodeView):
|
||||
@check_precondition
|
||||
def list(self, gid, sid, did, scid):
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
scid=scid
|
||||
)
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
scid=scid
|
||||
)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
|
||||
if not status:
|
||||
@@ -255,9 +255,9 @@ class FtsParserView(PGChildNodeView):
|
||||
def nodes(self, gid, sid, did, scid):
|
||||
res = []
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
scid=scid
|
||||
)
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
scid=scid
|
||||
)
|
||||
status, rset = self.conn.execute_2darray(sql)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=rset)
|
||||
@@ -279,9 +279,9 @@ class FtsParserView(PGChildNodeView):
|
||||
@check_precondition
|
||||
def node(self, gid, sid, did, scid, pid):
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
pid=pid
|
||||
)
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
pid=pid
|
||||
)
|
||||
status, rset = self.conn.execute_2darray(sql)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=rset)
|
||||
@@ -294,21 +294,21 @@ class FtsParserView(PGChildNodeView):
|
||||
for row in rset['rows']:
|
||||
return make_json_response(
|
||||
data=self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
did,
|
||||
row['name'],
|
||||
icon="icon-fts_parser"
|
||||
),
|
||||
row['oid'],
|
||||
did,
|
||||
row['name'],
|
||||
icon="icon-fts_parser"
|
||||
),
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, scid, pid):
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
scid=scid,
|
||||
pid=pid
|
||||
)
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
scid=scid,
|
||||
pid=pid
|
||||
)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
|
||||
if not status:
|
||||
@@ -358,10 +358,10 @@ class FtsParserView(PGChildNodeView):
|
||||
try:
|
||||
# Fetch schema name from schema oid
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'schema.sql']),
|
||||
data=data,
|
||||
conn=self.conn,
|
||||
)
|
||||
"/".join([self.template_path, 'schema.sql']),
|
||||
data=data,
|
||||
conn=self.conn,
|
||||
)
|
||||
|
||||
status, schema = self.conn.execute_scalar(sql)
|
||||
if not status:
|
||||
@@ -372,10 +372,10 @@ class FtsParserView(PGChildNodeView):
|
||||
new_data = data.copy()
|
||||
new_data['schema'] = schema
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
data=new_data,
|
||||
conn=self.conn,
|
||||
)
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
data=new_data,
|
||||
conn=self.conn,
|
||||
)
|
||||
status, res = self.conn.execute_scalar(sql)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -424,10 +424,10 @@ class FtsParserView(PGChildNodeView):
|
||||
|
||||
if pid is not None:
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
pid=pid,
|
||||
scid=scid
|
||||
)
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
pid=pid,
|
||||
scid=scid
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
if not status:
|
||||
@@ -440,7 +440,7 @@ class FtsParserView(PGChildNodeView):
|
||||
|
||||
data = res['rows'][0]
|
||||
return jsonify(
|
||||
node=self.blueprint.generate_browser_node(
|
||||
node=self.blueprint.generate_browser_node(
|
||||
pid,
|
||||
did,
|
||||
data['name'],
|
||||
@@ -449,16 +449,16 @@ class FtsParserView(PGChildNodeView):
|
||||
)
|
||||
else:
|
||||
return make_json_response(
|
||||
success=1,
|
||||
info="Nothing to update",
|
||||
data={
|
||||
'id': pid,
|
||||
'scid': scid,
|
||||
'sid': sid,
|
||||
'gid': gid,
|
||||
'did': did
|
||||
}
|
||||
)
|
||||
success=1,
|
||||
info="Nothing to update",
|
||||
data={
|
||||
'id': pid,
|
||||
'scid': scid,
|
||||
'sid': sid,
|
||||
'gid': gid,
|
||||
'did': did
|
||||
}
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def delete(self, gid, sid, did, scid, pid):
|
||||
@@ -480,9 +480,9 @@ class FtsParserView(PGChildNodeView):
|
||||
try:
|
||||
# Get name for Parser from pid
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
pid=pid
|
||||
)
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
pid=pid
|
||||
)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -493,11 +493,11 @@ class FtsParserView(PGChildNodeView):
|
||||
# Drop fts Parser
|
||||
result = res['rows'][0]
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
name=result['name'],
|
||||
schema=result['schema'],
|
||||
cascade=cascade
|
||||
)
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
name=result['name'],
|
||||
schema=result['schema'],
|
||||
cascade=cascade
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_scalar(sql)
|
||||
if not status:
|
||||
@@ -558,10 +558,10 @@ class FtsParserView(PGChildNodeView):
|
||||
# Fetch sql for update
|
||||
if pid is not None:
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
pid=pid,
|
||||
scid=scid
|
||||
)
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
pid=pid,
|
||||
scid=scid
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
if not status:
|
||||
@@ -589,9 +589,9 @@ class FtsParserView(PGChildNodeView):
|
||||
|
||||
# Fetch old schema name using old schema oid
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'schema.sql']),
|
||||
data=old_data
|
||||
)
|
||||
"/".join([self.template_path, 'schema.sql']),
|
||||
data=old_data
|
||||
)
|
||||
|
||||
status, old_schema = self.conn.execute_scalar(sql)
|
||||
if not status:
|
||||
@@ -601,17 +601,17 @@ class FtsParserView(PGChildNodeView):
|
||||
old_data['schema'] = old_schema
|
||||
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
data=new_data,
|
||||
o_data=old_data
|
||||
)
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
data=new_data,
|
||||
o_data=old_data
|
||||
)
|
||||
# Fetch sql query for modified data
|
||||
else:
|
||||
# Fetch schema name from schema oid
|
||||
sql = render_template(
|
||||
"/".join([self.template_path, 'schema.sql']),
|
||||
data=data
|
||||
)
|
||||
"/".join([self.template_path, 'schema.sql']),
|
||||
data=data
|
||||
)
|
||||
|
||||
status, schema = self.conn.execute_scalar(sql)
|
||||
if not status:
|
||||
@@ -622,16 +622,16 @@ class FtsParserView(PGChildNodeView):
|
||||
new_data['schema'] = schema
|
||||
|
||||
if 'prsstart' in new_data and \
|
||||
'prstoken' in new_data and \
|
||||
'prsend' in new_data and \
|
||||
'prslextype' in new_data and \
|
||||
'name' in new_data and \
|
||||
'schema' in new_data:
|
||||
'prstoken' in new_data and \
|
||||
'prsend' in new_data and \
|
||||
'prslextype' in new_data and \
|
||||
'name' in new_data and \
|
||||
'schema' in new_data:
|
||||
sql = render_template(
|
||||
"/".join([self.template_path,'create.sql']),
|
||||
data=new_data,
|
||||
conn=self.conn
|
||||
)
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
data=new_data,
|
||||
conn=self.conn
|
||||
)
|
||||
else:
|
||||
sql = "-- incomplete definition"
|
||||
return str(sql.strip('\n'))
|
||||
@@ -828,9 +828,9 @@ class FtsParserView(PGChildNodeView):
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, pid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, pid):
|
||||
@@ -847,8 +847,9 @@ class FtsParserView(PGChildNodeView):
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, pid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
FtsParserView.register_node_view(blueprint)
|
||||
|
||||
@@ -279,11 +279,11 @@ class FtsTemplateView(PGChildNodeView):
|
||||
for row in rset['rows']:
|
||||
return make_json_response(
|
||||
data=self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
did,
|
||||
row['name'],
|
||||
icon="icon-fts_template"
|
||||
),
|
||||
row['oid'],
|
||||
did,
|
||||
row['name'],
|
||||
icon="icon-fts_template"
|
||||
),
|
||||
status=200
|
||||
)
|
||||
|
||||
@@ -695,9 +695,9 @@ class FtsTemplateView(PGChildNodeView):
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, tid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, tid):
|
||||
@@ -714,8 +714,9 @@ class FtsTemplateView(PGChildNodeView):
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, tid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
FtsTemplateView.register_node_view(blueprint)
|
||||
|
||||
@@ -113,6 +113,7 @@ class FunctionModule(SchemaChildModule):
|
||||
|
||||
return snippets
|
||||
|
||||
|
||||
blueprint = FunctionModule(__name__)
|
||||
|
||||
|
||||
@@ -258,7 +259,7 @@ class FunctionView(PGChildNodeView, DataTypeReader):
|
||||
if 'fnid' not in kwargs:
|
||||
|
||||
for arg in self.required_args:
|
||||
if (arg not in req or req[arg] == '') or\
|
||||
if (arg not in req or req[arg] == '') or \
|
||||
(arg == 'probin' and req['lanname'] == 'c'
|
||||
and (arg not in req or req[arg] == '')):
|
||||
return make_json_response(
|
||||
@@ -281,12 +282,12 @@ class FunctionView(PGChildNodeView, DataTypeReader):
|
||||
# Coverts string into python list as expected.
|
||||
data[key] = json.loads(req[key])
|
||||
elif (
|
||||
key == 'proretset' or key == 'proisstrict' or
|
||||
key == 'prosecdef' or key == 'proiswindow' or
|
||||
key == 'proleakproof'
|
||||
key == 'proretset' or key == 'proisstrict' or
|
||||
key == 'prosecdef' or key == 'proiswindow' or
|
||||
key == 'proleakproof'
|
||||
):
|
||||
data[key] = True if (
|
||||
req[key] == 'true' or req[key] is True)\
|
||||
req[key] == 'true' or req[key] is True) \
|
||||
else False if (req[key] == 'false' or
|
||||
req[key] is False) else ''
|
||||
else:
|
||||
@@ -353,7 +354,7 @@ class FunctionView(PGChildNodeView, DataTypeReader):
|
||||
'9.5_plus' if ver >= 90500 else
|
||||
'9.2_plus' if ver >= 90200 else
|
||||
'9.1_plus'
|
||||
])
|
||||
])
|
||||
|
||||
return f(*args, **kwargs)
|
||||
|
||||
@@ -458,7 +459,7 @@ class FunctionView(PGChildNodeView, DataTypeReader):
|
||||
proargnames: Argument Name
|
||||
proargdefaultvals: Default Value of the Argument
|
||||
"""
|
||||
proargtypes = [ptype for ptype in data['proargtypenames'].split(",")]\
|
||||
proargtypes = [ptype for ptype in data['proargtypenames'].split(",")] \
|
||||
if data['proargtypenames'] else []
|
||||
proargmodes = data['proargmodes'] if data['proargmodes'] else []
|
||||
proargnames = data['proargnames'] if data['proargnames'] else []
|
||||
@@ -544,7 +545,7 @@ class FunctionView(PGChildNodeView, DataTypeReader):
|
||||
proargnames[i] if len(proargnames) > i else '',
|
||||
proargdefaultvals[i] if len(proargdefaultvals) > i else ''
|
||||
)
|
||||
for i in range(len(proargtypes))]
|
||||
for i in range(len(proargtypes))]
|
||||
|
||||
proargs = {"proargs": ", ".join(proargs)}
|
||||
|
||||
@@ -676,7 +677,7 @@ class FunctionView(PGChildNodeView, DataTypeReader):
|
||||
exc_value,
|
||||
exc_traceback,
|
||||
limit=2
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
return internal_server_error(errormsg=str(exc_value))
|
||||
@@ -699,7 +700,7 @@ class FunctionView(PGChildNodeView, DataTypeReader):
|
||||
"""
|
||||
SQL = render_template(
|
||||
"/".join([self.sql_template_path, 'variables.sql'])
|
||||
)
|
||||
)
|
||||
status, rset = self.conn.execute_dict(SQL)
|
||||
|
||||
if not status:
|
||||
@@ -782,7 +783,7 @@ class FunctionView(PGChildNodeView, DataTypeReader):
|
||||
try:
|
||||
# Fetch Name and Schema Name to delete the Function.
|
||||
SQL = render_template("/".join([self.sql_template_path,
|
||||
'delete.sql']), scid=scid, fnid=fnid)
|
||||
'delete.sql']), scid=scid, fnid=fnid)
|
||||
status, res = self.conn.execute_2darray(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -904,7 +905,7 @@ class FunctionView(PGChildNodeView, DataTypeReader):
|
||||
object_type = 'function'
|
||||
# Fetch the function definition.
|
||||
SQL = render_template("/".join([self.sql_template_path,
|
||||
'get_definition.sql']), fnid=fnid, scid=scid)
|
||||
'get_definition.sql']), fnid=fnid, scid=scid)
|
||||
status, res = self.conn.execute_2darray(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -969,7 +970,7 @@ class FunctionView(PGChildNodeView, DataTypeReader):
|
||||
# Get Schema Name from its OID.
|
||||
if 'pronamespace' in data:
|
||||
data['pronamespace'] = self._get_schema(data[
|
||||
'pronamespace'])
|
||||
'pronamespace'])
|
||||
if 'provolatile' in data:
|
||||
data['provolatile'] = vol_dict[data['provolatile']]
|
||||
|
||||
@@ -981,7 +982,7 @@ class FunctionView(PGChildNodeView, DataTypeReader):
|
||||
|
||||
# Get Schema Name
|
||||
old_data['pronamespace'] = self._get_schema(old_data[
|
||||
'pronamespace'])
|
||||
'pronamespace'])
|
||||
|
||||
if 'provolatile' in old_data:
|
||||
old_data['provolatile'] = vol_dict[old_data['provolatile']]
|
||||
@@ -1085,11 +1086,11 @@ class FunctionView(PGChildNodeView, DataTypeReader):
|
||||
if 'arguments' in data:
|
||||
for a in data['arguments']:
|
||||
if (('argmode' in a and a['argmode'] != 'OUT' and
|
||||
a['argmode'] is not None
|
||||
a['argmode'] is not None
|
||||
) or 'argnode' not in a):
|
||||
if 'argmode' in a:
|
||||
args += a['argmode'] + " "
|
||||
if 'argname' in a and a['argname'] != ''\
|
||||
if 'argname' in a and a['argname'] != '' \
|
||||
and a['argname'] is not None:
|
||||
args += self.qtIdent(
|
||||
self.conn, a['argname']) + " "
|
||||
@@ -1177,7 +1178,7 @@ It may have been removed by another user or moved to another schema.
|
||||
scid: Schema Id
|
||||
"""
|
||||
SQL = render_template("/".join([self.sql_template_path,
|
||||
'get_schema.sql']), scid=scid)
|
||||
'get_schema.sql']), scid=scid)
|
||||
|
||||
status, schema_name = self.conn.execute_scalar(SQL)
|
||||
|
||||
@@ -1238,7 +1239,7 @@ It may have been removed by another user or moved to another schema.
|
||||
"""
|
||||
# Fetch the function definition.
|
||||
SQL = render_template("/".join([self.sql_template_path,
|
||||
'get_definition.sql']), fnid=fnid, scid=scid)
|
||||
'get_definition.sql']), fnid=fnid, scid=scid)
|
||||
status, res = self.conn.execute_2darray(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -1334,16 +1335,16 @@ It may have been removed by another user or moved to another schema.
|
||||
"/".join([self.sql_template_path, sql]),
|
||||
conn=self.conn, fnid=fnid,
|
||||
scid=scid, schema_name=schema_name
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
FunctionView.register_node_view(blueprint)
|
||||
@@ -1416,7 +1417,6 @@ procedure_blueprint = ProcedureModule(__name__)
|
||||
|
||||
|
||||
class ProcedureView(FunctionView):
|
||||
|
||||
node_type = procedure_blueprint.node_type
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -1457,6 +1457,7 @@ class ProcedureView(FunctionView):
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
|
||||
ProcedureView.register_node_view(procedure_blueprint)
|
||||
|
||||
|
||||
@@ -1526,7 +1527,6 @@ trigger_function_blueprint = TriggerFunctionModule(__name__)
|
||||
|
||||
|
||||
class TriggerFunctionView(FunctionView):
|
||||
|
||||
node_type = trigger_function_blueprint.node_type
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -1567,4 +1567,5 @@ class TriggerFunctionView(FunctionView):
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
|
||||
TriggerFunctionView.register_node_view(trigger_function_blueprint)
|
||||
|
||||
@@ -82,6 +82,7 @@ class SequenceModule(SchemaChildModule):
|
||||
"""
|
||||
return False
|
||||
|
||||
|
||||
blueprint = SequenceModule(__name__)
|
||||
|
||||
|
||||
@@ -89,14 +90,14 @@ class SequenceView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'seid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'seid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -119,12 +120,12 @@ class SequenceView(PGChildNodeView):
|
||||
This property defines whether javascript exists for this node.
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"sequence/js/sequence.js",
|
||||
_=_
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"sequence/js/sequence.js",
|
||||
_=_
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def check_precondition(action=None):
|
||||
"""
|
||||
@@ -132,6 +133,7 @@ class SequenceView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
def wrap(f):
|
||||
@wraps(f)
|
||||
def wrapped(self, *args, **kwargs):
|
||||
@@ -147,14 +149,16 @@ class SequenceView(PGChildNodeView):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
_(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
self.template_path = 'sequence/sql/9.1_plus'
|
||||
self.acl = ['r', 'w', 'U']
|
||||
return f(self, *args, **kwargs)
|
||||
|
||||
return wrapped
|
||||
|
||||
return wrap
|
||||
|
||||
@check_precondition(action='list')
|
||||
@@ -177,9 +181,9 @@ class SequenceView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition(action='nodes')
|
||||
def nodes(self, gid, sid, did, scid):
|
||||
@@ -204,17 +208,17 @@ class SequenceView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
sid,
|
||||
row['name'],
|
||||
icon="icon-%s" % self.node_type
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
sid,
|
||||
row['name'],
|
||||
icon="icon-%s" % self.node_type
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition(action='properties')
|
||||
def properties(self, gid, sid, did, scid, seid):
|
||||
@@ -244,7 +248,7 @@ class SequenceView(PGChildNodeView):
|
||||
sec_lbls.append({
|
||||
'provider': sec.group(1),
|
||||
'label': sec.group(2)
|
||||
})
|
||||
})
|
||||
res['securities'] = sec_lbls
|
||||
|
||||
for row in res['rows']:
|
||||
@@ -273,9 +277,9 @@ class SequenceView(PGChildNodeView):
|
||||
res['rows'][0][row['deftype']] = [priv]
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition(action="create")
|
||||
def create(self, gid, sid, did, scid):
|
||||
@@ -340,8 +344,8 @@ class SequenceView(PGChildNodeView):
|
||||
scid,
|
||||
data['name'],
|
||||
icon="icon-%s" % self.node_type
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return make_json_response(
|
||||
@@ -488,14 +492,14 @@ class SequenceView(PGChildNodeView):
|
||||
SQL = self.getSQL(gid, sid, did, data, scid, seid)
|
||||
SQL = SQL.strip('\n').strip(' ')
|
||||
return make_json_response(
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return make_json_response(
|
||||
data="-- modified SQL",
|
||||
status=200
|
||||
)
|
||||
data="-- modified SQL",
|
||||
status=200
|
||||
)
|
||||
|
||||
def getSQL(self, gid, sid, did, data, scid, seid=None):
|
||||
"""
|
||||
@@ -526,11 +530,11 @@ class SequenceView(PGChildNodeView):
|
||||
for key in ['relacl']:
|
||||
if key in data and data[key] is not None:
|
||||
if 'added' in data[key]:
|
||||
data[key]['added'] = parse_priv_to_db(data[key]['added'], self.acl)
|
||||
data[key]['added'] = parse_priv_to_db(data[key]['added'], self.acl)
|
||||
if 'changed' in data[key]:
|
||||
data[key]['changed'] = parse_priv_to_db(data[key]['changed'], self.acl)
|
||||
data[key]['changed'] = parse_priv_to_db(data[key]['changed'], self.acl)
|
||||
if 'deleted' in data[key]:
|
||||
data[key]['deleted'] = parse_priv_to_db(data[key]['deleted'], self.acl)
|
||||
data[key]['deleted'] = parse_priv_to_db(data[key]['deleted'], self.acl)
|
||||
|
||||
# If name is not present with in update data then copy it
|
||||
# from old data
|
||||
@@ -637,9 +641,9 @@ class SequenceView(PGChildNodeView):
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, seid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition(action="dependencies")
|
||||
def dependencies(self, gid, sid, did, scid, seid):
|
||||
@@ -686,9 +690,9 @@ class SequenceView(PGChildNodeView):
|
||||
'field': dep_type})
|
||||
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition(action="stats")
|
||||
def statistics(self, gid, sid, did, scid, seid=None):
|
||||
@@ -724,15 +728,16 @@ class SequenceView(PGChildNodeView):
|
||||
"/".join([self.template_path, sql]),
|
||||
conn=self.conn, seid=seid,
|
||||
schema_name=schema_name
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
SequenceView.register_node_view(blueprint)
|
||||
|
||||
@@ -216,14 +216,14 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -266,6 +266,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -281,7 +282,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -353,9 +354,9 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did, scid):
|
||||
@@ -381,19 +382,19 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
scid,
|
||||
row['name'],
|
||||
icon="icon-table",
|
||||
tigger_count=row['triggercount'],
|
||||
has_enable_triggers=row['has_enable_triggers']
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
scid,
|
||||
row['name'],
|
||||
icon="icon-table",
|
||||
tigger_count=row['triggercount'],
|
||||
has_enable_triggers=row['has_enable_triggers']
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def get_all_tables(self, gid, sid, did, scid, tid=None):
|
||||
@@ -440,7 +441,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def get_toast_table_vacuum(self, gid, sid, did, scid=None, tid=None):
|
||||
@@ -456,7 +457,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def get_access_methods(self, gid, sid, did, scid, tid=None):
|
||||
@@ -488,9 +489,9 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
{'label': row['amname'], 'value': row['amname']}
|
||||
)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def get_oper_class(self, gid, sid, did, scid, tid=None):
|
||||
@@ -525,7 +526,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
return make_json_response(
|
||||
data=result,
|
||||
status=200
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -563,7 +564,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
return make_json_response(
|
||||
data=result,
|
||||
status=200
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -598,7 +599,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
column['seclabels'] = seclabels
|
||||
|
||||
if 'attnum' in column and column['attnum'] is not None and \
|
||||
column['attnum'] > 0:
|
||||
column['attnum'] > 0:
|
||||
# We need to parse & convert ACL coming from database to json format
|
||||
SQL = render_template("/".join([self.column_template_path, 'acl.sql']),
|
||||
tid=tid, clid=column['attnum'])
|
||||
@@ -737,7 +738,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
|
||||
columns = []
|
||||
for r in res['rows']:
|
||||
columns.append({"column": r['column'].strip('"')})
|
||||
columns.append({"column": r['column'].strip('"')})
|
||||
|
||||
result['columns'] = columns
|
||||
|
||||
@@ -761,7 +762,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
# We will fetch all the index constraints for the table
|
||||
sql = render_template("/".join([self.foreign_key_template_path,
|
||||
'properties.sql']),
|
||||
tid=tid)
|
||||
tid=tid)
|
||||
|
||||
status, result = self.conn.execute_dict(sql)
|
||||
|
||||
@@ -771,10 +772,10 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
for fk in result['rows']:
|
||||
|
||||
sql = render_template("/".join([self.foreign_key_template_path,
|
||||
'get_constraint_cols.sql']),
|
||||
tid=tid,
|
||||
keys=zip(fk['confkey'], fk['conkey']),
|
||||
confrelid=fk['confrelid'])
|
||||
'get_constraint_cols.sql']),
|
||||
tid=tid,
|
||||
keys=zip(fk['confkey'], fk['conkey']),
|
||||
confrelid=fk['confrelid'])
|
||||
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
|
||||
@@ -1039,7 +1040,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
|
||||
# Filter inherited columns from all columns
|
||||
if 'columns' in data and len(data['columns']) > 0 \
|
||||
and len(all_columns) > 0:
|
||||
and len(all_columns) > 0:
|
||||
columns = []
|
||||
for row in data['columns']:
|
||||
for i, col in enumerate(all_columns):
|
||||
@@ -1102,10 +1103,10 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
|
||||
if data['toast_table_vacuum_settings_str'] is not None:
|
||||
data['vacuum_settings_str'] += '\n' + '\n'.join(
|
||||
['toast_' + setting for setting in data[
|
||||
'toast_table_vacuum_settings_str'
|
||||
].split(',')]
|
||||
)
|
||||
['toast_' + setting for setting in data[
|
||||
'toast_table_vacuum_settings_str'
|
||||
].split(',')]
|
||||
)
|
||||
data['vacuum_settings_str'] = data[
|
||||
'vacuum_settings_str'
|
||||
].replace("=", " = ")
|
||||
@@ -1113,9 +1114,9 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
data = self._formatter(scid, tid, data)
|
||||
|
||||
return ajax_response(
|
||||
response=data,
|
||||
status=200
|
||||
)
|
||||
response=data,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def types(self, gid, sid, did, scid, tid=None, clid=None):
|
||||
@@ -1199,14 +1200,14 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
return internal_server_error(errormsg=res)
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
{'label': row['typname'], 'value': row['typname'],
|
||||
'tid': row['oid']
|
||||
}
|
||||
)
|
||||
{'label': row['typname'], 'value': row['typname'],
|
||||
'tid': row['oid']
|
||||
}
|
||||
)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -1228,14 +1229,14 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
return internal_server_error(errormsg=res)
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
{'label': row['inherits'], 'value': row['inherits'],
|
||||
'tid': row['oid']
|
||||
}
|
||||
)
|
||||
{'label': row['inherits'], 'value': row['inherits'],
|
||||
'tid': row['oid']
|
||||
}
|
||||
)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -1256,12 +1257,12 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
return internal_server_error(errormsg=res)
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
{'label': row['like_relation'], 'value': row['like_relation']}
|
||||
)
|
||||
{'label': row['like_relation'], 'value': row['like_relation']}
|
||||
)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -1707,8 +1708,8 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
# Sql for drop
|
||||
sql.append(
|
||||
render_template("/".join(
|
||||
[self.index_constraint_template_path,
|
||||
'delete.sql']),
|
||||
[self.index_constraint_template_path,
|
||||
'delete.sql']),
|
||||
data=c, conn=self.conn).strip('\n')
|
||||
)
|
||||
|
||||
@@ -1747,7 +1748,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
data=c, conn=self.conn,
|
||||
constraint_name='PRIMARY KEY'
|
||||
if ctype == 'p' else 'UNIQUE'
|
||||
).strip('\n')
|
||||
).strip('\n')
|
||||
)
|
||||
else:
|
||||
sql.append(
|
||||
@@ -1784,8 +1785,8 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
# Sql for drop
|
||||
sql.append(
|
||||
render_template("/".join(
|
||||
[self.foreign_key_template_path,
|
||||
'delete.sql']),
|
||||
[self.foreign_key_template_path,
|
||||
'delete.sql']),
|
||||
data=c, conn=self.conn).strip('\n')
|
||||
)
|
||||
|
||||
@@ -1824,13 +1825,13 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
|
||||
coveringindex = self.search_coveringindex(tid, cols)
|
||||
|
||||
if coveringindex is None and 'autoindex' in c and c['autoindex'] and\
|
||||
('coveringindex' in c and
|
||||
c['coveringindex'] != ''):
|
||||
if coveringindex is None and 'autoindex' in c and c['autoindex'] and \
|
||||
('coveringindex' in c and
|
||||
c['coveringindex'] != ''):
|
||||
sql.append(render_template(
|
||||
"/".join([self.foreign_key_template_path, 'create_index.sql']),
|
||||
data=c, conn=self.conn).strip('\n')
|
||||
)
|
||||
)
|
||||
|
||||
if 'added' in constraint:
|
||||
for c in constraint['added']:
|
||||
@@ -1863,7 +1864,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
"/".join([self.foreign_key_template_path,
|
||||
'create.sql']),
|
||||
data=c, conn=self.conn
|
||||
).strip('\n')
|
||||
).strip('\n')
|
||||
)
|
||||
|
||||
if c['autoindex']:
|
||||
@@ -1947,7 +1948,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
"/".join([self.check_constraint_template_path,
|
||||
'create.sql']),
|
||||
data=c, conn=self.conn
|
||||
).strip('\n')
|
||||
).strip('\n')
|
||||
)
|
||||
|
||||
if len(sql) > 0:
|
||||
@@ -2023,7 +2024,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
"/".join([self.exclusion_constraint_template_path,
|
||||
'create.sql']),
|
||||
data=c, conn=self.conn
|
||||
).strip('\n')
|
||||
).strip('\n')
|
||||
)
|
||||
|
||||
if len(sql) > 0:
|
||||
@@ -2127,11 +2128,11 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
self.column_acl)
|
||||
|
||||
properties_sql = render_template("/".join([self.column_template_path,
|
||||
'properties.sql']),
|
||||
tid=tid,
|
||||
clid=c['attnum'],
|
||||
show_sys_objects=self.blueprint.show_system_objects
|
||||
)
|
||||
'properties.sql']),
|
||||
tid=tid,
|
||||
clid=c['attnum'],
|
||||
show_sys_objects=self.blueprint.show_system_objects
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_dict(properties_sql)
|
||||
if not status:
|
||||
@@ -2249,7 +2250,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
return False
|
||||
|
||||
if data['autoindex'] and ('coveringindex' not in data or
|
||||
data['coveringindex'] == ''):
|
||||
data['coveringindex'] == ''):
|
||||
return False
|
||||
|
||||
return True
|
||||
@@ -2310,9 +2311,9 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
dependents_result.append({'type': 'sequence', 'name': ref_name, 'field': dep_type})
|
||||
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, tid):
|
||||
@@ -2333,9 +2334,9 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
)
|
||||
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def sql(self, gid, sid, did, scid, tid):
|
||||
@@ -2576,7 +2577,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
"""
|
||||
|
||||
SQL = render_template("/".join(
|
||||
[self.rules_template_path, 'properties.sql']), tid=tid)
|
||||
[self.rules_template_path, 'properties.sql']), tid=tid)
|
||||
|
||||
status, rset = self.conn.execute_2darray(SQL)
|
||||
if not status:
|
||||
@@ -2586,7 +2587,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
rules_sql = '\n'
|
||||
SQL = render_template("/".join(
|
||||
[self.rules_template_path, 'properties.sql']
|
||||
), rid=row['oid'], datlastsysoid=self.datlastsysoid)
|
||||
), rid=row['oid'], datlastsysoid=self.datlastsysoid)
|
||||
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
@@ -2798,8 +2799,8 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
render_template(
|
||||
"/".join([self.template_path, 'get_schema.sql']),
|
||||
conn=self.conn, scid=scid
|
||||
)
|
||||
)
|
||||
)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=schema_name)
|
||||
|
||||
@@ -2808,8 +2809,8 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
render_template(
|
||||
"/".join([self.template_path, 'coll_table_stats.sql']),
|
||||
conn=self.conn, schema_name=schema_name
|
||||
)
|
||||
)
|
||||
)
|
||||
else:
|
||||
# For Individual table stats
|
||||
|
||||
@@ -2828,8 +2829,8 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
render_template(
|
||||
"/".join([self.template_path, 'get_table.sql']),
|
||||
conn=self.conn, scid=scid, tid=tid
|
||||
)
|
||||
)
|
||||
)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=table_name)
|
||||
|
||||
@@ -2839,15 +2840,16 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
|
||||
conn=self.conn, schema_name=schema_name,
|
||||
table_name=table_name,
|
||||
is_pgstattuple=is_pgstattuple, tid=tid
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
TableView.register_node_view(blueprint)
|
||||
|
||||
@@ -70,7 +70,7 @@ class ColumnsModule(CollectionNodeModule):
|
||||
"""
|
||||
Generate the collection node
|
||||
"""
|
||||
assert('tid' in kwargs or 'vid' in kwargs)
|
||||
assert ('tid' in kwargs or 'vid' in kwargs)
|
||||
yield self.generate_browser_collection_node(
|
||||
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']
|
||||
)
|
||||
@@ -155,17 +155,17 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
ids = [
|
||||
# Here we specify type as any because table
|
||||
# are also has '-' in them if they are system table
|
||||
{'type': 'string', 'id': 'clid'}
|
||||
]
|
||||
# Here we specify type as any because table
|
||||
# are also has '-' in them if they are system table
|
||||
{'type': 'string', 'id': 'clid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -188,6 +188,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -202,7 +203,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -255,9 +256,9 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did, scid, tid):
|
||||
@@ -291,12 +292,12 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
row['name'],
|
||||
icon="icon-column",
|
||||
datatype=row['datatype'] # We need datatype somewhere in
|
||||
)) # exclusion constraint.
|
||||
)) # exclusion constraint.
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
def _formatter(self, scid, tid, clid, data):
|
||||
"""
|
||||
@@ -468,9 +469,9 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
data = self._formatter(scid, tid, clid, data)
|
||||
|
||||
return ajax_response(
|
||||
response=data,
|
||||
status=200
|
||||
)
|
||||
response=data,
|
||||
status=200
|
||||
)
|
||||
|
||||
def _cltype_formatter(self, type):
|
||||
"""
|
||||
@@ -671,7 +672,6 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
|
||||
@check_precondition
|
||||
def msql(self, gid, sid, did, scid, tid, clid=None):
|
||||
"""
|
||||
@@ -706,9 +706,9 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
|
||||
if SQL and SQL.strip('\n') and SQL.strip(' '):
|
||||
return make_json_response(
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -739,21 +739,21 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
if key in data and data[key] is not None:
|
||||
if 'added' in data[key]:
|
||||
data[key]['added'] = parse_priv_to_db(
|
||||
data[key]['added'], self.acl
|
||||
data[key]['added'], self.acl
|
||||
)
|
||||
if 'changed' in data[key]:
|
||||
data[key]['changed'] = parse_priv_to_db(
|
||||
data[key]['changed'], self.acl
|
||||
data[key]['changed'], self.acl
|
||||
)
|
||||
if 'deleted' in data[key]:
|
||||
data[key]['deleted'] = parse_priv_to_db(
|
||||
data[key]['deleted'], self.acl
|
||||
data[key]['deleted'], self.acl
|
||||
)
|
||||
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
data=data, o_data=old_data, conn=self.conn
|
||||
)
|
||||
)
|
||||
else:
|
||||
required_args = [
|
||||
'name',
|
||||
@@ -875,9 +875,9 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
dependents_result.append({'type': 'sequence', 'name': ref_name, 'field': dep_type})
|
||||
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, tid, clid):
|
||||
@@ -900,9 +900,9 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
)
|
||||
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def statistics(self, gid, sid, did, scid, tid, clid):
|
||||
@@ -935,16 +935,16 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
|
||||
"/".join([self.template_path, 'stats.sql']),
|
||||
conn=self.conn, schema=self.schema,
|
||||
table=self.table, column=column
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
ColumnsView.register_node_view(blueprint)
|
||||
|
||||
@@ -14,7 +14,7 @@ from flask import render_template, make_response
|
||||
from flask.ext.babel import gettext
|
||||
from pgadmin.browser.collection import CollectionNodeModule
|
||||
from pgadmin.utils.ajax import make_json_response, \
|
||||
make_response as ajax_response
|
||||
make_response as ajax_response
|
||||
|
||||
from .type import ConstraintRegistry
|
||||
|
||||
@@ -63,6 +63,7 @@ class ConstraintsModule(CollectionNodeModule):
|
||||
"""
|
||||
return database.DatabaseModule.NODE_TYPE
|
||||
|
||||
|
||||
blueprint = ConstraintsModule(__name__)
|
||||
|
||||
|
||||
@@ -86,9 +87,9 @@ def nodes(**kwargs):
|
||||
res = res + view.get_nodes(**kwargs)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route('/obj/<int:gid>/<int:sid>/<int:did>/<int:scid>/<int:tid>/')
|
||||
@@ -110,9 +111,9 @@ def proplist(**kwargs):
|
||||
res = res + view.get_node_list(**kwargs)
|
||||
|
||||
return ajax_response(
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route('/module.js')
|
||||
@@ -122,13 +123,13 @@ def module_js():
|
||||
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"constraints/js/constraints.js",
|
||||
_=gettext,
|
||||
constraints=[
|
||||
(ConstraintRegistry.registry[n])['blueprint'].NODE_TYPE \
|
||||
for n in ConstraintRegistry.registry
|
||||
]
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"constraints/js/constraints.js",
|
||||
_=gettext,
|
||||
constraints=[
|
||||
(ConstraintRegistry.registry[n])['blueprint'].NODE_TYPE \
|
||||
for n in ConstraintRegistry.registry
|
||||
]
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
@@ -83,11 +83,11 @@ class CheckConstraintModule(CollectionNodeModule):
|
||||
Returns a snippet of css to include in the page
|
||||
"""
|
||||
return [
|
||||
render_template(
|
||||
"check_constraint/css/check_constraint.css",
|
||||
node_type=self.node_type
|
||||
)
|
||||
]
|
||||
render_template(
|
||||
"check_constraint/css/check_constraint.css",
|
||||
node_type=self.node_type
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
blueprint = CheckConstraintModule(__name__)
|
||||
@@ -199,6 +199,7 @@ class CheckConstraintView(PGChildNodeView):
|
||||
Checks database connection status.
|
||||
Attach connection object and template path.
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
self = args[0]
|
||||
@@ -260,9 +261,9 @@ class CheckConstraintView(PGChildNodeView):
|
||||
try:
|
||||
res = self.get_node_list(gid, sid, did, scid, tid, cid)
|
||||
return ajax_response(
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -305,9 +306,9 @@ class CheckConstraintView(PGChildNodeView):
|
||||
try:
|
||||
res = self.get_nodes(gid, sid, did, scid, tid, cid)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -341,13 +342,13 @@ class CheckConstraintView(PGChildNodeView):
|
||||
icon = "icon-check_constraints"
|
||||
valid = True
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
tid,
|
||||
row['name'],
|
||||
icon=icon,
|
||||
valid=valid
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
tid,
|
||||
row['name'],
|
||||
icon=icon,
|
||||
valid=valid
|
||||
))
|
||||
return res
|
||||
|
||||
@check_precondition
|
||||
@@ -428,7 +429,7 @@ class CheckConstraintView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
data=data
|
||||
)
|
||||
)
|
||||
|
||||
status, msg = self.conn.execute_scalar(SQL)
|
||||
if not status:
|
||||
@@ -474,8 +475,8 @@ class CheckConstraintView(PGChildNodeView):
|
||||
data['name'],
|
||||
icon=icon,
|
||||
valid=valid
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
self.end_transaction()
|
||||
@@ -633,8 +634,8 @@ class CheckConstraintView(PGChildNodeView):
|
||||
sql_header = "-- Constraint: {0}\n\n-- ".format(data['name'])
|
||||
|
||||
sql_header += render_template(
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
data=data)
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
data=data)
|
||||
sql_header += "\n"
|
||||
|
||||
SQL = sql_header + SQL
|
||||
@@ -671,9 +672,9 @@ class CheckConstraintView(PGChildNodeView):
|
||||
sql = sql.strip('\n').strip(' ')
|
||||
|
||||
return make_json_response(
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -709,7 +710,7 @@ class CheckConstraintView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
data=data, o_data=old_data, conn=self.conn
|
||||
)
|
||||
)
|
||||
else:
|
||||
required_args = ['consrc']
|
||||
|
||||
@@ -743,9 +744,9 @@ class CheckConstraintView(PGChildNodeView):
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, cid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, tid, cid):
|
||||
@@ -763,9 +764,9 @@ class CheckConstraintView(PGChildNodeView):
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, cid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def validate_check_constraint(self, gid, sid, did, scid, tid, cid):
|
||||
@@ -811,7 +812,8 @@ class CheckConstraintView(PGChildNodeView):
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
|
||||
constraint = ConstraintRegistry(
|
||||
'check_constraint', CheckConstraintModule, CheckConstraintView
|
||||
)
|
||||
)
|
||||
CheckConstraintView.register_node_view(blueprint)
|
||||
|
||||
@@ -91,6 +91,7 @@ class ExclusionConstraintModule(ConstraintTypeModule):
|
||||
"""
|
||||
return database.DatabaseModule.NODE_TYPE
|
||||
|
||||
|
||||
blueprint = ExclusionConstraintModule(__name__)
|
||||
|
||||
|
||||
@@ -163,14 +164,14 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
node_type = 'exclusion_constraint'
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
ids = [{'type': 'int', 'id': 'exid'}
|
||||
]
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -192,12 +193,12 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
Override this property for your own logic.
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"exclusion_constraint/js/exclusion_constraint.js",
|
||||
_=_
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"exclusion_constraint/js/exclusion_constraint.js",
|
||||
_=_
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def check_precondition(f):
|
||||
"""
|
||||
@@ -205,20 +206,21 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
self = args[0]
|
||||
self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(
|
||||
kwargs['sid']
|
||||
)
|
||||
)
|
||||
self.conn = self.manager.connection(did=kwargs['did'])
|
||||
|
||||
# If DB not connected then return error to browser
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
_(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -246,7 +248,7 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
|
||||
def end_transaction(self):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'end.sql']))
|
||||
"/".join([self.template_path, 'end.sql']))
|
||||
# End transaction if any.
|
||||
self.conn.execute_scalar(SQL)
|
||||
|
||||
@@ -307,9 +309,9 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
result['columns'] = columns
|
||||
|
||||
return ajax_response(
|
||||
response=result,
|
||||
status=200
|
||||
)
|
||||
response=result,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -333,9 +335,9 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
try:
|
||||
res = self.get_node_list(gid, sid, did, scid, tid, exid)
|
||||
return ajax_response(
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -358,7 +360,7 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
"""
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
'properties.sql']),
|
||||
tid=tid)
|
||||
tid=tid)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
return res['rows']
|
||||
@@ -383,9 +385,9 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
try:
|
||||
res = self.get_nodes(gid, sid, did, scid, tid, exid)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -413,12 +415,12 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
tid,
|
||||
row['name'],
|
||||
icon="icon-exclusion_constraint"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
tid,
|
||||
row['name'],
|
||||
icon="icon-exclusion_constraint"
|
||||
))
|
||||
return res
|
||||
|
||||
@check_precondition
|
||||
@@ -450,20 +452,20 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
for arg in required_args:
|
||||
if arg not in data:
|
||||
return make_json_response(
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=_(
|
||||
"Couldn't find required parameter (%s)." % str(arg)
|
||||
)
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=_(
|
||||
"Couldn't find required parameter (%s)." % str(arg)
|
||||
)
|
||||
)
|
||||
elif isinstance(data[arg], list) and len(data[arg]) < 1:
|
||||
return make_json_response(
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=_(
|
||||
"Couldn't find required parameter (%s)." % str(arg)
|
||||
)
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=_(
|
||||
"Couldn't find required parameter (%s)." % str(arg)
|
||||
)
|
||||
)
|
||||
|
||||
data['schema'] = self.schema
|
||||
data['table'] = self.table
|
||||
@@ -481,7 +483,7 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
data=data, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_scalar(SQL)
|
||||
if not status:
|
||||
self.end_transaction()
|
||||
@@ -515,8 +517,8 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
tid,
|
||||
data['name'],
|
||||
icon="icon-exclusion_constraint"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
self.end_transaction()
|
||||
@@ -675,9 +677,9 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
sql = sql.strip('\n').strip(' ')
|
||||
|
||||
return make_json_response(
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -789,8 +791,8 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
sql_header = "-- Constraint: {0}\n\n-- ".format(data['name'])
|
||||
|
||||
sql_header += render_template(
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
data=data)
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
data=data)
|
||||
sql_header += "\n"
|
||||
|
||||
SQL = sql_header + SQL
|
||||
@@ -845,18 +847,18 @@ class ExclusionConstraintView(PGChildNodeView):
|
||||
"/".join([self.template_path, 'stats.sql']),
|
||||
conn=self.conn, schema=self.schema,
|
||||
name=name, exid=exid, is_pgstattuple=is_pgstattuple
|
||||
)
|
||||
)
|
||||
)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
constraint = ConstraintRegistry(
|
||||
'exclusion_constraint', ExclusionConstraintModule, ExclusionConstraintView
|
||||
)
|
||||
)
|
||||
ExclusionConstraintView.register_node_view(blueprint)
|
||||
|
||||
@@ -97,23 +97,24 @@ class ForeignKeyConstraintModule(ConstraintTypeModule):
|
||||
Returns a snippet of css to include in the page
|
||||
"""
|
||||
snippets = [
|
||||
render_template(
|
||||
"browser/css/collection.css",
|
||||
node_type=self.node_type,
|
||||
_=_
|
||||
),
|
||||
render_template(
|
||||
"foreign_key/css/foreign_key.css",
|
||||
node_type=self.node_type,
|
||||
_=_
|
||||
)
|
||||
]
|
||||
render_template(
|
||||
"browser/css/collection.css",
|
||||
node_type=self.node_type,
|
||||
_=_
|
||||
),
|
||||
render_template(
|
||||
"foreign_key/css/foreign_key.css",
|
||||
node_type=self.node_type,
|
||||
_=_
|
||||
)
|
||||
]
|
||||
|
||||
for submodule in self.submodules:
|
||||
snippets.extend(submodule.csssnippets)
|
||||
|
||||
return snippets
|
||||
|
||||
|
||||
blueprint = ForeignKeyConstraintModule(__name__)
|
||||
|
||||
|
||||
@@ -177,14 +178,14 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
node_type = 'foreign_key'
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
ids = [{'type': 'int', 'id': 'fkid'}
|
||||
]
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -211,12 +212,12 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
Override this property for your own logic.
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"foreign_key/js/foreign_key.js",
|
||||
_=_
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"foreign_key/js/foreign_key.js",
|
||||
_=_
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def check_precondition(f):
|
||||
"""
|
||||
@@ -224,20 +225,21 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
self = args[0]
|
||||
self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(
|
||||
kwargs['sid']
|
||||
)
|
||||
)
|
||||
self.conn = self.manager.connection(did=kwargs['did'])
|
||||
|
||||
# If DB not connected then return error to browser
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
_(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -259,7 +261,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
|
||||
def end_transaction(self):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'end.sql']))
|
||||
"/".join([self.template_path, 'end.sql']))
|
||||
# End transaction if any.
|
||||
self.conn.execute_scalar(SQL)
|
||||
|
||||
@@ -323,9 +325,9 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
result['hasindex'] = False
|
||||
|
||||
return ajax_response(
|
||||
response=result,
|
||||
status=200
|
||||
)
|
||||
response=result,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -349,9 +351,9 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
try:
|
||||
res = self.get_node_list(gid, sid, did, scid, tid, fkid)
|
||||
return ajax_response(
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -374,7 +376,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
"""
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
'properties.sql']),
|
||||
tid=tid)
|
||||
tid=tid)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
return res['rows']
|
||||
@@ -399,9 +401,9 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
try:
|
||||
res = self.get_nodes(gid, sid, did, scid, tid, fkid)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -435,13 +437,13 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
icon = "icon-foreign_key"
|
||||
valid = True
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
tid,
|
||||
row['name'],
|
||||
icon=icon,
|
||||
valid=valid
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
tid,
|
||||
row['name'],
|
||||
icon=icon,
|
||||
valid=valid
|
||||
))
|
||||
return res
|
||||
|
||||
@check_precondition
|
||||
@@ -473,20 +475,20 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
for arg in required_args:
|
||||
if arg not in data:
|
||||
return make_json_response(
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=_(
|
||||
"Couldn't find required parameter (%s)." % str(arg)
|
||||
)
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=_(
|
||||
"Couldn't find required parameter (%s)." % str(arg)
|
||||
)
|
||||
)
|
||||
elif isinstance(data[arg], list) and len(data[arg]) < 1:
|
||||
return make_json_response(
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=_(
|
||||
"Couldn't find required parameter (%s)." % str(arg)
|
||||
)
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=_(
|
||||
"Couldn't find required parameter (%s)." % str(arg)
|
||||
)
|
||||
)
|
||||
|
||||
data['schema'] = self.schema
|
||||
data['table'] = self.table
|
||||
@@ -514,7 +516,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
data=data, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_scalar(SQL)
|
||||
if not status:
|
||||
self.end_transaction()
|
||||
@@ -568,8 +570,8 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
data['name'],
|
||||
valid=valid,
|
||||
icon=icon
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
self.end_transaction()
|
||||
@@ -632,8 +634,8 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
'sid': sid,
|
||||
'gid': gid,
|
||||
'did': did,
|
||||
'icon':icon,
|
||||
'valid':valid
|
||||
'icon': icon,
|
||||
'valid': valid
|
||||
}
|
||||
)
|
||||
else:
|
||||
@@ -735,9 +737,9 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
sql = sql.strip('\n').strip(' ')
|
||||
|
||||
return make_json_response(
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -769,15 +771,15 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
sql = render_template("/".join([self.template_path, 'update.sql']),
|
||||
data=data, o_data=old_data)
|
||||
|
||||
if 'autoindex' in data and data['autoindex'] and\
|
||||
if 'autoindex' in data and data['autoindex'] and \
|
||||
('coveringindex' in data and
|
||||
data['coveringindex'] != ''):
|
||||
|
||||
col_sql = render_template("/".join([self.template_path,
|
||||
'get_constraint_cols.sql']),
|
||||
tid=tid,
|
||||
keys=zip(old_data['confkey'], old_data['conkey']),
|
||||
confrelid=old_data['confrelid'])
|
||||
'get_constraint_cols.sql']),
|
||||
tid=tid,
|
||||
keys=zip(old_data['confkey'], old_data['conkey']),
|
||||
confrelid=old_data['confrelid'])
|
||||
|
||||
status, res = self.conn.execute_dict(col_sql)
|
||||
|
||||
@@ -805,7 +807,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
return _('-- definition incomplete')
|
||||
|
||||
if data['autoindex'] and ('coveringindex' not in data or
|
||||
data['coveringindex'] == ''):
|
||||
data['coveringindex'] == ''):
|
||||
return _('-- definition incomplete')
|
||||
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
@@ -892,8 +894,8 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
sql_header = "-- Constraint: {0}\n\n-- ".format(data['name'])
|
||||
|
||||
sql_header += render_template(
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
data=data)
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
data=data)
|
||||
sql_header += "\n"
|
||||
|
||||
SQL = sql_header + SQL
|
||||
@@ -917,9 +919,9 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, fkid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, tid, fkid=None):
|
||||
@@ -935,9 +937,9 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, fkid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def validate_foreign_key(self, gid, sid, did, scid, tid, fkid):
|
||||
@@ -1048,11 +1050,12 @@ class ForeignKeyConstraintView(PGChildNodeView):
|
||||
return make_json_response(
|
||||
data=index,
|
||||
status=200
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
|
||||
constraint = ConstraintRegistry(
|
||||
'foreign_key', ForeignKeyConstraintModule, ForeignKeyConstraintView
|
||||
)
|
||||
)
|
||||
ForeignKeyConstraintView.register_node_view(blueprint)
|
||||
|
||||
@@ -182,14 +182,14 @@ class IndexConstraintView(PGChildNodeView):
|
||||
node_label = _('Index constraint')
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
ids = [{'type': 'int', 'id': 'cid'}
|
||||
]
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -213,14 +213,14 @@ class IndexConstraintView(PGChildNodeView):
|
||||
Override this property for your own logic.
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"index_constraint/js/index_constraint.js",
|
||||
_=_,
|
||||
node_type=self.node_type,
|
||||
node_label=self.node_label
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"index_constraint/js/index_constraint.js",
|
||||
_=_,
|
||||
node_type=self.node_type,
|
||||
node_label=self.node_label
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def check_precondition(f):
|
||||
"""
|
||||
@@ -228,20 +228,21 @@ class IndexConstraintView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
self = args[0]
|
||||
self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(
|
||||
kwargs['sid']
|
||||
)
|
||||
)
|
||||
self.conn = self.manager.connection(did=kwargs['did'])
|
||||
|
||||
# If DB not connected then return error to browser
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
_(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -263,7 +264,7 @@ class IndexConstraintView(PGChildNodeView):
|
||||
|
||||
def end_transaction(self):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'end.sql']))
|
||||
"/".join([self.template_path, 'end.sql']))
|
||||
# End transaction if any.
|
||||
self.conn.execute_scalar(SQL)
|
||||
|
||||
@@ -287,7 +288,7 @@ class IndexConstraintView(PGChildNodeView):
|
||||
sql = render_template("/".join([self.template_path, 'properties.sql']),
|
||||
tid=tid,
|
||||
cid=cid,
|
||||
constraint_type= self.constraint_type)
|
||||
constraint_type=self.constraint_type)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
|
||||
if not status:
|
||||
@@ -306,14 +307,14 @@ class IndexConstraintView(PGChildNodeView):
|
||||
|
||||
columns = []
|
||||
for row in res['rows']:
|
||||
columns.append({"column": row['column'].strip('"')})
|
||||
columns.append({"column": row['column'].strip('"')})
|
||||
|
||||
result['columns'] = columns
|
||||
|
||||
return ajax_response(
|
||||
response=result,
|
||||
status=200
|
||||
)
|
||||
response=result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def list(self, gid, sid, did, scid, tid, cid=None):
|
||||
@@ -335,9 +336,9 @@ class IndexConstraintView(PGChildNodeView):
|
||||
try:
|
||||
res = self.get_node_list(gid, sid, did, scid, tid, cid)
|
||||
return ajax_response(
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -360,7 +361,7 @@ class IndexConstraintView(PGChildNodeView):
|
||||
"""
|
||||
SQL = render_template("/".join([self.template_path, 'properties.sql']),
|
||||
tid=tid,
|
||||
constraint_type= self.constraint_type)
|
||||
constraint_type=self.constraint_type)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
return res['rows']
|
||||
@@ -385,9 +386,9 @@ class IndexConstraintView(PGChildNodeView):
|
||||
try:
|
||||
res = self.get_nodes(gid, sid, did, scid, tid, cid)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -415,12 +416,12 @@ class IndexConstraintView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
tid,
|
||||
row['name'],
|
||||
icon="icon-%s" % self.node_type
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
tid,
|
||||
row['name'],
|
||||
icon="icon-%s" % self.node_type
|
||||
))
|
||||
return res
|
||||
|
||||
@check_precondition
|
||||
@@ -440,7 +441,7 @@ class IndexConstraintView(PGChildNodeView):
|
||||
|
||||
"""
|
||||
required_args = [
|
||||
[u'columns', u'index'] # Either of one should be there.
|
||||
[u'columns', u'index'] # Either of one should be there.
|
||||
]
|
||||
|
||||
data = request.form if request.form else json.loads(request.data.decode())
|
||||
@@ -456,16 +457,16 @@ class IndexConstraintView(PGChildNodeView):
|
||||
for param in arg:
|
||||
if (param in data and
|
||||
(not isinstance(data[param], list) or
|
||||
(isinstance(data[param], list) and
|
||||
len(data[param]) > 0))):
|
||||
(isinstance(data[param], list) and
|
||||
len(data[param]) > 0))):
|
||||
break
|
||||
else:
|
||||
return make_json_response(
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=_(
|
||||
"Couldn't find at least one required parameter (%s)." % str(param)
|
||||
)
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=_(
|
||||
"Couldn't find at least one required parameter (%s)." % str(param)
|
||||
)
|
||||
)
|
||||
|
||||
elif arg not in data:
|
||||
@@ -494,7 +495,7 @@ class IndexConstraintView(PGChildNodeView):
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
data=data, conn=self.conn,
|
||||
constraint_name=self.constraint_name
|
||||
)
|
||||
)
|
||||
|
||||
status, msg = self.conn.execute_scalar(SQL)
|
||||
if not status:
|
||||
@@ -534,8 +535,8 @@ class IndexConstraintView(PGChildNodeView):
|
||||
tid,
|
||||
data['name'],
|
||||
icon="icon-%s" % self.node_type
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
self.end_transaction()
|
||||
@@ -636,7 +637,7 @@ class IndexConstraintView(PGChildNodeView):
|
||||
try:
|
||||
sql = render_template("/".join([self.template_path, 'get_name.sql']),
|
||||
tid=tid,
|
||||
constraint_type = self.constraint_type,
|
||||
constraint_type=self.constraint_type,
|
||||
cid=cid)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
if not status:
|
||||
@@ -698,9 +699,9 @@ class IndexConstraintView(PGChildNodeView):
|
||||
sql = sql.strip('\n').strip(' ')
|
||||
|
||||
return make_json_response(
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -721,7 +722,7 @@ class IndexConstraintView(PGChildNodeView):
|
||||
sql = render_template("/".join([self.template_path, 'properties.sql']),
|
||||
tid=tid,
|
||||
cid=cid,
|
||||
constraint_type= self.constraint_type)
|
||||
constraint_type=self.constraint_type)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -737,7 +738,7 @@ class IndexConstraintView(PGChildNodeView):
|
||||
o_data=old_data)
|
||||
else:
|
||||
required_args = [
|
||||
[u'columns', u'index'] # Either of one should be there.
|
||||
[u'columns', u'index'] # Either of one should be there.
|
||||
]
|
||||
|
||||
for arg in required_args:
|
||||
@@ -745,9 +746,9 @@ class IndexConstraintView(PGChildNodeView):
|
||||
for param in arg:
|
||||
if (param in data and
|
||||
((isinstance(data[param], str) and
|
||||
data[param] != "") or
|
||||
(isinstance(data[param], list) and
|
||||
len(data[param]) > 0))):
|
||||
data[param] != "") or
|
||||
(isinstance(data[param], list) and
|
||||
len(data[param]) > 0))):
|
||||
break
|
||||
else:
|
||||
return _('-- definition incomplete')
|
||||
@@ -805,7 +806,7 @@ class IndexConstraintView(PGChildNodeView):
|
||||
|
||||
columns = []
|
||||
for row in res['rows']:
|
||||
columns.append({"column": row['column'].strip('"')})
|
||||
columns.append({"column": row['column'].strip('"')})
|
||||
|
||||
data['columns'] = columns
|
||||
|
||||
@@ -817,8 +818,8 @@ class IndexConstraintView(PGChildNodeView):
|
||||
sql_header = "-- Constraint: {0}\n\n-- ".format(data['name'])
|
||||
|
||||
sql_header += render_template(
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
data=data)
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
data=data)
|
||||
sql_header += "\n"
|
||||
|
||||
SQL = sql_header + SQL
|
||||
@@ -859,7 +860,7 @@ class IndexConstraintView(PGChildNodeView):
|
||||
sql = render_template("/".join([self.template_path, 'properties.sql']),
|
||||
tid=tid,
|
||||
cid=cid,
|
||||
constraint_type= self.constraint_type)
|
||||
constraint_type=self.constraint_type)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
|
||||
if not status:
|
||||
@@ -875,15 +876,16 @@ class IndexConstraintView(PGChildNodeView):
|
||||
"/".join([self.template_path, 'stats.sql']),
|
||||
conn=self.conn, schema=self.schema,
|
||||
name=name, cid=cid, is_pgstattuple=is_pgstattuple
|
||||
)
|
||||
)
|
||||
)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
class PrimaryKeyConstraintView(IndexConstraintView):
|
||||
node_type = 'primary_key'
|
||||
@@ -907,11 +909,11 @@ class UniqueConstraintView(IndexConstraintView):
|
||||
|
||||
primary_key_constraint = ConstraintRegistry(
|
||||
'primary_key', PrimaryKeyConstraintModule, PrimaryKeyConstraintView
|
||||
)
|
||||
)
|
||||
|
||||
unique_constraint = ConstraintRegistry(
|
||||
'unique_constraint', UniqueConstraintModule, UniqueConstraintView
|
||||
)
|
||||
)
|
||||
|
||||
PrimaryKeyConstraintView.register_node_view(primary_key_blueprint)
|
||||
UniqueConstraintView.register_node_view(unique_constraint_blueprint)
|
||||
|
||||
@@ -23,7 +23,6 @@ class ConstraintRegistry(object):
|
||||
|
||||
def __init__(self, name, con_blueprint, con_nodeview):
|
||||
if name not in ConstraintRegistry.registry:
|
||||
|
||||
blueprint = con_blueprint(name)
|
||||
|
||||
# TODO:: register the view with the blueprint
|
||||
|
||||
@@ -73,7 +73,7 @@ class IndexesModule(CollectionNodeModule):
|
||||
if not conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -82,7 +82,7 @@ class IndexesModule(CollectionNodeModule):
|
||||
|
||||
template_path = 'index/sql/9.1_plus'
|
||||
SQL = render_template("/".join(
|
||||
[template_path, 'backend_support.sql']), vid=kwargs['vid'])
|
||||
[template_path, 'backend_support.sql']), vid=kwargs['vid'])
|
||||
status, res = conn.execute_scalar(SQL)
|
||||
|
||||
# check if any errors
|
||||
@@ -96,7 +96,7 @@ class IndexesModule(CollectionNodeModule):
|
||||
"""
|
||||
Generate the collection node
|
||||
"""
|
||||
assert('tid' in kwargs or 'vid' in kwargs)
|
||||
assert ('tid' in kwargs or 'vid' in kwargs)
|
||||
yield self.generate_browser_collection_node(
|
||||
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']
|
||||
)
|
||||
@@ -116,6 +116,7 @@ class IndexesModule(CollectionNodeModule):
|
||||
"""
|
||||
return False
|
||||
|
||||
|
||||
blueprint = IndexesModule(__name__)
|
||||
|
||||
|
||||
@@ -180,15 +181,15 @@ class IndexesView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'idx'}
|
||||
]
|
||||
{'type': 'int', 'id': 'idx'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -209,7 +210,7 @@ class IndexesView(PGChildNodeView):
|
||||
'get_access_methods': [{'get': 'get_access_methods'},
|
||||
{'get': 'get_access_methods'}],
|
||||
'get_op_class': [{'get': 'get_op_class'},
|
||||
{'get': 'get_op_class'}]
|
||||
{'get': 'get_op_class'}]
|
||||
})
|
||||
|
||||
def check_precondition(f):
|
||||
@@ -218,6 +219,7 @@ class IndexesView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -230,7 +232,7 @@ class IndexesView(PGChildNodeView):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -274,13 +276,13 @@ class IndexesView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
{'label': row['collation'],
|
||||
'value': row['collation']}
|
||||
)
|
||||
{'label': row['collation'],
|
||||
'value': row['collation']}
|
||||
)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -301,13 +303,13 @@ class IndexesView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
{'label': row['amname'],
|
||||
'value': row['amname']}
|
||||
)
|
||||
{'label': row['amname'],
|
||||
'value': row['amname']}
|
||||
)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -346,14 +348,13 @@ class IndexesView(PGChildNodeView):
|
||||
res[row['amname']] = op_class_list
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
|
||||
@check_precondition
|
||||
def list(self, gid, sid, did, scid, tid):
|
||||
"""
|
||||
@@ -377,9 +378,9 @@ class IndexesView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did, scid, tid):
|
||||
@@ -406,17 +407,17 @@ class IndexesView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
tid,
|
||||
row['name'],
|
||||
icon="icon-index"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
tid,
|
||||
row['name'],
|
||||
icon="icon-index"
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
def _column_details(self, idx, data):
|
||||
"""
|
||||
@@ -469,7 +470,6 @@ class IndexesView(PGChildNodeView):
|
||||
|
||||
return data
|
||||
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, scid, tid, idx):
|
||||
"""
|
||||
@@ -505,9 +505,9 @@ class IndexesView(PGChildNodeView):
|
||||
data = self._column_details(idx, data)
|
||||
|
||||
return ajax_response(
|
||||
response=data,
|
||||
status=200
|
||||
)
|
||||
response=data,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def create(self, gid, sid, did, scid, tid):
|
||||
@@ -705,7 +705,6 @@ class IndexesView(PGChildNodeView):
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
|
||||
@check_precondition
|
||||
def msql(self, gid, sid, did, scid, tid, idx=None):
|
||||
"""
|
||||
@@ -735,9 +734,9 @@ class IndexesView(PGChildNodeView):
|
||||
|
||||
if SQL and SQL.strip('\n') and SQL.strip(' '):
|
||||
return make_json_response(
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -765,7 +764,7 @@ class IndexesView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
data=data, o_data=old_data, conn=self.conn
|
||||
)
|
||||
)
|
||||
else:
|
||||
required_args = {
|
||||
'name': 'Name',
|
||||
@@ -855,9 +854,9 @@ class IndexesView(PGChildNodeView):
|
||||
)
|
||||
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, tid, idx):
|
||||
@@ -879,9 +878,9 @@ class IndexesView(PGChildNodeView):
|
||||
)
|
||||
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def statistics(self, gid, sid, did, scid, tid, idx=None):
|
||||
@@ -933,8 +932,8 @@ class IndexesView(PGChildNodeView):
|
||||
"/".join([self.template_path, 'stats.sql']),
|
||||
conn=self.conn, schema=self.schema,
|
||||
index=index, idx=idx, is_pgstattuple=is_pgstattuple
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
else:
|
||||
status, res = self.conn.execute_dict(
|
||||
@@ -942,15 +941,16 @@ class IndexesView(PGChildNodeView):
|
||||
"/".join([self.template_path, 'coll_stats.sql']),
|
||||
conn=self.conn, schema=self.schema,
|
||||
table=self.table
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
IndexesView.register_node_view(blueprint)
|
||||
|
||||
@@ -57,7 +57,7 @@ class RuleModule(CollectionNodeModule):
|
||||
if not conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -66,8 +66,8 @@ class RuleModule(CollectionNodeModule):
|
||||
|
||||
self.template_path = 'rules/sql'
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'backend_support.sql']
|
||||
), vid=kwargs['vid'])
|
||||
[self.template_path, 'backend_support.sql']
|
||||
), vid=kwargs['vid'])
|
||||
status, res = conn.execute_scalar(SQL)
|
||||
# check if any errors
|
||||
if not status:
|
||||
@@ -83,10 +83,10 @@ class RuleModule(CollectionNodeModule):
|
||||
"""
|
||||
Generate the collection node
|
||||
"""
|
||||
assert('tid' in kwargs or 'vid' in kwargs)
|
||||
assert ('tid' in kwargs or 'vid' in kwargs)
|
||||
yield self.generate_browser_collection_node(
|
||||
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']
|
||||
)
|
||||
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']
|
||||
)
|
||||
|
||||
@property
|
||||
def node_inode(self):
|
||||
@@ -109,17 +109,17 @@ class RuleModule(CollectionNodeModule):
|
||||
Returns a snippet of css to include in the page
|
||||
"""
|
||||
snippets = [
|
||||
render_template(
|
||||
"browser/css/collection.css",
|
||||
node_type=self.node_type,
|
||||
_=gettext
|
||||
),
|
||||
render_template(
|
||||
"rules/css/rule.css",
|
||||
node_type=self.node_type,
|
||||
_=gettext
|
||||
)
|
||||
]
|
||||
render_template(
|
||||
"browser/css/collection.css",
|
||||
node_type=self.node_type,
|
||||
_=gettext
|
||||
),
|
||||
render_template(
|
||||
"rules/css/rule.css",
|
||||
node_type=self.node_type,
|
||||
_=gettext
|
||||
)
|
||||
]
|
||||
|
||||
for submodule in self.submodules:
|
||||
snippets.extend(submodule.csssnippets)
|
||||
@@ -147,15 +147,15 @@ class RuleView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'rid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'rid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -181,12 +181,12 @@ class RuleView(PGChildNodeView):
|
||||
This property defines whether Javascript exists for this node.
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"rules/js/rules.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"rules/js/rules.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def check_precondition(f):
|
||||
"""
|
||||
@@ -194,20 +194,20 @@ class RuleView(PGChildNodeView):
|
||||
database connection before running a view. It will also attach
|
||||
manager, conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
self = args[0]
|
||||
self.manager = get_driver(
|
||||
PG_DEFAULT_DRIVER).connection_manager(kwargs['sid'])
|
||||
PG_DEFAULT_DRIVER).connection_manager(kwargs['sid'])
|
||||
self.conn = self.manager.connection(did=kwargs['did'])
|
||||
|
||||
# If DB not connected then return error to browser
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -225,15 +225,15 @@ class RuleView(PGChildNodeView):
|
||||
|
||||
# fetch schema name by schema id
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'properties.sql']), tid=tid)
|
||||
[self.template_path, 'properties.sql']), tid=tid)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did, scid, tid):
|
||||
@@ -242,7 +242,7 @@ class RuleView(PGChildNodeView):
|
||||
"""
|
||||
res = []
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'properties.sql']), tid=tid)
|
||||
[self.template_path, 'properties.sql']), tid=tid)
|
||||
|
||||
status, rset = self.conn.execute_2darray(SQL)
|
||||
if not status:
|
||||
@@ -250,17 +250,17 @@ class RuleView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
tid,
|
||||
row['name'],
|
||||
icon="icon-rule"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
tid,
|
||||
row['name'],
|
||||
icon="icon-rule"
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, scid, tid, rid):
|
||||
@@ -270,16 +270,16 @@ class RuleView(PGChildNodeView):
|
||||
"""
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'properties.sql']
|
||||
), rid=rid, datlastsysoid=self.datlastsysoid)
|
||||
), rid=rid, datlastsysoid=self.datlastsysoid)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return ajax_response(
|
||||
response=parse_rule_definition(res),
|
||||
status=200
|
||||
)
|
||||
response=parse_rule_definition(res),
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def create(self, gid, sid, did, scid, tid):
|
||||
@@ -373,7 +373,7 @@ class RuleView(PGChildNodeView):
|
||||
try:
|
||||
# Get name for rule from did
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'delete.sql']), rid=rid)
|
||||
[self.template_path, 'delete.sql']), rid=rid)
|
||||
status, res_data = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res_data)
|
||||
@@ -381,10 +381,10 @@ class RuleView(PGChildNodeView):
|
||||
rset = res_data['rows'][0]
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'delete.sql']),
|
||||
rulename=rset['rulename'],
|
||||
relname=rset['relname'],
|
||||
nspname=rset['nspname'],
|
||||
cascade=cascade
|
||||
rulename=rset['rulename'],
|
||||
relname=rset['relname'],
|
||||
nspname=rset['nspname'],
|
||||
cascade=cascade
|
||||
)
|
||||
status, res = self.conn.execute_scalar(SQL)
|
||||
if not status:
|
||||
@@ -412,9 +412,9 @@ class RuleView(PGChildNodeView):
|
||||
data = request.args
|
||||
SQL = self.getSQL(gid, sid, data, tid, rid)
|
||||
return make_json_response(
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def sql(self, gid, sid, did, scid, tid, rid):
|
||||
@@ -422,7 +422,7 @@ class RuleView(PGChildNodeView):
|
||||
This function will generate sql to render into the sql panel
|
||||
"""
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'properties.sql']), rid=rid)
|
||||
[self.template_path, 'properties.sql']), rid=rid)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -440,7 +440,7 @@ class RuleView(PGChildNodeView):
|
||||
try:
|
||||
if rid is not None:
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'properties.sql']), rid=rid)
|
||||
[self.template_path, 'properties.sql']), rid=rid)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
res_data = []
|
||||
res_data = parse_rule_definition(res)
|
||||
@@ -450,7 +450,7 @@ class RuleView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
data=data, o_data=old_data
|
||||
)
|
||||
)
|
||||
else:
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'create.sql']), data=data)
|
||||
@@ -475,7 +475,7 @@ class RuleView(PGChildNodeView):
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, tid, rid):
|
||||
@@ -494,6 +494,7 @@ class RuleView(PGChildNodeView):
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
RuleView.register_node_view(blueprint)
|
||||
|
||||
@@ -73,7 +73,7 @@ class TriggerModule(CollectionNodeModule):
|
||||
if not conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -82,7 +82,7 @@ class TriggerModule(CollectionNodeModule):
|
||||
|
||||
template_path = 'trigger/sql/9.1_plus'
|
||||
SQL = render_template("/".join(
|
||||
[template_path, 'backend_support.sql']), vid=kwargs['vid'])
|
||||
[template_path, 'backend_support.sql']), vid=kwargs['vid'])
|
||||
status, res = conn.execute_scalar(SQL)
|
||||
# check if any errors
|
||||
if not status:
|
||||
@@ -95,7 +95,7 @@ class TriggerModule(CollectionNodeModule):
|
||||
"""
|
||||
Generate the collection node
|
||||
"""
|
||||
assert('tid' in kwargs or 'vid' in kwargs)
|
||||
assert ('tid' in kwargs or 'vid' in kwargs)
|
||||
yield self.generate_browser_collection_node(
|
||||
kwargs['tid'] if 'tid' in kwargs else kwargs['vid']
|
||||
)
|
||||
@@ -121,17 +121,18 @@ class TriggerModule(CollectionNodeModule):
|
||||
Returns a snippet of css to include in the page
|
||||
"""
|
||||
snippets = [
|
||||
render_template(
|
||||
"trigger/css/trigger.css",
|
||||
node_type=self.node_type
|
||||
)
|
||||
]
|
||||
render_template(
|
||||
"trigger/css/trigger.css",
|
||||
node_type=self.node_type
|
||||
)
|
||||
]
|
||||
|
||||
for submodule in self.submodules:
|
||||
snippets.extend(submodule.csssnippets)
|
||||
|
||||
return snippets
|
||||
|
||||
|
||||
blueprint = TriggerModule(__name__)
|
||||
|
||||
|
||||
@@ -210,15 +211,15 @@ class TriggerView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'},
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'trid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'trid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -235,7 +236,7 @@ class TriggerView(PGChildNodeView):
|
||||
'dependent': [{'get': 'dependents'}],
|
||||
'module.js': [{}, {}, {'get': 'module_js'}],
|
||||
'get_triggerfunctions': [{'get': 'get_trigger_functions'},
|
||||
{'get': 'get_trigger_functions'}],
|
||||
{'get': 'get_trigger_functions'}],
|
||||
'enable': [{'put': 'enable_disable_trigger'}]
|
||||
})
|
||||
|
||||
@@ -245,6 +246,7 @@ class TriggerView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -257,7 +259,7 @@ class TriggerView(PGChildNodeView):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -285,13 +287,13 @@ class TriggerView(PGChildNodeView):
|
||||
# Here we are storing trigger definition
|
||||
# We will use it to check trigger type definition
|
||||
self.trigger_definition = {
|
||||
'TRIGGER_TYPE_ROW': (1 << 0),
|
||||
'TRIGGER_TYPE_BEFORE': (1 << 1),
|
||||
'TRIGGER_TYPE_INSERT': (1 << 2),
|
||||
'TRIGGER_TYPE_DELETE': (1 << 3),
|
||||
'TRIGGER_TYPE_UPDATE': (1 << 4),
|
||||
'TRIGGER_TYPE_TRUNCATE': (1 << 5),
|
||||
'TRIGGER_TYPE_INSTEAD': (1 << 6)
|
||||
'TRIGGER_TYPE_ROW': (1 << 0),
|
||||
'TRIGGER_TYPE_BEFORE': (1 << 1),
|
||||
'TRIGGER_TYPE_INSERT': (1 << 2),
|
||||
'TRIGGER_TYPE_DELETE': (1 << 3),
|
||||
'TRIGGER_TYPE_UPDATE': (1 << 4),
|
||||
'TRIGGER_TYPE_TRUNCATE': (1 << 5),
|
||||
'TRIGGER_TYPE_INSTEAD': (1 << 6)
|
||||
}
|
||||
|
||||
return f(*args, **kwargs)
|
||||
@@ -314,7 +316,7 @@ class TriggerView(PGChildNodeView):
|
||||
res.append({
|
||||
'label': 'Inline EDB-SPL',
|
||||
'value': 'Inline EDB-SPL'
|
||||
})
|
||||
})
|
||||
try:
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
'get_triggerfunctions.sql']),
|
||||
@@ -326,13 +328,13 @@ class TriggerView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
{'label': row['tfunctions'],
|
||||
'value': row['tfunctions']}
|
||||
)
|
||||
{'label': row['tfunctions'],
|
||||
'value': row['tfunctions']}
|
||||
)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -360,9 +362,9 @@ class TriggerView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did, scid, tid):
|
||||
@@ -389,18 +391,18 @@ class TriggerView(PGChildNodeView):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
tid,
|
||||
row['name'],
|
||||
icon="icon-trigger" if row['is_enable_trigger']
|
||||
else "icon-trigger-bad"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
tid,
|
||||
row['name'],
|
||||
icon="icon-trigger" if row['is_enable_trigger']
|
||||
else "icon-trigger-bad"
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
def _column_details(self, tid, clist):
|
||||
"""
|
||||
@@ -441,7 +443,7 @@ class TriggerView(PGChildNodeView):
|
||||
|
||||
# Fires event definition
|
||||
if data['tgtype'] & self.trigger_definition['TRIGGER_TYPE_BEFORE']:
|
||||
data['fires'] = 'BEFORE'
|
||||
data['fires'] = 'BEFORE'
|
||||
elif data['tgtype'] & self.trigger_definition['TRIGGER_TYPE_INSTEAD']:
|
||||
data['fires'] = 'INSTEAD OF'
|
||||
else:
|
||||
@@ -518,9 +520,9 @@ class TriggerView(PGChildNodeView):
|
||||
data = self._trigger_definition(data)
|
||||
|
||||
return ajax_response(
|
||||
response=data,
|
||||
status=200
|
||||
)
|
||||
response=data,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def create(self, gid, sid, did, scid, tid):
|
||||
@@ -552,11 +554,11 @@ class TriggerView(PGChildNodeView):
|
||||
for arg in required_args:
|
||||
if arg not in data:
|
||||
return make_json_response(
|
||||
status=410,
|
||||
success=0,
|
||||
errormsg=gettext("Couldn't find the required parameter (%s)." % \
|
||||
required_args[arg])
|
||||
)
|
||||
status=410,
|
||||
success=0,
|
||||
errormsg=gettext("Couldn't find the required parameter (%s)." % \
|
||||
required_args[arg])
|
||||
)
|
||||
|
||||
# Adding parent into data dict, will be using it while creating sql
|
||||
data['schema'] = self.schema
|
||||
@@ -716,9 +718,9 @@ class TriggerView(PGChildNodeView):
|
||||
|
||||
if SQL and SQL.strip('\n') and SQL.strip(' '):
|
||||
return make_json_response(
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -756,7 +758,7 @@ class TriggerView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
data=data, o_data=old_data, conn=self.conn
|
||||
)
|
||||
)
|
||||
else:
|
||||
required_args = {
|
||||
'name': 'Name',
|
||||
@@ -893,7 +895,6 @@ class TriggerView(PGChildNodeView):
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
|
||||
@check_precondition
|
||||
def dependents(self, gid, sid, did, scid, tid, trid):
|
||||
"""
|
||||
@@ -913,9 +914,9 @@ class TriggerView(PGChildNodeView):
|
||||
)
|
||||
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, tid, trid):
|
||||
@@ -937,8 +938,9 @@ class TriggerView(PGChildNodeView):
|
||||
)
|
||||
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
TriggerView.register_node_view(blueprint)
|
||||
|
||||
@@ -86,6 +86,7 @@ class TypeModule(SchemaChildModule):
|
||||
"""
|
||||
return False
|
||||
|
||||
|
||||
blueprint = TypeModule(__name__)
|
||||
|
||||
|
||||
@@ -173,14 +174,14 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'tid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -213,6 +214,7 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -227,7 +229,7 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -267,9 +269,9 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did, scid):
|
||||
@@ -298,17 +300,17 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
scid,
|
||||
row['name'],
|
||||
icon="icon-type"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
scid,
|
||||
row['name'],
|
||||
icon="icon-type"
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
def additional_properties(self, copy_dict, tid):
|
||||
"""
|
||||
@@ -376,9 +378,10 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
is_precision = True if t_prec else False
|
||||
|
||||
composite_lst.append({
|
||||
'attnum':row['attnum'], 'member_name': row['attname'], 'type': row['typname'], 'collation': full_collate,
|
||||
'attnum': row['attnum'], 'member_name': row['attname'], 'type': row['typname'],
|
||||
'collation': full_collate,
|
||||
'tlength': t_len, 'precision': t_prec,
|
||||
'is_tlength': is_tlength, 'is_precision': is_precision })
|
||||
'is_tlength': is_tlength, 'is_precision': is_precision})
|
||||
|
||||
# Adding both results
|
||||
res['member_list'] = ', '.join(properties_list)
|
||||
@@ -470,9 +473,9 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
copy_dict.update(self.additional_properties(copy_dict, tid))
|
||||
|
||||
return ajax_response(
|
||||
response=copy_dict,
|
||||
status=200
|
||||
)
|
||||
response=copy_dict,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def get_collations(self, gid, sid, did, scid, tid=None):
|
||||
@@ -490,13 +493,13 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
{'label': row['collation'],
|
||||
'value': row['collation']}
|
||||
)
|
||||
{'label': row['collation'],
|
||||
'value': row['collation']}
|
||||
)
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -552,17 +555,17 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
max_val = 10
|
||||
|
||||
res.append(
|
||||
{'label': row['typname'], 'value': row['typname'],
|
||||
'typval': typeval, 'precision': precision,
|
||||
'length': length, 'min_val': min_val, 'max_val': max_val,
|
||||
'is_collatable': row['is_collatable']
|
||||
}
|
||||
)
|
||||
{'label': row['typname'], 'value': row['typname'],
|
||||
'typval': typeval, 'precision': precision,
|
||||
'length': length, 'min_val': min_val, 'max_val': max_val,
|
||||
'is_collatable': row['is_collatable']
|
||||
}
|
||||
)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -583,14 +586,14 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
{'label': row['stype'], 'value': row['stype'],
|
||||
'is_collate': row['is_collate']}
|
||||
)
|
||||
{'label': row['stype'], 'value': row['stype'],
|
||||
'is_collate': row['is_collate']}
|
||||
)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -614,13 +617,13 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
{'label': row['opcname'],
|
||||
'value': row['opcname']})
|
||||
{'label': row['opcname'],
|
||||
'value': row['opcname']})
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -651,14 +654,14 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
{'label': row['stypdiff'],
|
||||
'value': row['stypdiff']}
|
||||
)
|
||||
{'label': row['stypdiff'],
|
||||
'value': row['stypdiff']}
|
||||
)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -697,18 +700,17 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
{'label': row['canonical'],
|
||||
'value': row['canonical']})
|
||||
{'label': row['canonical'],
|
||||
'value': row['canonical']})
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
|
||||
@check_precondition
|
||||
def get_external_functions_list(self, gid, sid, did, scid, tid=None):
|
||||
"""
|
||||
@@ -769,7 +771,6 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
|
||||
@check_precondition
|
||||
def create(self, gid, sid, did, scid):
|
||||
"""
|
||||
@@ -922,7 +923,6 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
|
||||
@check_precondition
|
||||
def delete(self, gid, sid, did, scid, tid):
|
||||
"""
|
||||
@@ -976,7 +976,6 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
|
||||
@check_precondition
|
||||
def msql(self, gid, sid, did, scid, tid=None):
|
||||
"""
|
||||
@@ -993,7 +992,7 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
data = dict()
|
||||
|
||||
# converting nested request data in proper json format
|
||||
for key,val in req.items():
|
||||
for key, val in req.items():
|
||||
if key in ['composite', 'enum', 'seclabels', 'typacl']:
|
||||
data[key] = json.loads(val)
|
||||
else:
|
||||
@@ -1004,9 +1003,9 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
|
||||
if SQL and SQL.strip('\n') and SQL.strip(' '):
|
||||
return make_json_response(
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
except Exception as e:
|
||||
internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -1048,11 +1047,11 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
for key in ['typacl']:
|
||||
if key in data and data[key] is not None:
|
||||
if 'added' in data[key]:
|
||||
data[key]['added'] = parse_priv_to_db(data[key]['added'], self.acl)
|
||||
data[key]['added'] = parse_priv_to_db(data[key]['added'], self.acl)
|
||||
if 'changed' in data[key]:
|
||||
data[key]['changed'] = parse_priv_to_db(data[key]['changed'], self.acl)
|
||||
data[key]['changed'] = parse_priv_to_db(data[key]['changed'], self.acl)
|
||||
if 'deleted' in data[key]:
|
||||
data[key]['deleted'] = parse_priv_to_db(data[key]['deleted'], self.acl)
|
||||
data[key]['deleted'] = parse_priv_to_db(data[key]['deleted'], self.acl)
|
||||
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
'properties.sql']),
|
||||
@@ -1091,7 +1090,7 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
data=data, o_data=old_data, conn=self.conn
|
||||
)
|
||||
)
|
||||
else:
|
||||
required_args = [
|
||||
'name',
|
||||
@@ -1112,7 +1111,6 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
|
||||
return SQL
|
||||
|
||||
|
||||
@check_precondition
|
||||
def sql(self, gid, sid, did, scid, tid):
|
||||
"""
|
||||
@@ -1197,9 +1195,9 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
)
|
||||
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, tid):
|
||||
@@ -1219,8 +1217,9 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
)
|
||||
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
TypeView.register_node_view(blueprint)
|
||||
|
||||
@@ -43,22 +43,22 @@ class SchemaChildModule(CollectionNodeModule):
|
||||
|
||||
def BackendSupported(self, manager, **kwargs):
|
||||
return (
|
||||
(
|
||||
kwargs['is_catalog'] and ((
|
||||
self.CATALOG_DB_SUPPORTED and kwargs['db_support']
|
||||
) or (
|
||||
not self.CATALOG_DB_SUPPORTED and
|
||||
not kwargs['db_support'] and
|
||||
(
|
||||
self.SUPPORTED_SCHEMAS is None or (
|
||||
kwargs['schema_name'] in self.SUPPORTED_SCHEMAS
|
||||
)
|
||||
)
|
||||
))
|
||||
) or (
|
||||
not kwargs['is_catalog'] and self.CATALOG_DB_SUPPORTED
|
||||
)
|
||||
) and CollectionNodeModule.BackendSupported(
|
||||
(
|
||||
kwargs['is_catalog'] and ((
|
||||
self.CATALOG_DB_SUPPORTED and kwargs['db_support']
|
||||
) or (
|
||||
not self.CATALOG_DB_SUPPORTED and
|
||||
not kwargs['db_support'] and
|
||||
(
|
||||
self.SUPPORTED_SCHEMAS is None or (
|
||||
kwargs['schema_name'] in self.SUPPORTED_SCHEMAS
|
||||
)
|
||||
)
|
||||
))
|
||||
) or (
|
||||
not kwargs['is_catalog'] and self.CATALOG_DB_SUPPORTED
|
||||
)
|
||||
) and CollectionNodeModule.BackendSupported(
|
||||
self, manager, **kwargs
|
||||
)
|
||||
|
||||
@@ -161,9 +161,9 @@ class DataTypeReader:
|
||||
# Above 7.4, format_type also sends the schema name if it's not included
|
||||
# in the search_path, so we need to skip it in the typname
|
||||
if typname.find(schema + '".') >= 0:
|
||||
name = typname[len(schema)+3]
|
||||
name = typname[len(schema) + 3]
|
||||
elif typname.find(schema + '.') >= 0:
|
||||
name = typname[len(schema)+1]
|
||||
name = typname[len(schema) + 1]
|
||||
else:
|
||||
name = typname
|
||||
|
||||
@@ -191,19 +191,19 @@ class DataTypeReader:
|
||||
_len = (typmod - 4) >> 16;
|
||||
_prec = (typmod - 4) & 0xffff;
|
||||
length += str(_len)
|
||||
if(_prec):
|
||||
if (_prec):
|
||||
length += ',' + str(_prec)
|
||||
elif name == 'time' or \
|
||||
name == 'timetz' or \
|
||||
name == 'time without time zone' or \
|
||||
name == 'time with time zone' or \
|
||||
name == 'timestamp' or \
|
||||
name == 'timestamptz'or \
|
||||
name == 'timestamp without time zone' or \
|
||||
name == 'timestamp with time zone' or \
|
||||
name == 'bit' or \
|
||||
name == 'bit varying' or \
|
||||
name == 'varbit':
|
||||
name == 'timetz' or \
|
||||
name == 'time without time zone' or \
|
||||
name == 'time with time zone' or \
|
||||
name == 'timestamp' or \
|
||||
name == 'timestamptz' or \
|
||||
name == 'timestamp without time zone' or \
|
||||
name == 'timestamp with time zone' or \
|
||||
name == 'bit' or \
|
||||
name == 'bit varying' or \
|
||||
name == 'varbit':
|
||||
_prec = 0
|
||||
_len = typmod
|
||||
length += str(_len)
|
||||
@@ -250,13 +250,13 @@ def trigger_definition(data):
|
||||
# Here we are storing trigger definition
|
||||
# We will use it to check trigger type definition
|
||||
trigger_definition = {
|
||||
'TRIGGER_TYPE_ROW': (1 << 0),
|
||||
'TRIGGER_TYPE_BEFORE': (1 << 1),
|
||||
'TRIGGER_TYPE_INSERT': (1 << 2),
|
||||
'TRIGGER_TYPE_DELETE': (1 << 3),
|
||||
'TRIGGER_TYPE_UPDATE': (1 << 4),
|
||||
'TRIGGER_TYPE_TRUNCATE': (1 << 5),
|
||||
'TRIGGER_TYPE_INSTEAD': (1 << 6)
|
||||
'TRIGGER_TYPE_ROW': (1 << 0),
|
||||
'TRIGGER_TYPE_BEFORE': (1 << 1),
|
||||
'TRIGGER_TYPE_INSERT': (1 << 2),
|
||||
'TRIGGER_TYPE_DELETE': (1 << 3),
|
||||
'TRIGGER_TYPE_UPDATE': (1 << 4),
|
||||
'TRIGGER_TYPE_TRUNCATE': (1 << 5),
|
||||
'TRIGGER_TYPE_INSTEAD': (1 << 6)
|
||||
}
|
||||
|
||||
# Fires event definition
|
||||
@@ -369,6 +369,7 @@ class VacuumSettings:
|
||||
* type - table/toast vacuum type
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@@ -388,8 +389,8 @@ class VacuumSettings:
|
||||
vacuum_fields = json.loads(vacuum_fields)
|
||||
|
||||
# returns an array of setting & name values
|
||||
vacuum_fields_keys = "'"+"','".join(
|
||||
vacuum_fields['table'].keys())+"'"
|
||||
vacuum_fields_keys = "'" + "','".join(
|
||||
vacuum_fields['table'].keys()) + "'"
|
||||
SQL = render_template('vacuum_settings/sql/vacuum_defaults.sql',
|
||||
columns=vacuum_fields_keys)
|
||||
status, res = conn.execute_dict(SQL)
|
||||
@@ -421,8 +422,8 @@ class VacuumSettings:
|
||||
vacuum_fields = json.loads(vacuum_fields)
|
||||
|
||||
# returns an array of setting & name values
|
||||
vacuum_fields_keys = "'"+"','".join(
|
||||
vacuum_fields['toast'].keys())+"'"
|
||||
vacuum_fields_keys = "'" + "','".join(
|
||||
vacuum_fields['toast'].keys()) + "'"
|
||||
SQL = render_template('vacuum_settings/sql/vacuum_defaults.sql',
|
||||
columns=vacuum_fields_keys)
|
||||
status, res = conn.execute_dict(SQL)
|
||||
@@ -456,7 +457,7 @@ class VacuumSettings:
|
||||
vacuum_fields = json.loads(vacuum_fields)
|
||||
|
||||
# returns an array of setting & name values
|
||||
vacuum_fields_keys = "'"+"','".join(
|
||||
vacuum_fields_keys = "'" + "','".join(
|
||||
vacuum_fields[type].keys()) + "'"
|
||||
SQL = render_template('vacuum_settings/sql/vacuum_defaults.sql',
|
||||
columns=vacuum_fields_keys)
|
||||
@@ -492,4 +493,4 @@ class VacuumSettings:
|
||||
value = int(result[row_name])
|
||||
row['value'] = row['setting'] = value
|
||||
|
||||
return res['rows']
|
||||
return res['rows']
|
||||
|
||||
@@ -100,22 +100,22 @@ class ViewModule(SchemaChildModule):
|
||||
Returns a snippet of css to include in the page
|
||||
"""
|
||||
snippets = [
|
||||
render_template(
|
||||
"browser/css/collection.css",
|
||||
node_type=self.node_type,
|
||||
_=gettext
|
||||
),
|
||||
render_template(
|
||||
"view/css/view.css",
|
||||
node_type=self.node_type,
|
||||
_=gettext
|
||||
),
|
||||
render_template(
|
||||
"mview/css/mview.css",
|
||||
node_type='mview',
|
||||
_=gettext
|
||||
)
|
||||
]
|
||||
render_template(
|
||||
"browser/css/collection.css",
|
||||
node_type=self.node_type,
|
||||
_=gettext
|
||||
),
|
||||
render_template(
|
||||
"view/css/view.css",
|
||||
node_type=self.node_type,
|
||||
_=gettext
|
||||
),
|
||||
render_template(
|
||||
"mview/css/mview.css",
|
||||
node_type='mview',
|
||||
_=gettext
|
||||
)
|
||||
]
|
||||
|
||||
for submodule in self.submodules:
|
||||
snippets.extend(submodule.csssnippets)
|
||||
@@ -159,6 +159,7 @@ def check_precondition(f):
|
||||
Assumptions:
|
||||
This function will always be used as decorator of a class method.
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
|
||||
@@ -176,14 +177,14 @@ def check_precondition(f):
|
||||
gettext("Connection to the server has been lost!")
|
||||
)
|
||||
self.datlastsysoid = self.manager.db_info[
|
||||
kwargs['did']]['datlastsysoid']
|
||||
kwargs['did']]['datlastsysoid']
|
||||
|
||||
# Set template path for sql scripts
|
||||
self.template_path = self.template_initial + '/' + (
|
||||
self.ppas_template_path(self.manager.version)
|
||||
if self.manager.server_type == 'ppas' else
|
||||
self.pg_template_path(self.manager.version)
|
||||
)
|
||||
)
|
||||
|
||||
ver = self.manager.version
|
||||
if ver >= 90200:
|
||||
@@ -257,14 +258,14 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
node_type = view_blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'},
|
||||
{'type': 'int', 'id': 'did'},
|
||||
{'type': 'int', 'id': 'scid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'vid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'vid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -287,11 +288,11 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
'select_sql': [{'get': 'select_sql'}, {'get': 'select_sql'}],
|
||||
'insert_sql': [{'get': 'insert_sql'}, {'get': 'insert_sql'}],
|
||||
'get_table_vacuum': [
|
||||
{'get': 'get_table_vacuum'},
|
||||
{'get': 'get_table_vacuum'}],
|
||||
{'get': 'get_table_vacuum'},
|
||||
{'get': 'get_table_vacuum'}],
|
||||
'get_toast_table_vacuum': [
|
||||
{'get': 'get_toast_table_vacuum'},
|
||||
{'get': 'get_toast_table_vacuum'}]
|
||||
{'get': 'get_toast_table_vacuum'},
|
||||
{'get': 'get_toast_table_vacuum'}]
|
||||
})
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -336,15 +337,15 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
Fetches all views properties and render into properties tab
|
||||
"""
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/properties.sql']), scid=scid)
|
||||
[self.template_path, 'sql/properties.sql']), scid=scid)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, did, scid):
|
||||
@@ -353,24 +354,24 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
"""
|
||||
res = []
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/properties.sql']), scid=scid)
|
||||
[self.template_path, 'sql/properties.sql']), scid=scid)
|
||||
status, rset = self.conn.execute_2darray(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=rset)
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
scid,
|
||||
row['name'],
|
||||
icon="icon-view"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
scid,
|
||||
row['name'],
|
||||
icon="icon-view"
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
def parse_views_privileges(self, db_privileges):
|
||||
"""
|
||||
@@ -407,13 +408,13 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
"""
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/properties.sql']
|
||||
), vid=vid, datlastsysoid=self.datlastsysoid)
|
||||
), vid=vid, datlastsysoid=self.datlastsysoid)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/acl.sql']), vid=vid)
|
||||
[self.template_path, 'sql/acl.sql']), vid=vid)
|
||||
status, dataclres = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -434,9 +435,9 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
result.update(frmtd_reslt)
|
||||
|
||||
return ajax_response(
|
||||
response=result,
|
||||
status=200
|
||||
)
|
||||
response=result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def formatter(result):
|
||||
@@ -450,7 +451,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
sec_lbls.append({
|
||||
'provider': sec.group(1),
|
||||
'label': sec.group(2)
|
||||
})
|
||||
})
|
||||
|
||||
frmtd_result.update({"seclabels": sec_lbls})
|
||||
return frmtd_result
|
||||
@@ -485,14 +486,14 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/view_id.sql']), data=data)
|
||||
[self.template_path, 'sql/view_id.sql']), data=data)
|
||||
status, view_id = self.conn.execute_scalar(SQL)
|
||||
return jsonify(
|
||||
node=self.blueprint.generate_browser_node(
|
||||
view_id,
|
||||
scid,
|
||||
data['name'],
|
||||
icon="icon-view"
|
||||
view_id,
|
||||
scid,
|
||||
data['name'],
|
||||
icon="icon-view"
|
||||
)
|
||||
)
|
||||
else:
|
||||
@@ -520,7 +521,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/view_id.sql']), data=data)
|
||||
[self.template_path, 'sql/view_id.sql']), data=data)
|
||||
status, res_data = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -530,10 +531,10 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
if vid != view_id:
|
||||
return jsonify(
|
||||
node=self.blueprint.generate_browser_node(
|
||||
view_id,
|
||||
scid,
|
||||
new_view_name,
|
||||
icon="icon-view"
|
||||
view_id,
|
||||
scid,
|
||||
new_view_name,
|
||||
icon="icon-view"
|
||||
)
|
||||
)
|
||||
else:
|
||||
@@ -608,7 +609,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
scid: Schema Id
|
||||
"""
|
||||
SQL = render_template("/".join([self.template_path,
|
||||
'sql/get_schema.sql']), scid=scid)
|
||||
'sql/get_schema.sql']), scid=scid)
|
||||
|
||||
status, schema_name = self.conn.execute_scalar(SQL)
|
||||
|
||||
@@ -631,16 +632,16 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
|
||||
SQL = self.getSQL(gid, sid, data, vid)
|
||||
SQL = SQL.strip('\n')
|
||||
if(SQL):
|
||||
if (SQL):
|
||||
return make_json_response(
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
data=SQL,
|
||||
status=200
|
||||
)
|
||||
else:
|
||||
return make_json_response(
|
||||
data=gettext("-- Nothing changed"),
|
||||
status=200
|
||||
)
|
||||
data=gettext("-- Nothing changed"),
|
||||
status=200
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def parse_privileges(str_privileges, object_type='VIEW'):
|
||||
@@ -653,7 +654,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
'D': 'TRUNCATE',
|
||||
'x': 'REFERENCES',
|
||||
't': 'TRIGGER'
|
||||
}
|
||||
}
|
||||
privileges = []
|
||||
for priv in str_privileges:
|
||||
priv_with_grant = []
|
||||
@@ -661,10 +662,10 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
for privilege in priv['privileges']:
|
||||
if privilege['with_grant']:
|
||||
priv_with_grant.append(
|
||||
db_privileges[privilege['privilege_type']])
|
||||
db_privileges[privilege['privilege_type']])
|
||||
elif privilege['privilege']:
|
||||
priv_without_grant.append(
|
||||
db_privileges[privilege['privilege_type']])
|
||||
db_privileges[privilege['privilege_type']])
|
||||
|
||||
# If we have all acl then just return all
|
||||
if len(priv_with_grant) == len(db_privileges):
|
||||
@@ -675,11 +676,11 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
# Server Level validation
|
||||
if 'grantee' in priv:
|
||||
privileges.append(
|
||||
{
|
||||
'grantee': priv['grantee'] if 'grantee' in priv else '',
|
||||
'with_grant': priv_with_grant,
|
||||
'without_grant': priv_without_grant
|
||||
}
|
||||
{
|
||||
'grantee': priv['grantee'] if 'grantee' in priv else '',
|
||||
'with_grant': priv_with_grant,
|
||||
'without_grant': priv_without_grant
|
||||
}
|
||||
)
|
||||
else:
|
||||
return ''
|
||||
@@ -693,8 +694,8 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
if vid is not None:
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/properties.sql']),
|
||||
vid=vid,
|
||||
datlastsysoid=self.datlastsysoid
|
||||
vid=vid,
|
||||
datlastsysoid=self.datlastsysoid
|
||||
)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
@@ -711,16 +712,16 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
if key in data and data[key] is not None:
|
||||
if 'added' in data[key]:
|
||||
data[key]['added'] = self.parse_privileges(
|
||||
data[key]['added'])
|
||||
data[key]['added'])
|
||||
if 'changed' in data[key]:
|
||||
data[key]['changed'] = self.parse_privileges(
|
||||
data[key]['changed'])
|
||||
data[key]['changed'])
|
||||
if 'deleted' in data[key]:
|
||||
data[key]['deleted'] = self.parse_privileges(
|
||||
data[key]['deleted'])
|
||||
data[key]['deleted'])
|
||||
try:
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/update.sql']), data=data,
|
||||
[self.template_path, 'sql/update.sql']), data=data,
|
||||
o_data=old_data, conn=self.conn)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -741,11 +742,11 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
if 'datacl' in data and data['datacl'] is not None:
|
||||
data['datacl'] = self.parse_privileges(data['datacl'])
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/create.sql']), data=data)
|
||||
[self.template_path, 'sql/create.sql']), data=data)
|
||||
if data['definition']:
|
||||
SQL += "\n"
|
||||
SQL += render_template("/".join(
|
||||
[self.template_path, 'sql/grant.sql']), data=data)
|
||||
[self.template_path, 'sql/grant.sql']), data=data)
|
||||
return SQL
|
||||
|
||||
except Exception as e:
|
||||
@@ -765,7 +766,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
|
||||
self.index_temp_path = 'index'
|
||||
SQL = render_template("/".join([self.index_temp_path,
|
||||
'sql/9.1_plus/column_details.sql']), idx=idx)
|
||||
'sql/9.1_plus/column_details.sql']), idx=idx)
|
||||
status, rset = self.conn.execute_2darray(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=rset)
|
||||
@@ -841,7 +842,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
self.rule_temp_path = 'rules'
|
||||
SQL_data = ''
|
||||
SQL = render_template("/".join(
|
||||
[self.rule_temp_path, 'sql/properties.sql']), tid=vid)
|
||||
[self.rule_temp_path, 'sql/properties.sql']), tid=vid)
|
||||
|
||||
status, data = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
@@ -853,13 +854,13 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
if rule['name'] != '_RETURN':
|
||||
res = []
|
||||
SQL = render_template("/".join(
|
||||
[self.rule_temp_path, 'sql/properties.sql']),
|
||||
[self.rule_temp_path, 'sql/properties.sql']),
|
||||
rid=rule['oid']
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
res = parse_rule_definition(res)
|
||||
SQL = render_template("/".join(
|
||||
[self.rule_temp_path, 'sql/create.sql']),
|
||||
[self.rule_temp_path, 'sql/create.sql']),
|
||||
data=res, display_comments=True)
|
||||
SQL_data += '\n'
|
||||
SQL_data += SQL
|
||||
@@ -888,10 +889,10 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
|
||||
for trigger in data['rows']:
|
||||
SQL = render_template("/".join(
|
||||
[self.trigger_temp_path, 'sql/9.1_plus/properties.sql']),
|
||||
[self.trigger_temp_path, 'sql/9.1_plus/properties.sql']),
|
||||
tid=trigger['oid'],
|
||||
tgrelid=vid
|
||||
)
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
@@ -909,7 +910,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
res_rows = trigger_definition(res_rows)
|
||||
|
||||
SQL = render_template("/".join(
|
||||
[self.trigger_temp_path, 'sql/9.1_plus/create.sql']),
|
||||
[self.trigger_temp_path, 'sql/9.1_plus/create.sql']),
|
||||
data=res_rows, display_comments=True)
|
||||
SQL_data += '\n'
|
||||
SQL_data += SQL
|
||||
@@ -926,7 +927,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
self.index_temp_path = 'index'
|
||||
SQL_data = ''
|
||||
SQL = render_template("/".join(
|
||||
[self.index_temp_path, 'sql/9.1_plus/properties.sql']), tid=vid)
|
||||
[self.index_temp_path, 'sql/9.1_plus/properties.sql']), tid=vid)
|
||||
status, data = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=data)
|
||||
@@ -934,10 +935,10 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
for index in data['rows']:
|
||||
res = []
|
||||
SQL = render_template("/".join(
|
||||
[self.index_temp_path, 'sql/9.1_plus/properties.sql']),
|
||||
[self.index_temp_path, 'sql/9.1_plus/properties.sql']),
|
||||
idx=index['oid'],
|
||||
tid=vid
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
data = dict(res['rows'][0])
|
||||
@@ -949,7 +950,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
data = self.get_index_column_details(index['oid'], data)
|
||||
|
||||
SQL = render_template("/".join(
|
||||
[self.index_temp_path, 'sql/9.1_plus/create.sql']),
|
||||
[self.index_temp_path, 'sql/9.1_plus/create.sql']),
|
||||
data=data, display_comments=True)
|
||||
SQL_data += '\n'
|
||||
SQL_data += SQL
|
||||
@@ -963,9 +964,9 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
|
||||
SQL_data = ''
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/properties.sql']),
|
||||
vid=vid,
|
||||
datlastsysoid=self.datlastsysoid
|
||||
[self.template_path, 'sql/properties.sql']),
|
||||
vid=vid,
|
||||
datlastsysoid=self.datlastsysoid
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
@@ -976,7 +977,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
|
||||
# Fetch all privileges for view
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/acl.sql']), vid=vid)
|
||||
[self.template_path, 'sql/acl.sql']), vid=vid)
|
||||
status, dataclres = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -993,14 +994,14 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
result['datacl'] = self.parse_privileges(result['datacl'])
|
||||
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/create.sql']),
|
||||
data=result,
|
||||
conn=self.conn,
|
||||
display_comments=True
|
||||
)
|
||||
[self.template_path, 'sql/create.sql']),
|
||||
data=result,
|
||||
conn=self.conn,
|
||||
display_comments=True
|
||||
)
|
||||
SQL += "\n"
|
||||
SQL += render_template("/".join(
|
||||
[self.template_path, 'sql/grant.sql']), data=result)
|
||||
[self.template_path, 'sql/grant.sql']), data=result)
|
||||
|
||||
SQL_data += SQL
|
||||
SQL_data += self.get_rule_sql(vid)
|
||||
@@ -1018,20 +1019,20 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
try:
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'sql/get_tblspc.sql'])
|
||||
)
|
||||
)
|
||||
status, rset = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
{'label': row['spcname'], 'value': row['spcname']}
|
||||
)
|
||||
{'label': row['spcname'], 'value': row['spcname']}
|
||||
)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -1052,7 +1053,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependencies(self, gid, sid, did, scid, vid):
|
||||
@@ -1070,7 +1071,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def select_sql(self, gid, sid, did, scid, vid):
|
||||
@@ -1273,8 +1274,8 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
if vid is not None:
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/properties.sql']),
|
||||
vid=vid,
|
||||
datlastsysoid=self.datlastsysoid
|
||||
vid=vid,
|
||||
datlastsysoid=self.datlastsysoid
|
||||
)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
@@ -1301,65 +1302,65 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
data['vacuum_data']['reset'].append(item)
|
||||
else:
|
||||
if (old_data[item['name']] is None or
|
||||
(float(old_data[item['name']]) != float(item['value']))):
|
||||
(float(old_data[item['name']]) != float(item['value']))):
|
||||
data['vacuum_data']['changed'].append(item)
|
||||
|
||||
if ('autovacuum_enabled' in data and
|
||||
old_data['autovacuum_enabled'] is not None):
|
||||
old_data['autovacuum_enabled'] is not None):
|
||||
if (data['autovacuum_enabled'] !=
|
||||
old_data['autovacuum_enabled']):
|
||||
old_data['autovacuum_enabled']):
|
||||
data['vacuum_data']['changed'].append(
|
||||
{'name': 'autovacuum_enabled',
|
||||
'value': data['autovacuum_enabled']})
|
||||
elif ('autovacuum_enabled' in data and 'autovacuum_custom' in data and
|
||||
old_data['autovacuum_enabled'] is None and data['autovacuum_custom']):
|
||||
data['vacuum_data']['changed'].append(
|
||||
{'name': 'autovacuum_enabled',
|
||||
'value': data['autovacuum_enabled']})
|
||||
old_data['autovacuum_enabled'] is None and data['autovacuum_custom']):
|
||||
data['vacuum_data']['changed'].append(
|
||||
{'name': 'autovacuum_enabled',
|
||||
'value': data['autovacuum_enabled']})
|
||||
|
||||
# toast autovacuum: separate list of changed and reset data
|
||||
if ('vacuum_toast' in data):
|
||||
if ('changed' in data['vacuum_toast']):
|
||||
for item in data['vacuum_toast']['changed']:
|
||||
if 'value' in item.keys():
|
||||
toast_key = 'toast_'+item['name']
|
||||
item['name'] = 'toast.'+item['name']
|
||||
toast_key = 'toast_' + item['name']
|
||||
item['name'] = 'toast.' + item['name']
|
||||
if item['value'] is None:
|
||||
if old_data[toast_key] != item['value']:
|
||||
data['vacuum_data']['reset'].append(item)
|
||||
else:
|
||||
if (old_data[toast_key] is None or
|
||||
(float(old_data[toast_key]) != float(item['value']))):
|
||||
(float(old_data[toast_key]) != float(item['value']))):
|
||||
data['vacuum_data']['changed'].append(item)
|
||||
|
||||
if ('toast_autovacuum_enabled' in data and
|
||||
old_data['toast_autovacuum_enabled'] is not None):
|
||||
old_data['toast_autovacuum_enabled'] is not None):
|
||||
if (data['toast_autovacuum_enabled'] !=
|
||||
old_data['toast_autovacuum_enabled']):
|
||||
old_data['toast_autovacuum_enabled']):
|
||||
data['vacuum_data']['changed'].append(
|
||||
{'name': 'toast.autovacuum_enabled',
|
||||
'value': data['toast_autovacuum_enabled']})
|
||||
elif ('toast_autovacuum_enabled' in data and 'toast_autovacuum' in data and
|
||||
old_data['toast_autovacuum_enabled'] is None and data['toast_autovacuum']):
|
||||
data['vacuum_data']['changed'].append(
|
||||
{'name': 'toast.autovacuum_enabled',
|
||||
'value': data['toast_autovacuum_enabled']})
|
||||
old_data['toast_autovacuum_enabled'] is None and data['toast_autovacuum']):
|
||||
data['vacuum_data']['changed'].append(
|
||||
{'name': 'toast.autovacuum_enabled',
|
||||
'value': data['toast_autovacuum_enabled']})
|
||||
|
||||
key = 'datacl'
|
||||
if key in data and data[key] is not None:
|
||||
if 'added' in data[key]:
|
||||
data[key]['added'] = self.parse_privileges(
|
||||
data[key]['added'])
|
||||
data[key]['added'])
|
||||
if 'changed' in data[key]:
|
||||
data[key]['changed'] = self.parse_privileges(
|
||||
data[key]['changed'])
|
||||
data[key]['changed'])
|
||||
if 'deleted' in data[key]:
|
||||
data[key]['deleted'] = self.parse_privileges(
|
||||
data[key]['deleted'])
|
||||
data[key]['deleted'])
|
||||
|
||||
try:
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/update.sql']), data=data,
|
||||
[self.template_path, 'sql/update.sql']), data=data,
|
||||
o_data=old_data, conn=self.conn)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
@@ -1382,7 +1383,7 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
if 'value' in item.keys() and
|
||||
item['value'] is not None]
|
||||
vacuum_toast = [
|
||||
{'name': 'toast.'+item['name'], 'value':item['value']}
|
||||
{'name': 'toast.' + item['name'], 'value': item['value']}
|
||||
for item in data['vacuum_toast']
|
||||
if 'value' in item.keys() and item['value'] is not None]
|
||||
|
||||
@@ -1390,37 +1391,37 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
if ('autovacuum_custom' in data and data['autovacuum_custom']):
|
||||
vacuum_table.append(
|
||||
{
|
||||
'name': 'autovacuum_enabled',
|
||||
'value': str(data['autovacuum_enabled'])
|
||||
'name': 'autovacuum_enabled',
|
||||
'value': str(data['autovacuum_enabled'])
|
||||
}
|
||||
)
|
||||
if ('toast_autovacuum' in data and data['toast_autovacuum']):
|
||||
vacuum_table.append(
|
||||
{
|
||||
'name': 'toast.autovacuum_enabled',
|
||||
'value': str(data['toast_autovacuum_enabled'])
|
||||
'name': 'toast.autovacuum_enabled',
|
||||
'value': str(data['toast_autovacuum_enabled'])
|
||||
}
|
||||
)
|
||||
|
||||
# add vacuum_toast dict to vacuum_data only if
|
||||
# table & toast's custom autovacuum is enabled
|
||||
data['vacuum_data'] = (vacuum_table if (
|
||||
'autovacuum_custom' in data and
|
||||
data['autovacuum_custom'] is True
|
||||
) else []) + (
|
||||
vacuum_toast if (
|
||||
'toast_autovacuum' in data and
|
||||
data['toast_autovacuum'] is True
|
||||
) else [])
|
||||
'autovacuum_custom' in data and
|
||||
data['autovacuum_custom'] is True
|
||||
) else []) + (
|
||||
vacuum_toast if (
|
||||
'toast_autovacuum' in data and
|
||||
data['toast_autovacuum'] is True
|
||||
) else [])
|
||||
|
||||
if 'datacl' in data and data['datacl'] is not None:
|
||||
data['datacl'] = self.parse_privileges(data['datacl'])
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/create.sql']), data=data)
|
||||
[self.template_path, 'sql/create.sql']), data=data)
|
||||
if data['definition']:
|
||||
SQL += "\n"
|
||||
SQL += render_template("/".join(
|
||||
[self.template_path, 'sql/grant.sql']), data=data)
|
||||
[self.template_path, 'sql/grant.sql']), data=data)
|
||||
return SQL
|
||||
|
||||
except Exception as e:
|
||||
@@ -1434,9 +1435,9 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
|
||||
SQL_data = ''
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/properties.sql']),
|
||||
vid=vid,
|
||||
datlastsysoid=self.datlastsysoid
|
||||
[self.template_path, 'sql/properties.sql']),
|
||||
vid=vid,
|
||||
datlastsysoid=self.datlastsysoid
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
@@ -1459,20 +1460,20 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
vacuum_table = [item for item in result['vacuum_table']
|
||||
if 'value' in item.keys() and item['value'] is not None]
|
||||
vacuum_toast = [
|
||||
{'name': 'toast.'+item['name'], 'value':item['value']}
|
||||
{'name': 'toast.' + item['name'], 'value': item['value']}
|
||||
for item in result['vacuum_toast'] if 'value' in item.keys() and item['value'] is not None]
|
||||
|
||||
# add vacuum_toast dict to vacuum_data only if
|
||||
# toast's autovacuum is enabled
|
||||
if ('toast_autovacuum_enabled' in result and
|
||||
result['toast_autovacuum_enabled'] is True):
|
||||
result['toast_autovacuum_enabled'] is True):
|
||||
result['vacuum_data'] = vacuum_table + vacuum_toast
|
||||
else:
|
||||
result['vacuum_data'] = vacuum_table
|
||||
|
||||
# Fetch all privileges for view
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/acl.sql']), vid=vid)
|
||||
[self.template_path, 'sql/acl.sql']), vid=vid)
|
||||
status, dataclres = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -1489,14 +1490,14 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
result['datacl'] = self.parse_privileges(result['datacl'])
|
||||
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/create.sql']),
|
||||
data=result,
|
||||
conn=self.conn,
|
||||
display_comments=True
|
||||
)
|
||||
[self.template_path, 'sql/create.sql']),
|
||||
data=result,
|
||||
conn=self.conn,
|
||||
display_comments=True
|
||||
)
|
||||
SQL += "\n"
|
||||
SQL += render_template("/".join(
|
||||
[self.template_path, 'sql/grant.sql']), data=result)
|
||||
[self.template_path, 'sql/grant.sql']), data=result)
|
||||
|
||||
SQL_data += SQL
|
||||
SQL_data += self.get_rule_sql(vid)
|
||||
@@ -1518,9 +1519,9 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
|
||||
res = self.get_vacuum_table_settings(self.conn)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def get_toast_table_vacuum(self, gid, sid, did, scid):
|
||||
@@ -1535,9 +1536,9 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
res = self.get_vacuum_toast_settings(self.conn)
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, scid, vid):
|
||||
@@ -1547,13 +1548,13 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
"""
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/properties.sql']
|
||||
), vid=vid, datlastsysoid=self.datlastsysoid)
|
||||
), vid=vid, datlastsysoid=self.datlastsysoid)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/acl.sql']), vid=vid)
|
||||
[self.template_path, 'sql/acl.sql']), vid=vid)
|
||||
status, dataclres = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -1579,9 +1580,9 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
self.conn, result, 'toast')
|
||||
|
||||
return ajax_response(
|
||||
response=result,
|
||||
status=200
|
||||
)
|
||||
response=result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def refresh_data(self, gid, sid, did, scid, vid):
|
||||
@@ -1600,7 +1601,7 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
|
||||
# Fetch view name by view id
|
||||
SQL = render_template("/".join(
|
||||
[self.template_path, 'sql/get_view_name.sql']), vid=vid)
|
||||
[self.template_path, 'sql/get_view_name.sql']), vid=vid)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -1608,10 +1609,10 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
# Refresh view
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'sql/refresh.sql']),
|
||||
name=res['rows'][0]['name'],
|
||||
nspname=res['rows'][0]['schema'],
|
||||
is_concurrent=is_concurrent,
|
||||
with_data=with_data
|
||||
name=res['rows'][0]['name'],
|
||||
nspname=res['rows'][0]['schema'],
|
||||
is_concurrent=is_concurrent,
|
||||
with_data=with_data
|
||||
)
|
||||
status, res_data = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
@@ -1631,5 +1632,6 @@ class MViewNode(ViewNode, VacuumSettings):
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
|
||||
ViewNode.register_node_view(view_blueprint)
|
||||
MViewNode.register_node_view(mview_blueprint)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
"""Database helper utilities"""
|
||||
|
||||
|
||||
def parse_sec_labels_from_db(db_sec_labels):
|
||||
"""
|
||||
Function to format the output for security label.
|
||||
@@ -29,7 +30,7 @@ def parse_sec_labels_from_db(db_sec_labels):
|
||||
sec_lbls.append({
|
||||
'provider': sec.group(1),
|
||||
'label': sec.group(2)
|
||||
})
|
||||
})
|
||||
|
||||
return {"seclabels": sec_lbls}
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ from pgadmin.browser.server_groups.servers.types import ServerType
|
||||
|
||||
|
||||
class PPAS(ServerType):
|
||||
|
||||
def instanceOf(self, ver):
|
||||
return ver.startswith("EnterpriseDB")
|
||||
|
||||
|
||||
# Default Server Type
|
||||
PPAS('ppas', gettext("EDB Advanced Server"), 2)
|
||||
|
||||
@@ -96,6 +96,7 @@ class ResourceGroupModule(CollectionNodeModule):
|
||||
"""
|
||||
return servers.ServerModule.NODE_TYPE
|
||||
|
||||
|
||||
blueprint = ResourceGroupModule(__name__)
|
||||
|
||||
|
||||
@@ -153,12 +154,12 @@ class ResourceGroupView(NodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'rg_id'}
|
||||
]
|
||||
{'type': 'int', 'id': 'rg_id'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -193,12 +194,12 @@ class ResourceGroupView(NodeView):
|
||||
Override this property for your own logic.
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"resource_groups/js/resource_groups.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"resource_groups/js/resource_groups.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def check_precondition(f):
|
||||
"""
|
||||
@@ -206,6 +207,7 @@ class ResourceGroupView(NodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -218,12 +220,13 @@ class ResourceGroupView(NodeView):
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
self.template_path = 'resource_groups/sql'
|
||||
return f(*args, **kwargs)
|
||||
|
||||
return wrap
|
||||
|
||||
@check_precondition
|
||||
@@ -241,9 +244,9 @@ class ResourceGroupView(NodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid):
|
||||
@@ -263,17 +266,17 @@ class ResourceGroupView(NodeView):
|
||||
|
||||
for row in result['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
sid,
|
||||
row['name'],
|
||||
icon="icon-resource_group"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
sid,
|
||||
row['name'],
|
||||
icon="icon-resource_group"
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, rg_id):
|
||||
@@ -292,9 +295,9 @@ class ResourceGroupView(NodeView):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def create(self, gid, sid):
|
||||
@@ -373,7 +376,7 @@ class ResourceGroupView(NodeView):
|
||||
sql = render_template("/".join([self.template_path, 'properties.sql']), rgid=rg_id)
|
||||
status, res = self.conn.execute_dict(sql)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return internal_server_error(errormsg=res)
|
||||
old_data = res['rows'][0]
|
||||
for arg in required_args:
|
||||
if arg not in data:
|
||||
@@ -466,14 +469,14 @@ class ResourceGroupView(NodeView):
|
||||
sql = self.get_sql(data, rg_id)
|
||||
if sql and sql.strip('\n') and sql.strip(' '):
|
||||
return make_json_response(
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
data=sql,
|
||||
status=200
|
||||
)
|
||||
else:
|
||||
return make_json_response(
|
||||
data='-- Modified SQL --',
|
||||
status=200
|
||||
)
|
||||
data='-- Modified SQL --',
|
||||
status=200
|
||||
)
|
||||
|
||||
def get_sql(self, data, rg_id=None):
|
||||
"""
|
||||
@@ -503,7 +506,7 @@ class ResourceGroupView(NodeView):
|
||||
name_changed = True
|
||||
sql = render_template("/".join([self.template_path, 'update.sql']),
|
||||
oldname=old_data['name'], newname=data['name'], conn=self.conn)
|
||||
if (data['cpu_rate_limit'] != old_data['cpu_rate_limit'])\
|
||||
if (data['cpu_rate_limit'] != old_data['cpu_rate_limit']) \
|
||||
or data['dirty_rate_limit'] != old_data['dirty_rate_limit']:
|
||||
if name_changed:
|
||||
sql += "\n-- Following query will be executed in a separate transaction\n"
|
||||
@@ -544,4 +547,5 @@ class ResourceGroupView(NodeView):
|
||||
|
||||
return ajax_response(response=sql)
|
||||
|
||||
|
||||
ResourceGroupView.register_node_view(blueprint)
|
||||
|
||||
@@ -63,11 +63,11 @@ class RoleModule(CollectionNodeModule):
|
||||
Returns a snippet of css to include in the page
|
||||
"""
|
||||
snippets = [
|
||||
render_template(
|
||||
"browser/css/collection.css",
|
||||
node_type=self.node_type
|
||||
),
|
||||
render_template("role/css/role.css")]
|
||||
render_template(
|
||||
"browser/css/collection.css",
|
||||
node_type=self.node_type
|
||||
),
|
||||
render_template("role/css/role.css")]
|
||||
|
||||
for submodule in self.submodules:
|
||||
snippets.extend(submodule.csssnippets)
|
||||
@@ -82,12 +82,12 @@ class RoleView(PGChildNodeView):
|
||||
node_type = 'role'
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'rid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'rid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -103,7 +103,7 @@ class RoleView(PGChildNodeView):
|
||||
'module.js': [{}, {}, {'get': 'module_js'}],
|
||||
'vopts': [{}, {'get': 'voptions'}],
|
||||
'variables': [{'get': 'variables'}],
|
||||
})
|
||||
})
|
||||
|
||||
def validate_request(f):
|
||||
@wraps(f)
|
||||
@@ -120,11 +120,11 @@ class RoleView(PGChildNodeView):
|
||||
|
||||
val = req[key]
|
||||
if key in [
|
||||
u'rolcanlogin', u'rolsuper', u'rolcreatedb',
|
||||
u'rolcreaterole', u'rolinherit', u'rolreplication',
|
||||
u'rolcatupdate', u'variables', u'rolmembership',
|
||||
u'seclabels'
|
||||
]:
|
||||
u'rolcanlogin', u'rolsuper', u'rolcreatedb',
|
||||
u'rolcreaterole', u'rolinherit', u'rolreplication',
|
||||
u'rolcatupdate', u'variables', u'rolmembership',
|
||||
u'seclabels'
|
||||
]:
|
||||
data[key] = json.loads(val)
|
||||
else:
|
||||
data[key] = val
|
||||
@@ -132,8 +132,8 @@ class RoleView(PGChildNodeView):
|
||||
if u'rid' not in kwargs or kwargs['rid'] == -1:
|
||||
if u'rolname' not in data:
|
||||
return precondition_required(
|
||||
_("Name must be specified.")
|
||||
)
|
||||
_("Name must be specified.")
|
||||
)
|
||||
|
||||
if u'rolvaliduntil' in data:
|
||||
# Make date explicit so that it works with every
|
||||
@@ -149,15 +149,15 @@ class RoleView(PGChildNodeView):
|
||||
except Exception as e:
|
||||
return precondition_required(
|
||||
_("Date format is invalid.")
|
||||
)
|
||||
)
|
||||
|
||||
if u'rolconnlimit' in data:
|
||||
if data[u'rolconnlimit'] is not None:
|
||||
data[u'rolconnlimit'] = int(data[u'rolconnlimit'])
|
||||
if type(data[u'rolconnlimit']) != int or data[u'rolconnlimit'] < -1:
|
||||
return precondition_required(
|
||||
_("Connection limit must be an integer value or equal to -1.")
|
||||
)
|
||||
_("Connection limit must be an integer value or equal to -1.")
|
||||
)
|
||||
|
||||
if u'rolmembership' in data:
|
||||
if u'rid' not in kwargs or kwargs['rid'] == -1:
|
||||
@@ -225,7 +225,7 @@ rolmembership:{
|
||||
|
||||
for r in roles:
|
||||
if (type(r) != dict or u'role' not in r or
|
||||
u'admin' not in r):
|
||||
u'admin' not in r):
|
||||
return precondition_required(msg)
|
||||
|
||||
if r[u'admin']:
|
||||
@@ -245,7 +245,7 @@ rolmembership:{
|
||||
|
||||
data[u'revoked'].append(r[u'role'])
|
||||
|
||||
if u'changed' in data[u'rolmembership']:
|
||||
if u'changed' in data[u'rolmembership']:
|
||||
roles = (data[u'rolmembership'])[u'changed']
|
||||
|
||||
if type(roles) != list:
|
||||
@@ -253,7 +253,7 @@ rolmembership:{
|
||||
|
||||
for r in roles:
|
||||
if (type(r) != dict or u'role' not in r or
|
||||
u'admin' not in r):
|
||||
u'admin' not in r):
|
||||
return precondition_required(msg)
|
||||
|
||||
if not r[u'admin']:
|
||||
@@ -278,7 +278,7 @@ seclabels:[{
|
||||
|
||||
for s in data[u'seclabels']:
|
||||
if (type(s) != dict or u'provider' not in s or
|
||||
u'label' not in s):
|
||||
u'label' not in s):
|
||||
return precondition_required(msg)
|
||||
else:
|
||||
msg = _("""
|
||||
@@ -311,13 +311,12 @@ seclabels:{
|
||||
if u'added' in seclabels:
|
||||
new_seclabels = seclabels[u'added']
|
||||
|
||||
|
||||
if type(new_seclabels) != list:
|
||||
return precondition_required(msg)
|
||||
|
||||
for s in new_seclabels:
|
||||
if (type(s) != dict or u'provider' not in s or
|
||||
u'label' not in s):
|
||||
u'label' not in s):
|
||||
return precondition_required(msg)
|
||||
|
||||
if u'deleted' in seclabels:
|
||||
@@ -338,7 +337,7 @@ seclabels:{
|
||||
|
||||
for s in changed_seclabels:
|
||||
if (type(s) != dict or u'provider' not in s
|
||||
and u'label' not in s):
|
||||
and u'label' not in s):
|
||||
return precondition_required(msg)
|
||||
|
||||
if u'variables' in data:
|
||||
@@ -358,8 +357,8 @@ variables:[{
|
||||
|
||||
for r in data[u'variables']:
|
||||
if (type(r) != dict or
|
||||
u'name' not in r or
|
||||
u'value' not in r):
|
||||
u'name' not in r or
|
||||
u'value' not in r):
|
||||
return precondition_required(msg)
|
||||
else:
|
||||
msg = _("""
|
||||
@@ -400,7 +399,7 @@ rolmembership:{
|
||||
|
||||
for v in new_vars:
|
||||
if (type(v) != dict or u'name' not in v or
|
||||
u'value' not in v):
|
||||
u'value' not in v):
|
||||
return precondition_required(msg)
|
||||
|
||||
if u'deleted' in variables:
|
||||
@@ -413,7 +412,7 @@ rolmembership:{
|
||||
if type(v) != dict or u'name' not in v:
|
||||
return precondition_required(msg)
|
||||
|
||||
if u'changed' in variables:
|
||||
if u'changed' in variables:
|
||||
new_vars = variables[u'changed']
|
||||
|
||||
if type(new_vars) != list:
|
||||
@@ -421,12 +420,13 @@ rolmembership:{
|
||||
|
||||
for v in new_vars:
|
||||
if (type(v) != dict or u'name' not in v or
|
||||
u'value' not in v):
|
||||
u'value' not in v):
|
||||
return precondition_required(msg)
|
||||
|
||||
self.request = data
|
||||
|
||||
return f(self, **kwargs)
|
||||
|
||||
return wrap
|
||||
|
||||
def check_precondition(action=None):
|
||||
@@ -437,14 +437,15 @@ rolmembership:{
|
||||
also attach manager, conn (maintenance connection for the server) as
|
||||
properties of the instance.
|
||||
"""
|
||||
|
||||
def wrap(f):
|
||||
@wraps(f)
|
||||
def wrapped(self, **kwargs):
|
||||
self.manager = get_driver(
|
||||
PG_DEFAULT_DRIVER
|
||||
).connection_manager(
|
||||
kwargs['sid']
|
||||
)
|
||||
PG_DEFAULT_DRIVER
|
||||
).connection_manager(
|
||||
kwargs['sid']
|
||||
)
|
||||
self.conn = self.manager.connection()
|
||||
|
||||
driver = get_driver(PG_DEFAULT_DRIVER)
|
||||
@@ -452,30 +453,30 @@ rolmembership:{
|
||||
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
_("Connection to the server has been lost!")
|
||||
)
|
||||
_("Connection to the server has been lost!")
|
||||
)
|
||||
|
||||
ver = self.manager.version
|
||||
|
||||
self.sql_path = 'role/sql/{0}/'.format(
|
||||
'post9_4' if ver >= 90500 else \
|
||||
'post9_1' if ver >= 90200 else \
|
||||
'post9_0' if ver >= 90100 else \
|
||||
'post8_4'
|
||||
)
|
||||
'post9_1' if ver >= 90200 else \
|
||||
'post9_0' if ver >= 90100 else \
|
||||
'post8_4'
|
||||
)
|
||||
|
||||
self.alterKeys = [
|
||||
u'rolcanlogin', u'rolsuper', u'rolcreatedb',
|
||||
u'rolcreaterole', u'rolinherit', u'rolreplication',
|
||||
u'rolconnlimit', u'rolvaliduntil', u'rolpassword'
|
||||
] if ver >= 90200 else [
|
||||
u'rolcanlogin', u'rolsuper', u'rolcreatedb',
|
||||
u'rolcreaterole', u'rolinherit', u'rolconnlimit',
|
||||
u'rolvaliduntil', u'rolpassword'
|
||||
]
|
||||
u'rolcanlogin', u'rolsuper', u'rolcreatedb',
|
||||
u'rolcreaterole', u'rolinherit', u'rolreplication',
|
||||
u'rolconnlimit', u'rolvaliduntil', u'rolpassword'
|
||||
] if ver >= 90200 else [
|
||||
u'rolcanlogin', u'rolsuper', u'rolcreatedb',
|
||||
u'rolcreaterole', u'rolinherit', u'rolconnlimit',
|
||||
u'rolvaliduntil', u'rolpassword'
|
||||
]
|
||||
|
||||
check_permission=False
|
||||
fetch_name=False
|
||||
check_permission = False
|
||||
fetch_name = False
|
||||
forbidden_msg = None
|
||||
|
||||
if action in ['drop', 'update']:
|
||||
@@ -483,19 +484,19 @@ rolmembership:{
|
||||
fetch_name = True
|
||||
if action == 'drop':
|
||||
forbidden_msg = _(
|
||||
"The current user does not have permission to drop the role."
|
||||
)
|
||||
"The current user does not have permission to drop the role."
|
||||
)
|
||||
else:
|
||||
forbidden_msg = _(
|
||||
"The current user does not have permission to update the role."
|
||||
)
|
||||
"The current user does not have permission to update the role."
|
||||
)
|
||||
elif action == 'create':
|
||||
check_permission = True
|
||||
forbidden_msg = _(
|
||||
"The current user does not have permission to create the role."
|
||||
)
|
||||
"The current user does not have permission to create the role."
|
||||
)
|
||||
elif (action == 'msql' and
|
||||
'rid' in kwargs and kwargs['rid'] != -1):
|
||||
'rid' in kwargs and kwargs['rid'] != -1):
|
||||
fetch_name = True
|
||||
|
||||
if check_permission:
|
||||
@@ -504,31 +505,31 @@ rolmembership:{
|
||||
if not user['is_superuser'] and \
|
||||
not user['can_create_role']:
|
||||
if (action != 'update' or
|
||||
'rid' in kwargs and kwargs['rid'] != -1 and
|
||||
user['id'] != kwargs['rid']):
|
||||
'rid' in kwargs and kwargs['rid'] != -1 and
|
||||
user['id'] != kwargs['rid']):
|
||||
return forbidden(forbidden_msg)
|
||||
|
||||
if fetch_name:
|
||||
|
||||
status, res = self.conn.execute_dict(
|
||||
render_template(
|
||||
self.sql_path + 'permission.sql',
|
||||
rid=kwargs['rid'],
|
||||
conn=self.conn
|
||||
)
|
||||
)
|
||||
render_template(
|
||||
self.sql_path + 'permission.sql',
|
||||
rid=kwargs['rid'],
|
||||
conn=self.conn
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_(
|
||||
"Error retrieving the role information.\n{0}"
|
||||
).format(res)
|
||||
)
|
||||
_(
|
||||
"Error retrieving the role information.\n{0}"
|
||||
).format(res)
|
||||
)
|
||||
|
||||
if len(res['rows']) == 0:
|
||||
return gone(
|
||||
_("Couldn't find the role on the database server.")
|
||||
)
|
||||
_("Couldn't find the role on the database server.")
|
||||
)
|
||||
|
||||
row = res['rows'][0]
|
||||
|
||||
@@ -538,61 +539,63 @@ rolmembership:{
|
||||
self.rolSuper = row['rolsuper']
|
||||
|
||||
return f(self, **kwargs)
|
||||
|
||||
return wrapped
|
||||
|
||||
return wrap
|
||||
|
||||
@check_precondition(action='list')
|
||||
def list(self, gid, sid):
|
||||
status, res = self.conn.execute_dict(
|
||||
render_template(
|
||||
self.sql_path + 'properties.sql'
|
||||
)
|
||||
)
|
||||
render_template(
|
||||
self.sql_path + 'properties.sql'
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_(
|
||||
"Error retrieving roles from the database server.\n{0}"
|
||||
).format(res)
|
||||
)
|
||||
_(
|
||||
"Error retrieving roles from the database server.\n{0}"
|
||||
).format(res)
|
||||
)
|
||||
|
||||
self.transform(res)
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition(action='nodes')
|
||||
def nodes(self, gid, sid):
|
||||
|
||||
status, rset = self.conn.execute_2darray(
|
||||
render_template(self.sql_path + 'nodes.sql')
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_(
|
||||
"Error fetching role information from the database server.\n{0}"
|
||||
).format(rset)
|
||||
)
|
||||
_(
|
||||
"Error fetching role information from the database server.\n{0}"
|
||||
).format(rset)
|
||||
)
|
||||
|
||||
res = []
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'], sid,
|
||||
row['rolname'],
|
||||
'icon-role' if row['rolcanlogin'] else 'icon-group',
|
||||
can_login=row['rolcanlogin'],
|
||||
is_superuser=row['rolsuper']
|
||||
)
|
||||
)
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'], sid,
|
||||
row['rolname'],
|
||||
'icon-role' if row['rolcanlogin'] else 'icon-group',
|
||||
can_login=row['rolcanlogin'],
|
||||
is_superuser=row['rolsuper']
|
||||
)
|
||||
)
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition(action='node')
|
||||
def node(self, gid, sid, rid):
|
||||
@@ -601,27 +604,27 @@ rolmembership:{
|
||||
render_template(
|
||||
self.sql_path + 'nodes.sql',
|
||||
rid=rid
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_(
|
||||
"Error fetching role information from the database server.\n{0}"
|
||||
).format(rset)
|
||||
)
|
||||
_(
|
||||
"Error fetching role information from the database server.\n{0}"
|
||||
).format(rset)
|
||||
)
|
||||
|
||||
for row in rset['rows']:
|
||||
return make_json_response(
|
||||
data=self.blueprint.generate_browser_node(
|
||||
row['oid'], sid,
|
||||
row['rolname'],
|
||||
'icon-role' if row['rolcanlogin'] else 'icon-group',
|
||||
can_login=row['rolcanlogin'],
|
||||
is_superuser=row['rolsuper']
|
||||
),
|
||||
status=200
|
||||
)
|
||||
data=self.blueprint.generate_browser_node(
|
||||
row['oid'], sid,
|
||||
row['rolname'],
|
||||
'icon-role' if row['rolcanlogin'] else 'icon-group',
|
||||
can_login=row['rolcanlogin'],
|
||||
is_superuser=row['rolsuper']
|
||||
),
|
||||
status=200
|
||||
)
|
||||
|
||||
return gone(_("Could not find the role information."))
|
||||
|
||||
@@ -635,13 +638,13 @@ rolmembership:{
|
||||
res.append({
|
||||
'role': role.group(2),
|
||||
'admin': True if role.group(1) == '1' else False
|
||||
})
|
||||
})
|
||||
row['rolmembership'] = res
|
||||
row['rolvaliduntil'] = row['rolvaliduntil'].isoformat() \
|
||||
if isinstance(
|
||||
row['rolvaliduntil'],
|
||||
(datetime.date, datetime.datetime)
|
||||
) else None
|
||||
if isinstance(
|
||||
row['rolvaliduntil'],
|
||||
(datetime.date, datetime.datetime)
|
||||
) else None
|
||||
if 'seclabels' in row and row['seclabels'] is not None:
|
||||
res = []
|
||||
for sec in row['seclabels']:
|
||||
@@ -649,67 +652,67 @@ rolmembership:{
|
||||
res.append({
|
||||
'provider': sec.group(1),
|
||||
'label': sec.group(2)
|
||||
})
|
||||
})
|
||||
|
||||
@check_precondition(action='properties')
|
||||
def properties(self, gid, sid, rid):
|
||||
|
||||
status, res = self.conn.execute_dict(
|
||||
render_template(
|
||||
self.sql_path + 'properties.sql',
|
||||
rid=rid
|
||||
)
|
||||
)
|
||||
render_template(
|
||||
self.sql_path + 'properties.sql',
|
||||
rid=rid
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_(
|
||||
"Error retrieving roles from the database server.\n{0}"
|
||||
).format(res)
|
||||
)
|
||||
_(
|
||||
"Error retrieving roles from the database server.\n{0}"
|
||||
).format(res)
|
||||
)
|
||||
|
||||
self.transform(res)
|
||||
if len(res['rows']) == 0:
|
||||
return gone(_("Could not find the role information."))
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition(action='drop')
|
||||
def drop(self, gid, sid, rid):
|
||||
|
||||
status, res = self.conn.execute_2darray(
|
||||
"DROP ROLE {0};".format(self.qtIdent(self.conn, self.role))
|
||||
)
|
||||
"DROP ROLE {0};".format(self.qtIdent(self.conn, self.role))
|
||||
)
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_("Couldn't drop the role.\n{0}").format(res)
|
||||
)
|
||||
_("Couldn't drop the role.\n{0}").format(res)
|
||||
)
|
||||
|
||||
return success_return()
|
||||
|
||||
@check_precondition()
|
||||
def sql(self, gid, sid, rid):
|
||||
status, res = self.conn.execute_scalar(
|
||||
render_template(
|
||||
self.sql_path + 'sql.sql'
|
||||
),
|
||||
dict({'rid':rid})
|
||||
)
|
||||
render_template(
|
||||
self.sql_path + 'sql.sql'
|
||||
),
|
||||
dict({'rid': rid})
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_("Could not generate reversed engineered Query for the role.\n{0}").format(
|
||||
res
|
||||
)
|
||||
)
|
||||
_("Could not generate reversed engineered Query for the role.\n{0}").format(
|
||||
res
|
||||
)
|
||||
)
|
||||
|
||||
if res is None:
|
||||
return gone(
|
||||
_("Could not generate reversed engineered Query for the role.")
|
||||
)
|
||||
_("Could not generate reversed engineered Query for the role.")
|
||||
)
|
||||
|
||||
return ajax_response(response=res.strip('\n'))
|
||||
|
||||
@@ -718,51 +721,50 @@ rolmembership:{
|
||||
def create(self, gid, sid):
|
||||
|
||||
sql = render_template(
|
||||
self.sql_path + 'create.sql',
|
||||
data=self.request,
|
||||
dummy=False,
|
||||
conn=self.conn
|
||||
)
|
||||
self.sql_path + 'create.sql',
|
||||
data=self.request,
|
||||
dummy=False,
|
||||
conn=self.conn
|
||||
)
|
||||
|
||||
status, msg = self.conn.execute_dict(sql)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_("Could not create the role.\n{0}").format(msg)
|
||||
)
|
||||
_("Could not create the role.\n{0}").format(msg)
|
||||
)
|
||||
|
||||
status, rid = self.conn.execute_scalar(
|
||||
"SELECT oid FROM pg_roles WHERE rolname = %(rolname)s",
|
||||
{'rolname': self.request[u'rolname']}
|
||||
)
|
||||
"SELECT oid FROM pg_roles WHERE rolname = %(rolname)s",
|
||||
{'rolname': self.request[u'rolname']}
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_("Could not retrieve the role information.\n{0}").format(msg)
|
||||
)
|
||||
|
||||
_("Could not retrieve the role information.\n{0}").format(msg)
|
||||
)
|
||||
|
||||
status, rset = self.conn.execute_dict(
|
||||
render_template(self.sql_path + 'nodes.sql',
|
||||
rid=rid
|
||||
)
|
||||
)
|
||||
render_template(self.sql_path + 'nodes.sql',
|
||||
rid=rid
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_(
|
||||
"Error fetching role information from the database server.\n{0}"
|
||||
).format(rset)
|
||||
)
|
||||
_(
|
||||
"Error fetching role information from the database server.\n{0}"
|
||||
).format(rset)
|
||||
)
|
||||
for row in rset['rows']:
|
||||
return jsonify(
|
||||
node=self.blueprint.generate_browser_node(
|
||||
rid, sid,
|
||||
row['rolname'],
|
||||
'icon-role' if row['rolcanlogin'] else 'icon-group',
|
||||
can_login=row['rolcanlogin']
|
||||
)
|
||||
)
|
||||
node=self.blueprint.generate_browser_node(
|
||||
rid, sid,
|
||||
row['rolname'],
|
||||
'icon-role' if row['rolcanlogin'] else 'icon-group',
|
||||
can_login=row['rolcanlogin']
|
||||
)
|
||||
)
|
||||
|
||||
return gone(_("Could not find the role information."))
|
||||
|
||||
@@ -771,47 +773,47 @@ rolmembership:{
|
||||
def update(self, gid, sid, rid):
|
||||
|
||||
sql = render_template(
|
||||
self.sql_path + 'update.sql',
|
||||
data=self.request,
|
||||
dummy=False,
|
||||
conn=self.conn,
|
||||
role=self.role,
|
||||
rolCanLogin=self.rolCanLogin,
|
||||
rolCatUpdate=self.rolCatUpdate,
|
||||
rolSuper=self.rolSuper,
|
||||
alterKeys=self.alterKeys
|
||||
)
|
||||
self.sql_path + 'update.sql',
|
||||
data=self.request,
|
||||
dummy=False,
|
||||
conn=self.conn,
|
||||
role=self.role,
|
||||
rolCanLogin=self.rolCanLogin,
|
||||
rolCatUpdate=self.rolCatUpdate,
|
||||
rolSuper=self.rolSuper,
|
||||
alterKeys=self.alterKeys
|
||||
)
|
||||
|
||||
status, msg = self.conn.execute_dict(sql)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_("Could not create the role.\n{0}").format(msg)
|
||||
)
|
||||
_("Could not create the role.\n{0}").format(msg)
|
||||
)
|
||||
|
||||
status, rset = self.conn.execute_dict(
|
||||
render_template(self.sql_path + 'nodes.sql',
|
||||
rid=rid
|
||||
)
|
||||
)
|
||||
render_template(self.sql_path + 'nodes.sql',
|
||||
rid=rid
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_(
|
||||
"Error fetching role information from the database server.\n{0}"
|
||||
).format(rset)
|
||||
)
|
||||
_(
|
||||
"Error fetching role information from the database server.\n{0}"
|
||||
).format(rset)
|
||||
)
|
||||
|
||||
for row in rset['rows']:
|
||||
return jsonify(
|
||||
node=self.blueprint.generate_browser_node(
|
||||
rid, sid,
|
||||
row['rolname'],
|
||||
'icon-role' if row['rolcanlogin'] else 'icon-group',
|
||||
can_login=row['rolcanlogin'],
|
||||
is_superuser=row['rolsuper']
|
||||
)
|
||||
)
|
||||
node=self.blueprint.generate_browser_node(
|
||||
rid, sid,
|
||||
row['rolname'],
|
||||
'icon-role' if row['rolcanlogin'] else 'icon-group',
|
||||
can_login=row['rolcanlogin'],
|
||||
is_superuser=row['rolsuper']
|
||||
)
|
||||
)
|
||||
|
||||
return gone(_("Could not find the role information."))
|
||||
|
||||
@@ -820,27 +822,27 @@ rolmembership:{
|
||||
def msql(self, gid, sid, rid=-1):
|
||||
if rid == -1:
|
||||
return make_json_response(
|
||||
data=render_template(
|
||||
self.sql_path + 'create.sql',
|
||||
data=self.request,
|
||||
dummy=True,
|
||||
conn=self.conn
|
||||
).strip('\n')
|
||||
)
|
||||
data=render_template(
|
||||
self.sql_path + 'create.sql',
|
||||
data=self.request,
|
||||
dummy=True,
|
||||
conn=self.conn
|
||||
).strip('\n')
|
||||
)
|
||||
else:
|
||||
return make_json_response(
|
||||
data=render_template(
|
||||
self.sql_path + 'update.sql',
|
||||
data=self.request,
|
||||
dummy=True,
|
||||
conn=self.conn,
|
||||
role=self.role,
|
||||
rolCanLogin=self.rolCanLogin,
|
||||
rolCatUpdate=self.rolCatUpdate,
|
||||
rolSuper=self.rolSuper,
|
||||
alterKeys=self.alterKeys
|
||||
).strip('\n')
|
||||
)
|
||||
data=render_template(
|
||||
self.sql_path + 'update.sql',
|
||||
data=self.request,
|
||||
dummy=True,
|
||||
conn=self.conn,
|
||||
role=self.role,
|
||||
rolCanLogin=self.rolCanLogin,
|
||||
rolCatUpdate=self.rolCatUpdate,
|
||||
rolSuper=self.rolSuper,
|
||||
alterKeys=self.alterKeys
|
||||
).strip('\n')
|
||||
)
|
||||
|
||||
@check_precondition()
|
||||
def dependencies(self, gid, sid, rid):
|
||||
@@ -855,9 +857,9 @@ rolmembership:{
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, rid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition()
|
||||
def dependents(self, gid, sid, rid):
|
||||
@@ -872,9 +874,9 @@ rolmembership:{
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, sid, rid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
def get_dependents(self, conn, sid, rid):
|
||||
"""
|
||||
@@ -992,52 +994,52 @@ rolmembership:{
|
||||
def variables(self, gid, sid, rid):
|
||||
|
||||
status, rset = self.conn.execute_dict(
|
||||
render_template(self.sql_path + 'variables.sql',
|
||||
rid=rid
|
||||
)
|
||||
)
|
||||
render_template(self.sql_path + 'variables.sql',
|
||||
rid=rid
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_(
|
||||
"Error retrieving variable information for the role.\n{0}"
|
||||
).format(rset)
|
||||
)
|
||||
_(
|
||||
"Error retrieving variable information for the role.\n{0}"
|
||||
).format(rset)
|
||||
)
|
||||
|
||||
return make_json_response(
|
||||
data=rset['rows']
|
||||
)
|
||||
data=rset['rows']
|
||||
)
|
||||
|
||||
@check_precondition()
|
||||
def voptions(self, gid, sid):
|
||||
|
||||
status, res = self.conn.execute_dict(
|
||||
"""
|
||||
"""
|
||||
SELECT
|
||||
name, vartype, min_val, max_val, enumvals
|
||||
name, vartype, min_val, max_val, enumvals
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
'role'::text AS name, 'string'::text AS vartype,
|
||||
NULL AS min_val, NULL AS max_val, NULL::text[] AS enumvals
|
||||
UNION ALL
|
||||
SELECT
|
||||
name, vartype, min_val::numeric AS min_val, max_val::numeric AS max_val, enumvals
|
||||
FROM
|
||||
pg_settings
|
||||
WHERE
|
||||
context in ('user', 'superuser')
|
||||
) a""")
|
||||
(
|
||||
SELECT
|
||||
'role'::text AS name, 'string'::text AS vartype,
|
||||
NULL AS min_val, NULL AS max_val, NULL::text[] AS enumvals
|
||||
UNION ALL
|
||||
SELECT
|
||||
name, vartype, min_val::numeric AS min_val, max_val::numeric AS max_val, enumvals
|
||||
FROM
|
||||
pg_settings
|
||||
WHERE
|
||||
context in ('user', 'superuser')
|
||||
) a""")
|
||||
|
||||
if not status:
|
||||
return internal_server_error(
|
||||
_(
|
||||
"Error retrieving the variable options for the role.\n{0}"
|
||||
).format(res)
|
||||
)
|
||||
_(
|
||||
"Error retrieving the variable options for the role.\n{0}"
|
||||
).format(res)
|
||||
)
|
||||
return make_json_response(
|
||||
data=res['rows']
|
||||
)
|
||||
data=res['rows']
|
||||
)
|
||||
|
||||
|
||||
RoleView.register_node_view(blueprint)
|
||||
|
||||
@@ -55,12 +55,12 @@ class TablespaceView(PGChildNodeView):
|
||||
node_type = blueprint.node_type
|
||||
|
||||
parent_ids = [
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'gid'},
|
||||
{'type': 'int', 'id': 'sid'}
|
||||
]
|
||||
ids = [
|
||||
{'type': 'int', 'id': 'tsid'}
|
||||
]
|
||||
{'type': 'int', 'id': 'tsid'}
|
||||
]
|
||||
|
||||
operations = dict({
|
||||
'obj': [
|
||||
@@ -86,12 +86,12 @@ class TablespaceView(PGChildNodeView):
|
||||
Override this property for your own logic.
|
||||
"""
|
||||
return make_response(
|
||||
render_template(
|
||||
"tablespaces/js/tablespaces.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
render_template(
|
||||
"tablespaces/js/tablespaces.js",
|
||||
_=gettext
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def check_precondition(f):
|
||||
"""
|
||||
@@ -99,6 +99,7 @@ class TablespaceView(PGChildNodeView):
|
||||
database connection before running view, it will also attaches
|
||||
manager,conn & template_path properties to self
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,tsid
|
||||
@@ -110,11 +111,11 @@ class TablespaceView(PGChildNodeView):
|
||||
if not self.conn.connected():
|
||||
current_app.logger.warning(
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
ver = self.manager.version
|
||||
@@ -124,11 +125,12 @@ class TablespaceView(PGChildNodeView):
|
||||
self.template_path = 'tablespaces/sql/9.1_plus'
|
||||
current_app.logger.debug(
|
||||
"Using the template path: %s", self.template_path
|
||||
)
|
||||
)
|
||||
# Allowed ACL on tablespace
|
||||
self.acl = ['C']
|
||||
|
||||
return f(*args, **kwargs)
|
||||
|
||||
return wrap
|
||||
|
||||
@check_precondition
|
||||
@@ -136,15 +138,15 @@ class TablespaceView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
conn=self.conn
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
return ajax_response(
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
response=res['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def nodes(self, gid, sid, tsid=None):
|
||||
@@ -152,24 +154,24 @@ class TablespaceView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
tsid=tsid, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, rset = self.conn.execute_2darray(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=rset)
|
||||
|
||||
for row in rset['rows']:
|
||||
res.append(
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
sid,
|
||||
row['name'],
|
||||
icon="icon-tablespace"
|
||||
))
|
||||
self.blueprint.generate_browser_node(
|
||||
row['oid'],
|
||||
sid,
|
||||
row['name'],
|
||||
icon="icon-tablespace"
|
||||
))
|
||||
|
||||
return make_json_response(
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
data=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
def _formatter(self, data, tsid=None):
|
||||
"""
|
||||
@@ -202,7 +204,7 @@ class TablespaceView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'acl.sql']),
|
||||
tsid=tsid, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, acl = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=acl)
|
||||
@@ -225,7 +227,7 @@ class TablespaceView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
tsid=tsid, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -235,9 +237,9 @@ class TablespaceView(PGChildNodeView):
|
||||
copy_data = self._formatter(copy_data, tsid)
|
||||
|
||||
return ajax_response(
|
||||
response=copy_data,
|
||||
status=200
|
||||
)
|
||||
response=copy_data,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def create(self, gid, sid):
|
||||
@@ -271,7 +273,7 @@ class TablespaceView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
data=data, conn=self.conn
|
||||
)
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_scalar(SQL)
|
||||
|
||||
@@ -280,7 +282,7 @@ class TablespaceView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'alter.sql']),
|
||||
data=data, conn=self.conn
|
||||
)
|
||||
)
|
||||
|
||||
# Checking if we are not executing empty query
|
||||
if SQL and SQL.strip('\n') and SQL.strip(' '):
|
||||
@@ -292,7 +294,7 @@ class TablespaceView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'alter.sql']),
|
||||
tablespace=data['name'], conn=self.conn
|
||||
)
|
||||
)
|
||||
|
||||
status, tsid = self.conn.execute_scalar(SQL)
|
||||
|
||||
@@ -360,8 +362,8 @@ class TablespaceView(PGChildNodeView):
|
||||
render_template(
|
||||
"/".join([self.template_path, 'nodes.sql']),
|
||||
tsid=tsid, conn=self.conn
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=rset)
|
||||
@@ -369,13 +371,13 @@ class TablespaceView(PGChildNodeView):
|
||||
if len(rset['rows']) != 1:
|
||||
return gone(
|
||||
errormsg=gettext("Could not find the tablespace on the server.")
|
||||
)
|
||||
)
|
||||
|
||||
# drop tablespace
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'delete.sql']),
|
||||
tsname=(rset['rows'][0])['name'], conn=self.conn
|
||||
)
|
||||
)
|
||||
|
||||
status, res = self.conn.execute_scalar(SQL)
|
||||
if not status:
|
||||
@@ -388,8 +390,8 @@ class TablespaceView(PGChildNodeView):
|
||||
'id': tsid,
|
||||
'sid': sid,
|
||||
'gid': gid,
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
current_app.logger.exception(e)
|
||||
@@ -431,7 +433,7 @@ class TablespaceView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
tsid=tsid, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -444,11 +446,11 @@ class TablespaceView(PGChildNodeView):
|
||||
for key in ['spcacl']:
|
||||
if key in data and data[key] is not None:
|
||||
if 'added' in data[key]:
|
||||
data[key]['added'] = parse_priv_to_db(data[key]['added'], self.acl)
|
||||
data[key]['added'] = parse_priv_to_db(data[key]['added'], self.acl)
|
||||
if 'changed' in data[key]:
|
||||
data[key]['changed'] = parse_priv_to_db(data[key]['changed'], self.acl)
|
||||
data[key]['changed'] = parse_priv_to_db(data[key]['changed'], self.acl)
|
||||
if 'deleted' in data[key]:
|
||||
data[key]['deleted'] = parse_priv_to_db(data[key]['deleted'], self.acl)
|
||||
data[key]['deleted'] = parse_priv_to_db(data[key]['deleted'], self.acl)
|
||||
|
||||
# If name is not present with in update data then copy it
|
||||
# from old data
|
||||
@@ -459,7 +461,7 @@ class TablespaceView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'update.sql']),
|
||||
data=data, o_data=old_data
|
||||
)
|
||||
)
|
||||
else:
|
||||
# To format privileges coming from client
|
||||
if 'spcacl' in data:
|
||||
@@ -468,12 +470,12 @@ class TablespaceView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
data=data
|
||||
)
|
||||
)
|
||||
SQL += "\n"
|
||||
SQL += render_template(
|
||||
"/".join([self.template_path, 'alter.sql']),
|
||||
data=data, conn=self.conn
|
||||
)
|
||||
)
|
||||
SQL = re.sub('\n{2,}', '\n\n', SQL)
|
||||
return SQL
|
||||
|
||||
@@ -485,7 +487,7 @@ class TablespaceView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'properties.sql']),
|
||||
tsid=tsid, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
@@ -505,12 +507,12 @@ class TablespaceView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'create.sql']),
|
||||
data=old_data
|
||||
)
|
||||
)
|
||||
SQL += "\n"
|
||||
SQL += render_template(
|
||||
"/".join([self.template_path, 'alter.sql']),
|
||||
data=old_data, conn=self.conn
|
||||
)
|
||||
)
|
||||
|
||||
sql_header = """
|
||||
-- Tablespace: {0}
|
||||
@@ -523,7 +525,6 @@ class TablespaceView(PGChildNodeView):
|
||||
SQL = re.sub('\n{2,}', '\n\n', SQL)
|
||||
return ajax_response(response=SQL.strip('\n'))
|
||||
|
||||
|
||||
@check_precondition
|
||||
def variable_options(self, gid, sid):
|
||||
"""
|
||||
@@ -537,16 +538,16 @@ class TablespaceView(PGChildNodeView):
|
||||
"""
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'variables.sql'])
|
||||
)
|
||||
)
|
||||
status, rset = self.conn.execute_dict(SQL)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=rset)
|
||||
|
||||
return make_json_response(
|
||||
data=rset['rows'],
|
||||
status=200
|
||||
)
|
||||
data=rset['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def statistics(self, gid, sid, tsid=None):
|
||||
@@ -556,7 +557,7 @@ class TablespaceView(PGChildNodeView):
|
||||
SQL = render_template(
|
||||
"/".join([self.template_path, 'stats.sql']),
|
||||
tsid=tsid, conn=self.conn
|
||||
)
|
||||
)
|
||||
status, res = self.conn.execute_scalar(SQL)
|
||||
|
||||
if not status:
|
||||
@@ -581,9 +582,9 @@ class TablespaceView(PGChildNodeView):
|
||||
"""
|
||||
dependencies_result = self.get_dependencies(self.conn, tsid)
|
||||
return ajax_response(
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
response=dependencies_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
@check_precondition
|
||||
def dependents(self, gid, sid, tsid):
|
||||
@@ -598,9 +599,9 @@ class TablespaceView(PGChildNodeView):
|
||||
"""
|
||||
dependents_result = self.get_dependents(self.conn, sid, tsid)
|
||||
return ajax_response(
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
response=dependents_result,
|
||||
status=200
|
||||
)
|
||||
|
||||
def get_dependents(self, conn, sid, tsid):
|
||||
"""
|
||||
@@ -648,7 +649,7 @@ class TablespaceView(PGChildNodeView):
|
||||
if tsid == oid:
|
||||
dependents.append({
|
||||
'type': 'database', 'name': '', 'field': db_row['datname']
|
||||
})
|
||||
})
|
||||
|
||||
# If connection to the database is not allowed then continue
|
||||
# with the next database
|
||||
@@ -780,7 +781,9 @@ class TablespaceView(PGChildNodeView):
|
||||
)
|
||||
|
||||
return make_json_response(
|
||||
data=sql.strip('\n'),
|
||||
status=200
|
||||
)
|
||||
data=sql.strip('\n'),
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
TablespaceView.register_node_view(blueprint)
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
<div>{% if errmsg %}
|
||||
<div class="highlight has-error">
|
||||
<div class='control-label'>{{ errmsg }}</div>
|
||||
</div>{% endif %}
|
||||
<div><b>{{ _('Please enter the password for the user \'{0}\' to connect the server - "{1}"').format(username, server_label) }}</b></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div><b>{{ _('Please enter the password for the user \'{0}\' to connect the server - "{1}"').format(username,
|
||||
server_label) }}</b></div>
|
||||
<div style="padding: 5px; height: 1px;"></div>
|
||||
<div style="width: 100%">
|
||||
<span style="width: 25%;display: inline-table;">Password</span>
|
||||
|
||||
@@ -31,7 +31,7 @@ class ServerType(object):
|
||||
self.spriority = priority
|
||||
self.utility_path = None
|
||||
|
||||
assert(server_type not in ServerType.registry)
|
||||
assert (server_type not in ServerType.registry)
|
||||
ServerType.registry[server_type] = self
|
||||
|
||||
@property
|
||||
@@ -66,8 +66,8 @@ class ServerType(object):
|
||||
|
||||
def __str__(self):
|
||||
return "Type: {0}, Description:{1}, Priority: {2}".format(
|
||||
self.stype, self.desc, self.spriority
|
||||
)
|
||||
self.stype, self.desc, self.spriority
|
||||
)
|
||||
|
||||
def instanceOf(self, version):
|
||||
return True
|
||||
@@ -78,19 +78,19 @@ class ServerType(object):
|
||||
Returns a snippet of css to include in the page
|
||||
"""
|
||||
return [
|
||||
render_template(
|
||||
"css/server_type.css",
|
||||
server_type=self.stype
|
||||
)
|
||||
]
|
||||
render_template(
|
||||
"css/server_type.css",
|
||||
server_type=self.stype
|
||||
)
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def types(cls):
|
||||
return sorted(
|
||||
ServerType.registry.values(),
|
||||
key=lambda x: x.priority,
|
||||
reverse=True
|
||||
)
|
||||
ServerType.registry.values(),
|
||||
key=lambda x: x.priority,
|
||||
reverse=True
|
||||
)
|
||||
|
||||
def utility(self, operation, sverion):
|
||||
res = None
|
||||
|
||||
@@ -17,8 +17,8 @@ def parse_priv_from_db(db_privileges):
|
||||
acl = {
|
||||
'grantor': db_privileges['grantor'],
|
||||
'grantee': db_privileges['grantee'],
|
||||
'privileges':[]
|
||||
}
|
||||
'privileges': []
|
||||
}
|
||||
|
||||
privileges = []
|
||||
for idx, priv in enumerate(db_privileges['privileges']):
|
||||
@@ -26,14 +26,14 @@ def parse_priv_from_db(db_privileges):
|
||||
"privilege_type": priv,
|
||||
"privilege": True,
|
||||
"with_grant": db_privileges['grantable'][idx]
|
||||
})
|
||||
})
|
||||
|
||||
acl['privileges'] = privileges
|
||||
|
||||
return acl
|
||||
|
||||
|
||||
def parse_priv_to_db(str_privileges, allowed_acls = []):
|
||||
def parse_priv_to_db(str_privileges, allowed_acls=[]):
|
||||
"""
|
||||
Common utility function to parse privileges before sending to database.
|
||||
"""
|
||||
@@ -50,7 +50,7 @@ def parse_priv_to_db(str_privileges, allowed_acls = []):
|
||||
't': 'TRIGGER',
|
||||
'U': 'USAGE',
|
||||
'X': 'EXECUTE'
|
||||
}
|
||||
}
|
||||
|
||||
privileges = []
|
||||
allowed_acls_len = len(allowed_acls)
|
||||
@@ -69,12 +69,12 @@ def parse_priv_to_db(str_privileges, allowed_acls = []):
|
||||
|
||||
if privilege['with_grant']:
|
||||
priv_with_grant.append(
|
||||
db_privileges[privilege['privilege_type']]
|
||||
)
|
||||
db_privileges[privilege['privilege_type']]
|
||||
)
|
||||
elif privilege['privilege']:
|
||||
priv_without_grant.append(
|
||||
db_privileges[privilege['privilege_type']]
|
||||
)
|
||||
db_privileges[privilege['privilege_type']]
|
||||
)
|
||||
# If we have all acl then just return all
|
||||
if len(priv_with_grant) == allowed_acls_len:
|
||||
priv_with_grant = ['ALL']
|
||||
@@ -85,6 +85,6 @@ def parse_priv_to_db(str_privileges, allowed_acls = []):
|
||||
'grantee': priv['grantee'],
|
||||
'with_grant': priv_with_grant,
|
||||
'without_grant': priv_without_grant
|
||||
})
|
||||
})
|
||||
|
||||
return privileges
|
||||
|
||||
@@ -2,84 +2,92 @@
|
||||
{% block title %}{{ config.APP_NAME }}{% endblock %}
|
||||
{% block init_script %}
|
||||
try {
|
||||
require(
|
||||
['pgadmin', 'pgadmin.browser'],
|
||||
function(pgAdmin, pgBrowser) {
|
||||
pgBrowser.init();
|
||||
},
|
||||
function() {
|
||||
/* TODO:: Show proper error dialog */
|
||||
console.log(arguments);
|
||||
});
|
||||
require(
|
||||
['pgadmin', 'pgadmin.browser'],
|
||||
function(pgAdmin, pgBrowser) {
|
||||
pgBrowser.init();
|
||||
},
|
||||
function() {
|
||||
/* TODO:: Show proper error dialog */
|
||||
console.log(arguments);
|
||||
});
|
||||
} catch (err) {
|
||||
/* Show proper error dialog */
|
||||
console.log(err);
|
||||
/* Show proper error dialog */
|
||||
console.log(err);
|
||||
}
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
<nav class="navbar-inverse navbar-fixed-top">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-menu">
|
||||
<span class="sr-only">{{ _('Toggle navigation') }}</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="#">
|
||||
<i class="app-icon {{ config.APP_ICON }}"></i>
|
||||
<span> {{ config.APP_NAME }}</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-menu">
|
||||
<span class="sr-only">{{ _('Toggle navigation') }}</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="#">
|
||||
<i class="app-icon {{ config.APP_ICON }}"></i>
|
||||
<span> {{ config.APP_NAME }}</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbar-menu">
|
||||
<div class="collapse navbar-collapse" id="navbar-menu">
|
||||
|
||||
<ul class="nav navbar-nav">
|
||||
<ul class="nav navbar-nav">
|
||||
|
||||
<li id="mnu_file" class="dropdown hide">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ _('File') }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu navbar-inverse" role="menu"></ul>
|
||||
</li>
|
||||
<li id="mnu_edit" class="dropdown hide">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ _('Edit') }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu navbar-inverse" role="menu"></ul>
|
||||
</li>
|
||||
<li id="mnu_obj" class="dropdown ">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ _('Object') }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu navbar-inverse" role="menu"></ul>
|
||||
</li>
|
||||
<li id="mnu_management" class="dropdown hide">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ _('Management') }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu navbar-inverse" role="menu"></ul>
|
||||
</li>
|
||||
<li id="mnu_tools" class="dropdown hide">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ _('Tools') }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu navbar-inverse" role="menu"></ul>
|
||||
</li>
|
||||
<li id="mnu_help" class="dropdown hide">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ _('Help') }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu navbar-inverse" role="menu"></ul>
|
||||
</li>
|
||||
</ul>
|
||||
{% if config.SERVER_MODE %}
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><img src="{{ username | gravatar }}" width="18" height="18" alt="Gravatar image for {{ username }}"> {{ username }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu navbar-inverse">
|
||||
<li><a href="{{ url_for('security.change_password') }}">{{ _('Change Password') }}</a></li>
|
||||
<li class="divider"></li>
|
||||
{% if is_admin %}
|
||||
<li><a href="#" onclick="pgAdmin.Browser.UserManagement.show_users()">{{ _('Users') }}</a></li>
|
||||
<li class="divider"></li>
|
||||
<li id="mnu_file" class="dropdown hide">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{
|
||||
_('File') }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu navbar-inverse" role="menu"></ul>
|
||||
</li>
|
||||
<li id="mnu_edit" class="dropdown hide">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{
|
||||
_('Edit') }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu navbar-inverse" role="menu"></ul>
|
||||
</li>
|
||||
<li id="mnu_obj" class="dropdown ">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{
|
||||
_('Object') }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu navbar-inverse" role="menu"></ul>
|
||||
</li>
|
||||
<li id="mnu_management" class="dropdown hide">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{
|
||||
_('Management') }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu navbar-inverse" role="menu"></ul>
|
||||
</li>
|
||||
<li id="mnu_tools" class="dropdown hide">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{
|
||||
_('Tools') }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu navbar-inverse" role="menu"></ul>
|
||||
</li>
|
||||
<li id="mnu_help" class="dropdown hide">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{
|
||||
_('Help') }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu navbar-inverse" role="menu"></ul>
|
||||
</li>
|
||||
</ul>
|
||||
{% if config.SERVER_MODE %}
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><img
|
||||
src="{{ username | gravatar }}" width="18" height="18"
|
||||
alt="Gravatar image for {{ username }}"> {{ username }} <span class="caret"></span></a>
|
||||
<ul class="dropdown-menu navbar-inverse">
|
||||
<li><a href="{{ url_for('security.change_password') }}">{{ _('Change Password') }}</a></li>
|
||||
<li class="divider"></li>
|
||||
{% if is_admin %}
|
||||
<li><a href="#" onclick="pgAdmin.Browser.UserManagement.show_users()">{{ _('Users') }}</a></li>
|
||||
<li class="divider"></li>
|
||||
{% endif %}
|
||||
<li><a href="{{ url_for('security.logout') }}">{{ _('Logout') }}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
<li><a href="{{ url_for('security.logout') }}">{{ _('Logout') }}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div id="dockerContainer" style="position:absolute;left:0px;right:0px;top:50px;bottom:0px;"></div>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
{%- with messages = get_flashed_messages(with_categories=true) -%}
|
||||
{% if messages %}
|
||||
<div style="position: fixed; top: 70px; right: 20px; width: 400px; z-index: 9999">
|
||||
{% for category, message in messages %}
|
||||
<div class="alert alert-{{ category }} alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
{% if messages %}
|
||||
<div style="position: fixed; top: 70px; right: 20px; width: 400px; z-index: 9999">
|
||||
{% for category, message in messages %}
|
||||
<div class="alert alert-{{ category }} alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
|
||||
aria-hidden="true">×</span></button>
|
||||
{{ message|safe }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{%- endwith %}
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
<p>{{ _('You are currently running version {0} of {1}, however the current version is {2}.').format(current_version, product_name, upgrade_version) }}</p>
|
||||
<p>{{ _('Please click <a class="alert-link" href="{0}" target="_new">here</a> for more information.').format(download_url) }}</p>
|
||||
<p>{{ _('You are currently running version {0} of {1}, however the current version is {2}.').format(current_version,
|
||||
product_name, upgrade_version) }}</p>
|
||||
<p>{{ _('Please click <a class="alert-link" href="{0}" target="_new">here</a> for more
|
||||
information.').format(download_url) }}</p>
|
||||
@@ -12,6 +12,7 @@ import uuid
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
from regression.config import config_data
|
||||
|
||||
|
||||
class ResetPasswordTestCase(BaseTestGenerator):
|
||||
"""
|
||||
This class validates the reset password functionality by defining
|
||||
|
||||
@@ -54,9 +54,9 @@ class PGChildModule(object):
|
||||
if (self.min_ver is None and self.max_ver is None):
|
||||
return True
|
||||
|
||||
assert(self.max_ver is None or isinstance(self.max_ver, int))
|
||||
assert(self.min_ver is None or isinstance(self.min_ver, int))
|
||||
assert(self.server_type is None or isinstance(self.server_type, list))
|
||||
assert (self.max_ver is None or isinstance(self.max_ver, int))
|
||||
assert (self.min_ver is None or isinstance(self.min_ver, int))
|
||||
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:
|
||||
if self.min_ver is None or self.min_ver <= sversion:
|
||||
@@ -144,7 +144,7 @@ class NodeView(with_metaclass(MethodViewType, View)):
|
||||
cmds.append({
|
||||
'cmd': op, 'req': (idx == 0),
|
||||
'with_id': (idx != 2), 'methods': meths
|
||||
})
|
||||
})
|
||||
idx += 1
|
||||
return cmds
|
||||
|
||||
@@ -196,29 +196,29 @@ class NodeView(with_metaclass(MethodViewType, View)):
|
||||
meth = 'get'
|
||||
|
||||
assert self.cmd in self.operations, \
|
||||
"Unimplemented command ({0}) for {1}".format(
|
||||
self.cmd,
|
||||
str(self.__class__.__name__)
|
||||
)
|
||||
"Unimplemented command ({0}) for {1}".format(
|
||||
self.cmd,
|
||||
str(self.__class__.__name__)
|
||||
)
|
||||
|
||||
has_args, has_id = self.check_args(**kwargs)
|
||||
|
||||
assert (self.cmd in self.operations and
|
||||
(has_id and len(self.operations[self.cmd]) > 0 and
|
||||
meth in self.operations[self.cmd][0]) or
|
||||
meth in self.operations[self.cmd][0]) or
|
||||
(not has_id and len(self.operations[self.cmd]) > 1 and
|
||||
meth in self.operations[self.cmd][1]) or
|
||||
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(
|
||||
meth, self.cmd,
|
||||
'requires' if has_id else 'does not require'
|
||||
)
|
||||
meth in self.operations[self.cmd][2])), \
|
||||
"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]
|
||||
meth in self.operations[self.cmd][1] else \
|
||||
self.operations[self.cmd][2][meth]
|
||||
|
||||
method = getattr(self, meth, None)
|
||||
|
||||
@@ -244,25 +244,25 @@ class NodeView(with_metaclass(MethodViewType, View)):
|
||||
for c in commands:
|
||||
if c['with_id']:
|
||||
blueprint.add_url_rule(
|
||||
'/{0}{1}'.format(
|
||||
c['cmd'], id_url if c['req'] else url
|
||||
),
|
||||
view_func=cls.as_view(
|
||||
'{0}{1}'.format(
|
||||
c['cmd'], '_id' if c['req'] else ''
|
||||
),
|
||||
cmd=c['cmd']
|
||||
),
|
||||
methods=c['methods']
|
||||
)
|
||||
'/{0}{1}'.format(
|
||||
c['cmd'], id_url if c['req'] else url
|
||||
),
|
||||
view_func=cls.as_view(
|
||||
'{0}{1}'.format(
|
||||
c['cmd'], '_id' if c['req'] else ''
|
||||
),
|
||||
cmd=c['cmd']
|
||||
),
|
||||
methods=c['methods']
|
||||
)
|
||||
else:
|
||||
blueprint.add_url_rule(
|
||||
'/{0}'.format(c['cmd']),
|
||||
view_func=cls.as_view(
|
||||
'{0}'.format(c['cmd']), cmd=c['cmd']
|
||||
),
|
||||
methods=c['methods']
|
||||
)
|
||||
'/{0}'.format(c['cmd']),
|
||||
view_func=cls.as_view(
|
||||
'{0}'.format(c['cmd']), cmd=c['cmd']
|
||||
),
|
||||
methods=c['methods']
|
||||
)
|
||||
|
||||
def module_js(self, **kwargs):
|
||||
"""
|
||||
@@ -270,11 +270,11 @@ class NodeView(with_metaclass(MethodViewType, View)):
|
||||
Override this property for your own logic.
|
||||
"""
|
||||
return flask.make_response(
|
||||
flask.render_template(
|
||||
"{0}/js/{0}.js".format(self.node_type)
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
flask.render_template(
|
||||
"{0}/js/{0}.js".format(self.node_type)
|
||||
),
|
||||
200, {'Content-Type': 'application/x-javascript'}
|
||||
)
|
||||
|
||||
def children(self, *args, **kwargs):
|
||||
"""Build a list of treeview nodes from the child nodes."""
|
||||
@@ -291,7 +291,6 @@ class NodeView(with_metaclass(MethodViewType, View)):
|
||||
|
||||
|
||||
class PGChildNodeView(NodeView):
|
||||
|
||||
def children(self, **kwargs):
|
||||
"""Build a list of treeview nodes from the child nodes."""
|
||||
|
||||
@@ -302,8 +301,8 @@ class PGChildNodeView(NodeView):
|
||||
|
||||
from pgadmin.utils.driver import get_driver
|
||||
manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(
|
||||
sid=kwargs['sid']
|
||||
)
|
||||
sid=kwargs['sid']
|
||||
)
|
||||
|
||||
did = None
|
||||
if 'did' in kwargs:
|
||||
@@ -313,10 +312,10 @@ class PGChildNodeView(NodeView):
|
||||
|
||||
if not conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost."
|
||||
)
|
||||
)
|
||||
gettext(
|
||||
"Connection to the server has been lost."
|
||||
)
|
||||
)
|
||||
|
||||
nodes = []
|
||||
for module in self.blueprint.submodules:
|
||||
|
||||
@@ -62,9 +62,16 @@
|
||||
<div class="dashboard-tab-container">
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs dashboard-tab-panel" role="tablist">
|
||||
<li role="presentation" class="active dashboard-tab"><a href="#tab_panel_database_activity" aria-controls="tab_database_activity" role="tab" data-toggle="tab">Sessions</a></li>
|
||||
<li role="presentation" class="dashboard-tab"><a href="#tab_panel_database_locks" aria-controls="tab_database_locks" role="tab" data-toggle="tab">Locks</a></li>
|
||||
<li role="presentation" class="dashboard-tab"><a href="#tab_panel_database_prepared" aria-controls="tab_database_prepared" role="tab" data-toggle="tab">Prepared Transactions</a></li>
|
||||
<li role="presentation" class="active dashboard-tab"><a href="#tab_panel_database_activity"
|
||||
aria-controls="tab_database_activity"
|
||||
role="tab" data-toggle="tab">Sessions</a>
|
||||
</li>
|
||||
<li role="presentation" class="dashboard-tab"><a href="#tab_panel_database_locks"
|
||||
aria-controls="tab_database_locks" role="tab"
|
||||
data-toggle="tab">Locks</a></li>
|
||||
<li role="presentation" class="dashboard-tab"><a href="#tab_panel_database_prepared"
|
||||
aria-controls="tab_database_prepared" role="tab"
|
||||
data-toggle="tab">Prepared Transactions</a></li>
|
||||
</ul>
|
||||
|
||||
<!-- Tab panes -->
|
||||
@@ -86,4 +93,5 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
pgAdmin.Dashboard.init_database_dashboard({{ sid }}, {{ did }}, {{ rates.session_stats_refresh }}, {{ rates.tps_stats_refresh }}, {{ rates.ti_stats_refresh }}, {{ rates.to_stats_refresh }}, {{ rates.bio_stats_refresh }} );
|
||||
|
||||
</script>
|
||||
|
||||
@@ -62,10 +62,19 @@
|
||||
<div class="dashboard-tab-container">
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs dashboard-tab-panel" role="tablist">
|
||||
<li role="presentation" class="active dashboard-tab"><a href="#tab_panel_server_activity" aria-controls="tab_server_activity" role="tab" data-toggle="tab">Sessions</a></li>
|
||||
<li role="presentation" class="dashboard-tab"><a href="#tab_panel_server_locks" aria-controls="tab_server_locks" role="tab" data-toggle="tab">Locks</a></li>
|
||||
<li role="presentation" class="dashboard-tab"><a href="#tab_panel_server_prepared" aria-controls="tab_server_prepared" role="tab" data-toggle="tab">Prepared Transactions</a></li>
|
||||
<li role="presentation" class="dashboard-tab"><a href="#tab_panel_server_config" aria-controls="tab_server_config" role="tab" data-toggle="tab">Configuration</a></li>
|
||||
<li role="presentation" class="active dashboard-tab"><a href="#tab_panel_server_activity"
|
||||
aria-controls="tab_server_activity"
|
||||
role="tab" data-toggle="tab">Sessions</a>
|
||||
</li>
|
||||
<li role="presentation" class="dashboard-tab"><a href="#tab_panel_server_locks"
|
||||
aria-controls="tab_server_locks" role="tab"
|
||||
data-toggle="tab">Locks</a></li>
|
||||
<li role="presentation" class="dashboard-tab"><a href="#tab_panel_server_prepared"
|
||||
aria-controls="tab_server_prepared" role="tab"
|
||||
data-toggle="tab">Prepared Transactions</a></li>
|
||||
<li role="presentation" class="dashboard-tab"><a href="#tab_panel_server_config"
|
||||
aria-controls="tab_server_config" role="tab"
|
||||
data-toggle="tab">Configuration</a></li>
|
||||
</ul>
|
||||
|
||||
<!-- Tab panes -->
|
||||
@@ -90,4 +99,5 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
pgAdmin.Dashboard.init_server_dashboard({{ sid }}, {{ rates.session_stats_refresh }}, {{ rates.tps_stats_refresh }}, {{ rates.ti_stats_refresh }}, {{ rates.to_stats_refresh }}, {{ rates.bio_stats_refresh }} );
|
||||
|
||||
</script>
|
||||
|
||||
@@ -1,77 +1,78 @@
|
||||
<div class="dashboard-container">
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="obj_properties">
|
||||
<legend class="badge">Welcome</legend>
|
||||
</div>
|
||||
<div class="well well-lg">
|
||||
<img src="{{ url_for('dashboard.static', filename='img/welcome_logo.png') }}" alt="pgAdmin 4">
|
||||
<h4>Feature rich | Maximises PostgreSQL | Open Source </h4>
|
||||
<p>
|
||||
pgAdmin is an open source administration and management tool for the PostgreSQL
|
||||
database. The tools include a graphical administration interface, an SQL query
|
||||
tool, a procedural code debugger and much more. The tool is designed to answer
|
||||
the needs of developers, DBAs and system administrators alike.
|
||||
</p>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="obj_properties">
|
||||
<legend class="badge">Welcome</legend>
|
||||
</div>
|
||||
<div class="well well-lg">
|
||||
<img src="{{ url_for('dashboard.static', filename='img/welcome_logo.png') }}" alt="pgAdmin 4">
|
||||
<h4>Feature rich | Maximises PostgreSQL | Open Source </h4>
|
||||
<p>
|
||||
pgAdmin is an open source administration and management tool for the PostgreSQL
|
||||
database. The tools include a graphical administration interface, an SQL query
|
||||
tool, a procedural code debugger and much more. The tool is designed to answer
|
||||
the needs of developers, DBAs and system administrators alike.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="obj_properties">
|
||||
<legend class="badge">Quick Links</legend>
|
||||
</div>
|
||||
<div class="well well-lg">
|
||||
<div class="row">
|
||||
<div class="col-xs-6 dashboard-link">
|
||||
<a onclick="pgAdmin.Dashboard.add_new_server()">
|
||||
<span class="fa fa-4x dashboard-icon fa-server" aria-hidden="true"></span><br />
|
||||
Add New Server
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-6 dashboard-link">
|
||||
<a onclick="pgAdmin.Preferences.show()">
|
||||
<span id="mnu_preferences" class="fa fa-4x dashboard-icon fa-cogs" aria-hidden="true"></span><br />
|
||||
Configure pgAdmin
|
||||
</a>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="obj_properties">
|
||||
<legend class="badge">Quick Links</legend>
|
||||
</div>
|
||||
<div class="well well-lg">
|
||||
<div class="row">
|
||||
<div class="col-xs-6 dashboard-link">
|
||||
<a onclick="pgAdmin.Dashboard.add_new_server()">
|
||||
<span class="fa fa-4x dashboard-icon fa-server" aria-hidden="true"></span><br/>
|
||||
Add New Server
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-6 dashboard-link">
|
||||
<a onclick="pgAdmin.Preferences.show()">
|
||||
<span id="mnu_preferences" class="fa fa-4x dashboard-icon fa-cogs"
|
||||
aria-hidden="true"></span><br/>
|
||||
Configure pgAdmin
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="obj_properties">
|
||||
<legend class="badge">Getting Started</legend>
|
||||
</div>
|
||||
<div class="well well-lg">
|
||||
<div class="row">
|
||||
<div class="col-xs-3 dashboard-link">
|
||||
<a href="http://www.postgresql.org/docs" target="_new">
|
||||
<span class="fa fa-4x dashboard-icon icon-postgres" aria-hidden="true"></span><br />
|
||||
PostgreSQL Documentation
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-3 dashboard-link">
|
||||
<a href="https://www.pgadmin.org" target="_new">
|
||||
<span class="fa fa-4x dashboard-icon fa-globe" aria-hidden="true"></span><br />
|
||||
pgAdmin Website
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-3 dashboard-link">
|
||||
<a href="http://planet.postgresql.org" target="_new">
|
||||
<span class="fa fa-4x dashboard-icon fa-book" aria-hidden="true"></span><br />
|
||||
Planet PostgreSQL
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-3 dashboard-link">
|
||||
<a href="http://www.postgresql.org/community" target="_new">
|
||||
<span class="fa fa-4x dashboard-icon fa-users" aria-hidden="true"></span><br />
|
||||
Community Support
|
||||
</a>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="obj_properties">
|
||||
<legend class="badge">Getting Started</legend>
|
||||
</div>
|
||||
<div class="well well-lg">
|
||||
<div class="row">
|
||||
<div class="col-xs-3 dashboard-link">
|
||||
<a href="http://www.postgresql.org/docs" target="_new">
|
||||
<span class="fa fa-4x dashboard-icon icon-postgres" aria-hidden="true"></span><br/>
|
||||
PostgreSQL Documentation
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-3 dashboard-link">
|
||||
<a href="https://www.pgadmin.org" target="_new">
|
||||
<span class="fa fa-4x dashboard-icon fa-globe" aria-hidden="true"></span><br/>
|
||||
pgAdmin Website
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-3 dashboard-link">
|
||||
<a href="http://planet.postgresql.org" target="_new">
|
||||
<span class="fa fa-4x dashboard-icon fa-book" aria-hidden="true"></span><br/>
|
||||
Planet PostgreSQL
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-xs-3 dashboard-link">
|
||||
<a href="http://www.postgresql.org/community" target="_new">
|
||||
<span class="fa fa-4x dashboard-icon fa-users" aria-hidden="true"></span><br/>
|
||||
Community Support
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -20,11 +20,10 @@ import config
|
||||
|
||||
|
||||
class HelpModule(PgAdminModule):
|
||||
|
||||
def get_own_menuitems(self):
|
||||
"""Return a (set) of dicts of help menu items, with name, priority, URL,
|
||||
target and onclick code."""
|
||||
return { 'help_items': [
|
||||
return {'help_items': [
|
||||
MenuItem(name='mnu_online_help',
|
||||
label=gettext('Online Help'),
|
||||
priority=100,
|
||||
@@ -33,18 +32,18 @@ class HelpModule(PgAdminModule):
|
||||
url=url_for('help.static', filename='index.html')),
|
||||
|
||||
MenuItem(name='mnu_pgadmin_website',
|
||||
label= gettext('pgAdmin Website'),
|
||||
priority= 200,
|
||||
target= '_blank',
|
||||
label=gettext('pgAdmin Website'),
|
||||
priority=200,
|
||||
target='_blank',
|
||||
icon='fa fa-external-link',
|
||||
url= 'https://www.pgadmin.org/' ),
|
||||
url='https://www.pgadmin.org/'),
|
||||
|
||||
MenuItem(name= 'mnu_postgresql_website',
|
||||
label= gettext('PostgreSQL Website'),
|
||||
priority= 300,
|
||||
target= '_blank',
|
||||
MenuItem(name='mnu_postgresql_website',
|
||||
label=gettext('PostgreSQL Website'),
|
||||
priority=300,
|
||||
target='_blank',
|
||||
icon='fa fa-external-link',
|
||||
url= 'http://www.postgresql.org/' )]}
|
||||
url='http://www.postgresql.org/')]}
|
||||
|
||||
def get_panels(self):
|
||||
return [
|
||||
@@ -89,16 +88,19 @@ class HelpModule(PgAdminModule):
|
||||
gettext("PostgreSQL Help Path"), 'text',
|
||||
'http://www.postgresql.org/docs/$VERSION$/static/',
|
||||
category_label=gettext('Help'),
|
||||
help_str=gettext('Path to the PostgreSQL documentation. $VERSION$ will be replaced with the major.minor version number.')
|
||||
)
|
||||
help_str=gettext(
|
||||
'Path to the PostgreSQL documentation. $VERSION$ will be replaced with the major.minor version number.')
|
||||
)
|
||||
|
||||
self.edbas_help_path = self.help_preference.register(
|
||||
'help', 'edbas_help_path',
|
||||
gettext("EDB Advanced Server Help Path"), 'text',
|
||||
'http://www.enterprisedb.com/docs/en/$VERSION$/pg/',
|
||||
category_label=gettext('Help'),
|
||||
help_str=gettext('Path to the EDB Advanced Server documentation. $VERSION$ will be replaced with the major.minor version number.')
|
||||
)
|
||||
help_str=gettext(
|
||||
'Path to the EDB Advanced Server documentation. $VERSION$ will be replaced with the major.minor version number.')
|
||||
)
|
||||
|
||||
|
||||
# Initialise the module
|
||||
blueprint = HelpModule(MODULE_NAME, __name__, static_url_path='/help',
|
||||
|
||||
@@ -20,7 +20,6 @@ MODULE_NAME = 'misc'
|
||||
|
||||
|
||||
class MiscModule(PgAdminModule):
|
||||
|
||||
def get_own_javascripts(self):
|
||||
return [{
|
||||
'name': 'pgadmin.misc.explain',
|
||||
|
||||
@@ -23,13 +23,12 @@ MODULE_NAME = 'bgprocess'
|
||||
|
||||
|
||||
class BGProcessModule(PgAdminModule):
|
||||
|
||||
def get_own_javascripts(self):
|
||||
return [{
|
||||
'name': 'pgadmin.browser.bgprocess',
|
||||
'path': url_for('bgprocess.static', filename='js/bgprocess'),
|
||||
'when': None
|
||||
}]
|
||||
}]
|
||||
|
||||
def get_own_stylesheets(self):
|
||||
"""
|
||||
@@ -38,7 +37,7 @@ class BGProcessModule(PgAdminModule):
|
||||
"""
|
||||
stylesheets = [
|
||||
url_for('bgprocess.static', filename='css/bgprocess.css')
|
||||
]
|
||||
]
|
||||
return stylesheets
|
||||
|
||||
def get_own_messages(self):
|
||||
@@ -59,6 +58,7 @@ class BGProcessModule(PgAdminModule):
|
||||
'failed_with_exit_code': _("Failed (exit code: %%s).")
|
||||
}
|
||||
|
||||
|
||||
# Initialise the module
|
||||
blueprint = BGProcessModule(
|
||||
MODULE_NAME, __name__, url_prefix='/misc/bgprocess'
|
||||
|
||||
@@ -41,17 +41,18 @@ import csv
|
||||
import pytz
|
||||
import codecs
|
||||
|
||||
|
||||
# SQLite3 needs all string as UTF-8
|
||||
# We need to make string for Python2/3 compatible
|
||||
if sys.version_info < (3,):
|
||||
from cStringIO import StringIO
|
||||
|
||||
|
||||
def u(x):
|
||||
return x
|
||||
else:
|
||||
from io import StringIO
|
||||
|
||||
|
||||
def u(x):
|
||||
if hasattr(x, 'decode'):
|
||||
return x.decode()
|
||||
@@ -299,7 +300,7 @@ def execute(configs):
|
||||
shell=(os.name == 'nt'), close_fds=(os.name != 'nt')
|
||||
)
|
||||
try:
|
||||
del(os.environ['PGPASSWORD'])
|
||||
del (os.environ['PGPASSWORD'])
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -367,17 +368,17 @@ if __name__ == '__main__':
|
||||
# Read command line arguments
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Process executor for pgAdmin 4'
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
'-p', '--process_id', help='Process ID', required=True
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
'-d', '--db_file', help='Configuration Database', required=True
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
'-o', '--output_directory',
|
||||
help='Location where the logs will be created', required=True
|
||||
)
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
# Fetch bakcground process details from SQLite3 database file
|
||||
|
||||
@@ -58,7 +58,6 @@ class IProcessDesc(object):
|
||||
|
||||
|
||||
class BatchProcess(object):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
||||
self.id = self.desc = self.cmd = self.args = self.log_dir = \
|
||||
@@ -105,7 +104,7 @@ class BatchProcess(object):
|
||||
ctime = get_current_time(format='%y%m%d%H%M%S%f')
|
||||
log_dir = os.path.join(
|
||||
config.SESSION_DB_PATH, 'process_logs'
|
||||
)
|
||||
)
|
||||
|
||||
def random_number(size):
|
||||
import random
|
||||
@@ -184,7 +183,7 @@ class BatchProcess(object):
|
||||
p = None
|
||||
cmd = [
|
||||
(sys.executable if not app.PGADMIN_RUNTIME else
|
||||
'pythonw.exe' if os.name == 'nt' else 'python'),
|
||||
'pythonw.exe' if os.name == 'nt' else 'python'),
|
||||
executor,
|
||||
'-p', self.id,
|
||||
'-o', self.log_dir,
|
||||
@@ -282,7 +281,7 @@ class BatchProcess(object):
|
||||
execution_time = (etime - stime).total_seconds()
|
||||
|
||||
if process_output and self.ecode is not None and (
|
||||
len(stdout) + len(stderr) < 3073
|
||||
len(stdout) + len(stderr) < 3073
|
||||
):
|
||||
out, out_completed = read_log(
|
||||
self.stdout, stdout, out, ctime, False
|
||||
|
||||
@@ -16,13 +16,13 @@ MODULE_NAME = 'depends'
|
||||
|
||||
|
||||
class DependsModule(PgAdminModule):
|
||||
|
||||
def get_own_javascripts(self):
|
||||
return [{
|
||||
'name': 'pgadmin.browser.object_depends',
|
||||
'path': url_for('depends.static', filename='js/depends'),
|
||||
'when': None
|
||||
}]
|
||||
}]
|
||||
|
||||
|
||||
# Initialise the module
|
||||
blueprint = DependsModule(MODULE_NAME, __name__, url_prefix='/misc/depends')
|
||||
|
||||
@@ -27,6 +27,7 @@ from pgadmin.utils.ajax import make_json_response
|
||||
# Checks if platform is Windows
|
||||
if _platform == "win32":
|
||||
import ctypes
|
||||
|
||||
file_root = ""
|
||||
|
||||
# uppercase supported in py2, ascii_uppercase supported in py3
|
||||
@@ -41,7 +42,6 @@ try:
|
||||
except Exception as e:
|
||||
from urllib.parse import unquote
|
||||
|
||||
|
||||
MODULE_NAME = 'file_manager'
|
||||
global transid
|
||||
|
||||
@@ -118,18 +118,18 @@ class FileManagerModule(PgAdminModule):
|
||||
|
||||
def get_own_javascripts(self):
|
||||
return [
|
||||
{
|
||||
'name': 'pgadmin.file_manager',
|
||||
'path': url_for('file_manager.index') + 'file_manager',
|
||||
'when': None
|
||||
},
|
||||
]
|
||||
{
|
||||
'name': 'pgadmin.file_manager',
|
||||
'path': url_for('file_manager.index') + 'file_manager',
|
||||
'when': None
|
||||
},
|
||||
]
|
||||
|
||||
def get_own_stylesheets(self):
|
||||
return [
|
||||
url_for('static', filename='css/jquery.dropzone/dropzone.css'),
|
||||
url_for('file_manager.static', filename='css/file_manager.css')
|
||||
]
|
||||
url_for('static', filename='css/jquery.dropzone/dropzone.css'),
|
||||
url_for('file_manager.static', filename='css/file_manager.css')
|
||||
]
|
||||
|
||||
def get_own_menuitems(self):
|
||||
return {
|
||||
@@ -145,7 +145,8 @@ class FileManagerModule(PgAdminModule):
|
||||
'options', 'file_upload_size',
|
||||
gettext("Maximum file upload size(MB)"), 'integer', 50,
|
||||
category_label=gettext('Options')
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# Initialise the module
|
||||
blueprint = FileManagerModule(MODULE_NAME, __name__)
|
||||
@@ -156,7 +157,7 @@ blueprint = FileManagerModule(MODULE_NAME, __name__)
|
||||
def index():
|
||||
"""Render the preferences dialog."""
|
||||
return render_template(
|
||||
MODULE_NAME + "/index.html", _=gettext)
|
||||
MODULE_NAME + "/index.html", _=gettext)
|
||||
|
||||
|
||||
@blueprint.route("/utility.js")
|
||||
@@ -233,16 +234,18 @@ def delete_trans_id(trans_id):
|
||||
data={'status': True}
|
||||
)
|
||||
|
||||
|
||||
class Filemanager(object):
|
||||
"""FileManager Class."""
|
||||
|
||||
def __init__(self, trans_id):
|
||||
self.trans_id = trans_id
|
||||
self.patherror = encode_json(
|
||||
{
|
||||
'Error': gettext('No permission to operate on specified path.'),
|
||||
'Code': -1
|
||||
}
|
||||
)
|
||||
{
|
||||
'Error': gettext('No permission to operate on specified path.'),
|
||||
'Code': -1
|
||||
}
|
||||
)
|
||||
self.dir = get_storage_directory()
|
||||
|
||||
if self.dir is not None and isinstance(self.dir, list):
|
||||
@@ -295,22 +298,22 @@ class Filemanager(object):
|
||||
|
||||
# create configs using above configs
|
||||
configs = {
|
||||
"fileroot": "/",
|
||||
"dialog_type": fm_type,
|
||||
"title": title,
|
||||
"upload": {
|
||||
"multiple": True
|
||||
},
|
||||
"capabilities": capabilities,
|
||||
"security": {
|
||||
"uploadPolicy": "",
|
||||
"uploadRestrictions": allow_upload_files
|
||||
},
|
||||
"files_only": files_only,
|
||||
"folders_only": folders_only,
|
||||
"supported_types": supp_types,
|
||||
"platform_type": _platform,
|
||||
"show_volumes": show_volumes
|
||||
"fileroot": "/",
|
||||
"dialog_type": fm_type,
|
||||
"title": title,
|
||||
"upload": {
|
||||
"multiple": True
|
||||
},
|
||||
"capabilities": capabilities,
|
||||
"security": {
|
||||
"uploadPolicy": "",
|
||||
"uploadRestrictions": allow_upload_files
|
||||
},
|
||||
"files_only": files_only,
|
||||
"folders_only": folders_only,
|
||||
"supported_types": supp_types,
|
||||
"platform_type": _platform,
|
||||
"show_volumes": show_volumes
|
||||
}
|
||||
|
||||
# Create a unique id for the transaction
|
||||
@@ -420,7 +423,7 @@ class Filemanager(object):
|
||||
"Date Created": "",
|
||||
"Date Modified": "",
|
||||
"Size": drive_size_in_units
|
||||
}
|
||||
}
|
||||
}
|
||||
return files
|
||||
|
||||
@@ -429,9 +432,9 @@ class Filemanager(object):
|
||||
orig_path = "{0}{1}".format(dir, path)
|
||||
user_dir = path
|
||||
folders_only = trans_data['folders_only'] if 'folders_only' in \
|
||||
trans_data else ''
|
||||
trans_data else ''
|
||||
files_only = trans_data['files_only'] if 'files_only' in \
|
||||
trans_data else ''
|
||||
trans_data else ''
|
||||
supported_types = trans_data['supported_types'] \
|
||||
if 'supported_types' in trans_data else []
|
||||
|
||||
@@ -451,8 +454,8 @@ class Filemanager(object):
|
||||
file_extension = str(splitext(system_path))
|
||||
|
||||
# set protected to 1 if no write or read permission
|
||||
if(not os.access(system_path, os.R_OK) or
|
||||
not os.access(system_path, os.W_OK)):
|
||||
if (not os.access(system_path, os.R_OK) or
|
||||
not os.access(system_path, os.W_OK)):
|
||||
protected = 1
|
||||
|
||||
# list files only or folders only
|
||||
@@ -465,21 +468,21 @@ class Filemanager(object):
|
||||
# filter files based on file_type
|
||||
if file_type is not None and file_type != "*":
|
||||
if folders_only or len(supported_types) > 0 and \
|
||||
file_extension not in supported_types or \
|
||||
file_type != file_extension:
|
||||
file_extension not in supported_types or \
|
||||
file_type != file_extension:
|
||||
continue
|
||||
|
||||
# create a list of files and folders
|
||||
files[user_path] = {
|
||||
"Filename": f,
|
||||
"Path": user_path,
|
||||
"file_type": file_extension,
|
||||
"Protected": protected,
|
||||
"Properties": {
|
||||
"Date Created": created,
|
||||
"Date Modified": modified,
|
||||
"Size": sizeof_fmt(getSize(system_path))
|
||||
}
|
||||
"Filename": f,
|
||||
"Path": user_path,
|
||||
"file_type": file_extension,
|
||||
"Protected": protected,
|
||||
"Properties": {
|
||||
"Date Created": created,
|
||||
"Date Modified": modified,
|
||||
"Size": sizeof_fmt(getSize(system_path))
|
||||
}
|
||||
}
|
||||
except Exception as e:
|
||||
if e.strerror == gettext('Permission denied'):
|
||||
@@ -487,8 +490,8 @@ class Filemanager(object):
|
||||
else:
|
||||
err_msg = "Error: {0}".format(e.strerror)
|
||||
files = {
|
||||
'Code': 0,
|
||||
'err_msg': err_msg
|
||||
'Code': 0,
|
||||
'err_msg': err_msg
|
||||
}
|
||||
return files
|
||||
|
||||
@@ -518,13 +521,13 @@ class Filemanager(object):
|
||||
'Error': '',
|
||||
'Code': 0,
|
||||
'Properties': {
|
||||
'Date Created': '',
|
||||
'Date Modified': '',
|
||||
'Width': '',
|
||||
'Height': '',
|
||||
'Size': ''
|
||||
}
|
||||
'Date Created': '',
|
||||
'Date Modified': '',
|
||||
'Width': '',
|
||||
'Height': '',
|
||||
'Size': ''
|
||||
}
|
||||
}
|
||||
|
||||
if not path_exists(orig_path):
|
||||
thefile['Error'] = gettext('File does not exist.')
|
||||
@@ -559,8 +562,8 @@ class Filemanager(object):
|
||||
"""
|
||||
if not self.validate_request('rename'):
|
||||
return {
|
||||
'Error': gettext('Not allowed'),
|
||||
'Code': 1
|
||||
'Error': gettext('Not allowed'),
|
||||
'Code': 1
|
||||
}
|
||||
|
||||
dir = self.dir
|
||||
@@ -611,8 +614,8 @@ class Filemanager(object):
|
||||
"""
|
||||
if not self.validate_request('delete'):
|
||||
return {
|
||||
'Error': gettext('Not allowed'),
|
||||
'Code': 1
|
||||
'Error': gettext('Not allowed'),
|
||||
'Code': 1
|
||||
}
|
||||
|
||||
dir = self.dir
|
||||
@@ -644,8 +647,8 @@ class Filemanager(object):
|
||||
"""
|
||||
if not self.validate_request('upload'):
|
||||
return {
|
||||
'Error': gettext('Not allowed'),
|
||||
'Code': 1
|
||||
'Error': gettext('Not allowed'),
|
||||
'Code': 1
|
||||
}
|
||||
|
||||
dir = self.dir
|
||||
@@ -706,12 +709,12 @@ class Filemanager(object):
|
||||
with same name already exists
|
||||
"""
|
||||
last_char = newName[-1]
|
||||
tnewPath = dir + '/' + path + newName + '_'+str(count)
|
||||
tnewPath = dir + '/' + path + newName + '_' + str(count)
|
||||
if last_char == 'r' and not path_exists(tnewPath):
|
||||
return tnewPath, newName
|
||||
else:
|
||||
last_char = int(tnewPath[-1]) + 1
|
||||
newPath = dir + '/' + path + newName + '_'+str(last_char)
|
||||
newPath = dir + '/' + path + newName + '_' + str(last_char)
|
||||
if path_exists(newPath):
|
||||
count += 1
|
||||
return Filemanager.getNewName(dir, path, newName, count)
|
||||
@@ -724,8 +727,8 @@ class Filemanager(object):
|
||||
"""
|
||||
if not self.validate_request('create'):
|
||||
return {
|
||||
'Error': gettext('Not allowed'),
|
||||
'Code': 1
|
||||
'Error': gettext('Not allowed'),
|
||||
'Code': 1
|
||||
}
|
||||
|
||||
dir = self.dir
|
||||
@@ -766,8 +769,8 @@ class Filemanager(object):
|
||||
"""
|
||||
if not self.validate_request('download'):
|
||||
return {
|
||||
'Error': gettext('Not allowed'),
|
||||
'Code': 1
|
||||
'Error': gettext('Not allowed'),
|
||||
'Code': 1
|
||||
}
|
||||
|
||||
dir = self.dir
|
||||
@@ -775,7 +778,7 @@ class Filemanager(object):
|
||||
name = path.split('/')[-1]
|
||||
content = open(orig_path, 'r')
|
||||
resp = Response(content)
|
||||
resp.headers['Content-Disposition'] = 'attachment; filename='+name
|
||||
resp.headers['Content-Disposition'] = 'attachment; filename=' + name
|
||||
return resp
|
||||
|
||||
|
||||
@@ -802,8 +805,8 @@ def file_manager(trans_id):
|
||||
del kwargs['mode']
|
||||
elif req.method == 'GET':
|
||||
kwargs = {
|
||||
'path': req.args['path'],
|
||||
'name': req.args['name'] if 'name' in req.args else ''
|
||||
'path': req.args['path'],
|
||||
'name': req.args['name'] if 'name' in req.args else ''
|
||||
}
|
||||
mode = req.args['mode']
|
||||
|
||||
|
||||
@@ -1,54 +1,61 @@
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="{{ url_for('static', filename='js/jquery.dropzone/dropzone.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('file_manager.index') }}utility.js"></script>
|
||||
<script type="text/javascript" src="{{ url_for('static', filename='js/jquery.dropzone/dropzone.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('file_manager.index') }}utility.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="file_manager">
|
||||
<form id="uploader" method="post" class='col-xs-12'>
|
||||
<div class="btn-group filemanager-path-group col-sm-7 col-xs-12" role="group">
|
||||
<button name="home" type="button" value="Home" title="Home" class="fa fa-home btn home"><span></span></button>
|
||||
<button name="level-up" type="button" title="Back" value="LevelUp" class="btn fa fa-level-up level-up" disabled><span></span></button>
|
||||
<h1 title=''></h1>
|
||||
</div>
|
||||
<div class="btn-group filemanager-btn-group" role="group">
|
||||
<div class="uploadresponse"></div>
|
||||
<input class="mode" name="mode" type="hidden" value="add" />
|
||||
<input class="currentpath" name="currentpath" type="hidden" />
|
||||
<button type="button" title="Refresh" class="btn fa fa-refresh refresh"></button>
|
||||
<button type="submit" title="Upload File" value="Upload" class="btn fa fa-upload upload"><span></span></button>
|
||||
<button type="button" title="Download File" class="btn fa fa-download download" disabled><span></span></button>
|
||||
<button name="delete" type="button" title="Delete File/Folder" class="btn fa fa-trash delete" disabled><span></span></button>
|
||||
<button name="rename" type="button" title="Rename File/Folder" class="btn fa fa-pencil-square-o rename"><span></span></button>
|
||||
<button name="newfolder" type="button" title="Create new folder" value="New Folder" class="btn fa fa-folder-open create"><span></span></button>
|
||||
<button class="ON fa fa-th btn grid" type="button" title="View as grid"><span></span></button>
|
||||
<button type="button" class="btn fa fa-list list" title="View as Table"><span></span></button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="fileinfo">
|
||||
<form id="uploader" method="post" class='col-xs-12'>
|
||||
<div class="btn-group filemanager-path-group col-sm-7 col-xs-12" role="group">
|
||||
<button name="home" type="button" value="Home" title="Home" class="fa fa-home btn home"><span></span>
|
||||
</button>
|
||||
<button name="level-up" type="button" title="Back" value="LevelUp" class="btn fa fa-level-up level-up"
|
||||
disabled><span></span></button>
|
||||
<h1 title=''></h1>
|
||||
</div>
|
||||
<div class="btn-group filemanager-btn-group" role="group">
|
||||
<div class="uploadresponse"></div>
|
||||
<input class="mode" name="mode" type="hidden" value="add"/>
|
||||
<input class="currentpath" name="currentpath" type="hidden"/>
|
||||
<button type="button" title="Refresh" class="btn fa fa-refresh refresh"></button>
|
||||
<button type="submit" title="Upload File" value="Upload" class="btn fa fa-upload upload"><span></span>
|
||||
</button>
|
||||
<button type="button" title="Download File" class="btn fa fa-download download" disabled><span></span>
|
||||
</button>
|
||||
<button name="delete" type="button" title="Delete File/Folder" class="btn fa fa-trash delete" disabled>
|
||||
<span></span></button>
|
||||
<button name="rename" type="button" title="Rename File/Folder" class="btn fa fa-pencil-square-o rename">
|
||||
<span></span></button>
|
||||
<button name="newfolder" type="button" title="Create new folder" value="New Folder"
|
||||
class="btn fa fa-folder-open create"><span></span></button>
|
||||
<button class="ON fa fa-th btn grid" type="button" title="View as grid"><span></span></button>
|
||||
<button type="button" class="btn fa fa-list list" title="View as Table"><span></span></button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="fileinfo">
|
||||
<span class="activity">
|
||||
<img src="{{ url_for('browser.static', filename='css/aciTree/image/load-root.gif') }}">
|
||||
</span>
|
||||
<div class="file_listing"></div>
|
||||
<div class="upload_file dropzone"></div>
|
||||
<div class="allowed_file_types"></div>
|
||||
<div class='fm_dimmer'></div>
|
||||
<div class='delete_item'>
|
||||
<span>Are you sure you want to delete this item ?</span>
|
||||
<div class="file_listing"></div>
|
||||
<div class="upload_file dropzone"></div>
|
||||
<div class="allowed_file_types"></div>
|
||||
<div class='fm_dimmer'></div>
|
||||
<div class='delete_item'>
|
||||
<span>Are you sure you want to delete this item ?</span>
|
||||
<span class="pull-right">
|
||||
<button type='button' class='btn btn_yes'>YES</button>
|
||||
<button type='button' class='btn btn_no'>NO</button>
|
||||
</span>
|
||||
</div>
|
||||
<div class='replace_file'>
|
||||
<span>Are you sure you want to replace this file ?</span>
|
||||
</div>
|
||||
<div class='replace_file'>
|
||||
<span>Are you sure you want to replace this file ?</span>
|
||||
<span class="pull-right">
|
||||
<button type='button' class='btn btn_yes'>YES</button>
|
||||
<button type='button' class='btn btn_no'>NO</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -14,14 +14,15 @@ from pgadmin.utils import PgAdminModule
|
||||
|
||||
MODULE_NAME = 'sql'
|
||||
|
||||
class SQLModule(PgAdminModule):
|
||||
|
||||
class SQLModule(PgAdminModule):
|
||||
def get_own_javascripts(self):
|
||||
return [{
|
||||
'name': 'pgadmin.browser.object_sql',
|
||||
'path': url_for('sql.static', filename='js/sql'),
|
||||
'when': None
|
||||
}]
|
||||
}]
|
||||
|
||||
|
||||
# Initialise the module
|
||||
blueprint = SQLModule(MODULE_NAME, __name__, url_prefix='/misc/sql')
|
||||
|
||||
@@ -34,4 +34,4 @@ class StatisticsModule(PgAdminModule):
|
||||
# Initialise the module
|
||||
blueprint = StatisticsModule(
|
||||
MODULE_NAME, __name__, url_prefix='/misc/statistics'
|
||||
)
|
||||
)
|
||||
|
||||
@@ -25,10 +25,10 @@ db = SQLAlchemy()
|
||||
|
||||
# Define models
|
||||
roles_users = db.Table(
|
||||
'roles_users',
|
||||
db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
|
||||
db.Column('role_id', db.Integer(), db.ForeignKey('role.id'))
|
||||
)
|
||||
'roles_users',
|
||||
db.Column('user_id', db.Integer(), db.ForeignKey('user.id')),
|
||||
db.Column('role_id', db.Integer(), db.ForeignKey('role.id'))
|
||||
)
|
||||
|
||||
|
||||
class Version(db.Model):
|
||||
@@ -81,34 +81,35 @@ class Server(db.Model):
|
||||
__tablename__ = 'server'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
user_id = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('user.id'),
|
||||
nullable=False
|
||||
)
|
||||
db.Integer,
|
||||
db.ForeignKey('user.id'),
|
||||
nullable=False
|
||||
)
|
||||
servergroup_id = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('servergroup.id'),
|
||||
nullable=False
|
||||
)
|
||||
db.Integer,
|
||||
db.ForeignKey('servergroup.id'),
|
||||
nullable=False
|
||||
)
|
||||
name = db.Column(db.String(128), nullable=False)
|
||||
host = db.Column(db.String(128), nullable=False)
|
||||
port = db.Column(
|
||||
db.Integer(),
|
||||
db.CheckConstraint('port >= 1024 AND port <= 65534'),
|
||||
nullable=False)
|
||||
db.Integer(),
|
||||
db.CheckConstraint('port >= 1024 AND port <= 65534'),
|
||||
nullable=False)
|
||||
maintenance_db = db.Column(db.String(64), nullable=False)
|
||||
username = db.Column(db.String(64), nullable=False)
|
||||
password = db.Column(db.String(64), nullable=True)
|
||||
role = db.Column(db.String(64), nullable=True)
|
||||
ssl_mode = db.Column(
|
||||
db.String(16),
|
||||
db.CheckConstraint(
|
||||
"ssl_mode IN ('allow', 'prefer', 'require', 'disable', 'verify-ca', 'verify-full')"
|
||||
),
|
||||
nullable=False)
|
||||
db.String(16),
|
||||
db.CheckConstraint(
|
||||
"ssl_mode IN ('allow', 'prefer', 'require', 'disable', 'verify-ca', 'verify-full')"
|
||||
),
|
||||
nullable=False)
|
||||
comment = db.Column(
|
||||
db.String(1024),
|
||||
nullable=True)
|
||||
db.String(1024),
|
||||
nullable=True)
|
||||
|
||||
|
||||
class ModulePreference(db.Model):
|
||||
"""Define a preferences table for any modules."""
|
||||
@@ -116,6 +117,7 @@ class ModulePreference(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(256), nullable=False)
|
||||
|
||||
|
||||
class PreferenceCategory(db.Model):
|
||||
"""Define a preferences category for each modules."""
|
||||
__tablename__ = 'preference_category'
|
||||
@@ -124,9 +126,10 @@ class PreferenceCategory(db.Model):
|
||||
db.Integer,
|
||||
db.ForeignKey('module_preference.id'),
|
||||
nullable=False
|
||||
)
|
||||
)
|
||||
name = db.Column(db.String(256), nullable=False)
|
||||
|
||||
|
||||
class Preferences(db.Model):
|
||||
"""Define a particular preference."""
|
||||
__tablename__ = 'preferences'
|
||||
@@ -135,20 +138,22 @@ class Preferences(db.Model):
|
||||
db.Integer,
|
||||
db.ForeignKey('preference_category.id'),
|
||||
nullable=False
|
||||
)
|
||||
)
|
||||
name = db.Column(db.String(1024), nullable=False)
|
||||
|
||||
|
||||
class UserPreference(db.Model):
|
||||
"""Define the preference for a particular user."""
|
||||
__tablename__ = 'user_preferences'
|
||||
pid = db.Column(
|
||||
db.Integer, db.ForeignKey('preferences.id'), primary_key=True
|
||||
)
|
||||
)
|
||||
uid = db.Column(
|
||||
db.Integer, db.ForeignKey('user.id'), primary_key=True
|
||||
)
|
||||
)
|
||||
value = db.Column(db.String(1024), nullable=False)
|
||||
|
||||
|
||||
class DebuggerFunctionArguments(db.Model):
|
||||
"""Define the debugger input function arguments."""
|
||||
__tablename__ = 'debugger_function_arguments'
|
||||
@@ -158,14 +163,14 @@ class DebuggerFunctionArguments(db.Model):
|
||||
function_id = db.Column(db.Integer(), nullable=False, primary_key=True)
|
||||
arg_id = db.Column(db.Integer(), nullable=False, primary_key=True)
|
||||
is_null = db.Column(db.Integer(),
|
||||
db.CheckConstraint('is_null >= 0 AND is_null <= 1'),
|
||||
nullable=False)
|
||||
db.CheckConstraint('is_null >= 0 AND is_null <= 1'),
|
||||
nullable=False)
|
||||
is_expression = db.Column(db.Integer(),
|
||||
db.CheckConstraint('is_expression >= 0 AND is_expression <= 1'),
|
||||
nullable=False)
|
||||
db.CheckConstraint('is_expression >= 0 AND is_expression <= 1'),
|
||||
nullable=False)
|
||||
use_default = db.Column(db.Integer(),
|
||||
db.CheckConstraint('use_default >= 0 AND use_default <= 1'),
|
||||
nullable=False)
|
||||
db.CheckConstraint('use_default >= 0 AND use_default <= 1'),
|
||||
nullable=False)
|
||||
|
||||
value = db.Column(db.String(), nullable=True)
|
||||
|
||||
@@ -175,10 +180,10 @@ class Process(db.Model):
|
||||
__tablename__ = 'process'
|
||||
pid = db.Column(db.String(), nullable=False, primary_key=True)
|
||||
user_id = db.Column(
|
||||
db.Integer,
|
||||
db.ForeignKey('user.id'),
|
||||
nullable=False
|
||||
)
|
||||
db.Integer,
|
||||
db.ForeignKey('user.id'),
|
||||
nullable=False
|
||||
)
|
||||
command = db.Column(db.String(), nullable=False)
|
||||
desc = db.Column(db.String(), nullable=False)
|
||||
arguments = db.Column(db.String(), nullable=True)
|
||||
|
||||
@@ -26,6 +26,7 @@ from pgadmin.utils.preferences import Preferences
|
||||
|
||||
MODULE_NAME = 'preferences'
|
||||
|
||||
|
||||
class PreferencesModule(PgAdminModule):
|
||||
"""
|
||||
PreferenceModule represets the preferences of different modules to the
|
||||
@@ -56,6 +57,7 @@ class PreferencesModule(PgAdminModule):
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
blueprint = PreferencesModule(MODULE_NAME, __name__)
|
||||
|
||||
|
||||
@@ -64,10 +66,10 @@ blueprint = PreferencesModule(MODULE_NAME, __name__)
|
||||
def index():
|
||||
"""Render the preferences dialog."""
|
||||
return render_template(
|
||||
MODULE_NAME + "/index.html",
|
||||
username=current_user.email,
|
||||
_=gettext
|
||||
)
|
||||
MODULE_NAME + "/index.html",
|
||||
username=current_user.email,
|
||||
_=gettext
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route("/preferences.js")
|
||||
@@ -99,7 +101,7 @@ def preferences():
|
||||
"inode": True,
|
||||
"open": True,
|
||||
"branch": []
|
||||
}
|
||||
}
|
||||
|
||||
for c in m['categories']:
|
||||
oc = {
|
||||
@@ -109,7 +111,7 @@ def preferences():
|
||||
"inode": False,
|
||||
"open": False,
|
||||
"preferences": sorted(c['preferences'], key=label)
|
||||
}
|
||||
}
|
||||
|
||||
(om['branch']).append(oc)
|
||||
om['branch'] = sorted(om['branch'], key=label)
|
||||
@@ -117,9 +119,9 @@ def preferences():
|
||||
res.append(om)
|
||||
|
||||
return ajax_response(
|
||||
response=sorted(res, key=label),
|
||||
status=200
|
||||
)
|
||||
response=sorted(res, key=label),
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route("/preferences/<int:pid>", methods=["PUT"])
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<div id="options_dialog">
|
||||
<div id="options_tree" class="">
|
||||
ACI TREE
|
||||
</div>
|
||||
<div id='options_content'>
|
||||
Right hand side content
|
||||
</div>
|
||||
<div id="options_tree" class="">
|
||||
ACI TREE
|
||||
</div>
|
||||
<div id='options_content'>
|
||||
Right hand side content
|
||||
</div>
|
||||
</div>
|
||||
@@ -17,6 +17,7 @@ MODULE_NAME = 'redirects'
|
||||
blueprint = PgAdminModule(MODULE_NAME, __name__,
|
||||
url_prefix='/')
|
||||
|
||||
|
||||
@blueprint.route('/')
|
||||
@login_required
|
||||
def index():
|
||||
|
||||
@@ -25,7 +25,6 @@ MODULE_NAME = 'settings'
|
||||
|
||||
|
||||
class SettingsModule(PgAdminModule):
|
||||
|
||||
def get_own_javascripts(self):
|
||||
return [{
|
||||
'name': 'pgadmin.settings',
|
||||
@@ -45,6 +44,7 @@ class SettingsModule(PgAdminModule):
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
blueprint = SettingsModule(MODULE_NAME, __name__)
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ def get_setting(setting, default=None):
|
||||
def index():
|
||||
return bad_request(errormsg=_("This URL can not be called directly."))
|
||||
|
||||
|
||||
@blueprint.route("/settings.js")
|
||||
@login_required
|
||||
def script():
|
||||
@@ -80,6 +81,7 @@ def script():
|
||||
status=200,
|
||||
mimetype="application/javascript")
|
||||
|
||||
|
||||
@blueprint.route("/store", methods=['POST'])
|
||||
@blueprint.route("/store/<setting>/<value>", methods=['GET'])
|
||||
@login_required
|
||||
@@ -93,7 +95,7 @@ def store(setting=None, value=None):
|
||||
if request.method == 'POST':
|
||||
if 'count' in request.form:
|
||||
for x in range(int(request.form['count'])):
|
||||
store_setting(request.form['setting%d' % (x+1)], request.form['value%d' % (x+1)])
|
||||
store_setting(request.form['setting%d' % (x + 1)], request.form['value%d' % (x + 1)])
|
||||
else:
|
||||
store_setting(request.form['setting'], request.form['value'])
|
||||
else:
|
||||
@@ -107,12 +109,12 @@ def store(setting=None, value=None):
|
||||
except Exception as e:
|
||||
info = str(e)
|
||||
|
||||
|
||||
return make_json_response(success=success,
|
||||
errormsg=errormsg,
|
||||
info=info,
|
||||
result=request.form)
|
||||
|
||||
|
||||
@blueprint.route("/get", methods=['POST'])
|
||||
@blueprint.route("/get/<setting>", methods=['GET'])
|
||||
@blueprint.route("/get/<setting>/<default>", methods=['GET'])
|
||||
@@ -156,8 +158,7 @@ def reset_layout():
|
||||
db.session.commit()
|
||||
except Exception as e:
|
||||
return make_json_response(
|
||||
status=410, success=0, errormsg=str(e)
|
||||
)
|
||||
status=410, success=0, errormsg=str(e)
|
||||
)
|
||||
|
||||
return make_json_response(result=request.form)
|
||||
|
||||
|
||||
@@ -1,47 +1,62 @@
|
||||
<!DOCTYPE html>
|
||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
|
||||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
|
||||
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<!--[if lt IE 7]>
|
||||
<html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
|
||||
<!--[if IE 7]>
|
||||
<html class="no-js lt-ie9 lt-ie8"> <![endif]-->
|
||||
<!--[if IE 8]>
|
||||
<html class="no-js lt-ie9"> <![endif]-->
|
||||
<!--[if gt IE 8]><!-->
|
||||
<html class="no-js"> <!--<![endif]-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
|
||||
<title>{% block title %}{% endblock %}</title>
|
||||
<title>{% block title %}{% endblock %}</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="dcterms.rightsHolder" content="The pgAdmin Development Team">
|
||||
<meta name="dcterms.rights" content="All rights reserved">
|
||||
<meta name="dcterms.dateCopyrighted" content="2014 - 2015">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="dcterms.rightsHolder" content="The pgAdmin Development Team">
|
||||
<meta name="dcterms.rights" content="All rights reserved">
|
||||
<meta name="dcterms.dateCopyrighted" content="2014 - 2015">
|
||||
|
||||
<!-- Base template stylesheets -->
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.css' if config.DEBUG else 'css/bootstrap.min.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/alertifyjs/alertify.css' if config.DEBUG else 'css/alertifyjs/alertify.min.css') }}" />
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/alertifyjs/themes/bootstrap.css' if config.DEBUG else 'css/alertifyjs/themes/bootstrap.min.css') }}" />
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-theme.css' if config.DEBUG else 'css/bootstrap-theme.min.css') }}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/font-awesome.css' if config.DEBUG else 'css/font-awesome.min.css') }}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/font-mfizz.css') }}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-datepicker3.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-switch.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/backgrid/backgrid.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/backgrid/backgrid-select-all.css' if config.DEBUG else 'css/backgrid/backgrid-select-all.min.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/backgrid/backgrid-paginator.css' if config.DEBUG else 'css/backgrid/backgrid-paginator.min.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/backgrid/backgrid-filter.css' if config.DEBUG else 'css/backgrid/backgrid-filter.min.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/backgrid/backgrid-sizeable-columns.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/select2/select2.css' if config.DEBUG else 'css/select2/select2.min.css')}}"/>
|
||||
<!-- Base template stylesheets -->
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="{{ url_for('static', filename='css/bootstrap.css' if config.DEBUG else 'css/bootstrap.min.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="{{ url_for('static', filename='css/alertifyjs/alertify.css' if config.DEBUG else 'css/alertifyjs/alertify.min.css') }}"/>
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="{{ url_for('static', filename='css/alertifyjs/themes/bootstrap.css' if config.DEBUG else 'css/alertifyjs/themes/bootstrap.min.css') }}"/>
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="{{ url_for('static', filename='css/bootstrap-theme.css' if config.DEBUG else 'css/bootstrap-theme.min.css') }}"/>
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="{{ url_for('static', filename='css/font-awesome.css' if config.DEBUG else 'css/font-awesome.min.css') }}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/font-mfizz.css') }}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-datepicker3.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap-switch.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/backgrid/backgrid.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="{{ url_for('static', filename='css/backgrid/backgrid-select-all.css' if config.DEBUG else 'css/backgrid/backgrid-select-all.min.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="{{ url_for('static', filename='css/backgrid/backgrid-paginator.css' if config.DEBUG else 'css/backgrid/backgrid-paginator.min.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="{{ url_for('static', filename='css/backgrid/backgrid-filter.css' if config.DEBUG else 'css/backgrid/backgrid-filter.min.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="{{ url_for('static', filename='css/backgrid/backgrid-sizeable-columns.css')}}"/>
|
||||
<link type="text/css" rel="stylesheet"
|
||||
href="{{ url_for('static', filename='css/select2/select2.css' if config.DEBUG else 'css/select2/select2.min.css')}}"/>
|
||||
|
||||
<!-- View specified stylesheets -->
|
||||
{% for stylesheet in current_app.stylesheets %}
|
||||
<link type="text/css" rel="stylesheet" href="{{ stylesheet }}">
|
||||
{% endfor %}
|
||||
<!-- View specified stylesheets -->
|
||||
{% for stylesheet in current_app.stylesheets %}
|
||||
<link type="text/css" rel="stylesheet" href="{{ stylesheet }}">
|
||||
{% endfor %}
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/overrides.css') }}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/pgadmin.css') }}"/>
|
||||
{% block css_link %}{% endblock %}
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/overrides.css') }}"/>
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/pgadmin.css') }}"/>
|
||||
{% block css_link %}{% endblock %}
|
||||
|
||||
<!-- Base template scripts -->
|
||||
<script type="text/javascript" src="{{ url_for('static', filename='js/require.js' if config.DEBUG else 'js/require.min.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
<!-- Base template scripts -->
|
||||
<script type="text/javascript"
|
||||
src="{{ url_for('static', filename='js/require.js' if config.DEBUG else 'js/require.min.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
require.config({
|
||||
baseUrl: '',
|
||||
waitSeconds: 0,
|
||||
@@ -135,19 +150,22 @@
|
||||
'{{ script.name }}': "{{ script.path }}"{% endfor %}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<!-- View specified scripts -->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<!--[if lt IE 7]>
|
||||
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
|
||||
<![endif]-->
|
||||
</script>
|
||||
<!-- View specified scripts -->
|
||||
|
||||
{% block body %}{% endblock %}
|
||||
<script>
|
||||
</head>
|
||||
<body>
|
||||
<!--[if lt IE 7]>
|
||||
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade
|
||||
your browser</a> to improve your experience.</p>
|
||||
<![endif]-->
|
||||
|
||||
{% block body %}{% endblock %}
|
||||
<script>
|
||||
{% block init_script %}{% endblock %}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
{% block panel_title %}{{ _('%(appname)s Password Change', appname=config.APP_NAME) }}{% endblock %}
|
||||
{% block panel_body %}
|
||||
<form action="{{ url_for_security('change_password') }}" method="POST" name="change_password_form">
|
||||
{{ change_password_form.hidden_tag() }}
|
||||
<fieldset>
|
||||
{{ render_field_with_errors(change_password_form.password, "password") }}
|
||||
{{ render_field_with_errors(change_password_form.new_password, "password") }}
|
||||
{{ render_field_with_errors(change_password_form.new_password_confirm, "password") }}
|
||||
<input class="btn btn-lg btn-success btn-block" type="submit" value="{{ _('Change Password') }}">
|
||||
</fieldset>
|
||||
{{ change_password_form.hidden_tag() }}
|
||||
<fieldset>
|
||||
{{ render_field_with_errors(change_password_form.password, "password") }}
|
||||
{{ render_field_with_errors(change_password_form.new_password, "password") }}
|
||||
{{ render_field_with_errors(change_password_form.new_password_confirm, "password") }}
|
||||
<input class="btn btn-lg btn-success btn-block" type="submit" value="{{ _('Change Password') }}">
|
||||
</fieldset>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{% macro render_field_with_errors(field, type) %}
|
||||
<div class="form-group{% if field.errors %} has-error{% endif %}">
|
||||
<input class="form-control" placeholder="{{ field.label.text }}" name="{{ field.name }}" type="{% if type %}{{ type }}{% else %}{{ field.type }}{% endif %}">
|
||||
<input class="form-control" placeholder="{{ field.label.text }}" name="{{ field.name }}"
|
||||
type="{% if type %}{{ type }}{% else %}{{ field.type }}{% endif %}">
|
||||
</div>
|
||||
{% if field.errors %}
|
||||
{% for error in field.errors %}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
{% block panel_title %}{{ _('Recover %(appname)s Password', appname=config.APP_NAME) }}{% endblock %}
|
||||
{% block panel_body %}
|
||||
<p>{{ _('Enter the email address for the user account you wish to recover the password for:') }}</p>
|
||||
<form action="{{ url_for_security('forgot_password') }}" method="POST" name="forgot_password_form">
|
||||
<form action="{{ url_for_security('forgot_password') }}" method="POST" name="forgot_password_form">
|
||||
{{ forgot_password_form.hidden_tag() }}
|
||||
<fieldset>
|
||||
{{ render_field_with_errors(forgot_password_form.email, "text") }}
|
||||
<input class="btn btn-lg btn-success btn-block" type="submit" value="{{ _('Recover Password') }}">
|
||||
</fieldset>
|
||||
{{ render_field_with_errors(forgot_password_form.email, "text") }}
|
||||
<input class="btn btn-lg btn-success btn-block" type="submit" value="{{ _('Recover Password') }}">
|
||||
</fieldset>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
{% block panel_title %}{{ _('%(appname)s Login', appname=config.APP_NAME) }}{% endblock %}
|
||||
{% block panel_body %}
|
||||
<form action="{{ url_for_security('login') }}" method="POST" name="login_user_form">
|
||||
{{ login_user_form.hidden_tag() }}
|
||||
<fieldset>
|
||||
{{ render_field_with_errors(login_user_form.email, "text") }}
|
||||
{{ render_field_with_errors(login_user_form.password, "password") }}
|
||||
<input class="btn btn-lg btn-success btn-block" type="submit" value="{{ _('Login') }}">
|
||||
</fieldset>
|
||||
{{ login_user_form.hidden_tag() }}
|
||||
<fieldset>
|
||||
{{ render_field_with_errors(login_user_form.email, "text") }}
|
||||
{{ render_field_with_errors(login_user_form.password, "password") }}
|
||||
<input class="btn btn-lg btn-success btn-block" type="submit" value="{{ _('Login') }}">
|
||||
</fieldset>
|
||||
</form>
|
||||
<span class="help-block">{{ _('Forgotten your <a href="%(url)s">password</a>?', url=url_for('security.forgot_password')) }}</span>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
{%- with messages = get_flashed_messages(with_categories=true) -%}
|
||||
{% if messages %}
|
||||
<div style="position: fixed; top: 20px; right: 20px; width: 400px; z-index: 9999">
|
||||
{% for category, message in messages %}
|
||||
<div class="alert alert-{{ category }} alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="{{ _('Close') }}"><span aria-hidden="true">×</span></button>
|
||||
{% if messages %}
|
||||
<div style="position: fixed; top: 20px; right: 20px; width: 400px; z-index: 9999">
|
||||
{% for category, message in messages %}
|
||||
<div class="alert alert-{{ category }} alert-dismissible" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="{{ _('Close') }}"><span
|
||||
aria-hidden="true">×</span></button>
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{%- endwith %}
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
{% from "security/fields.html" import render_field_with_errors %}
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
{% include "security/messages.html" %}
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{% block panel_title %}{% endblock %}</h3>
|
||||
{% include "security/messages.html" %}
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{% block panel_title %}{% endblock %}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% block panel_body %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{% block panel_body %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% include 'security/watermark.html' %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
{% extends "security/panel.html" %}
|
||||
{% block panel_title %}{{ _('%(appname)s Password Reset', appname=config.APP_NAME) }}{% endblock %}
|
||||
{% block panel_body %}
|
||||
<form action="{{ url_for_security('reset_password', token=reset_password_token) }}" method="POST" name="reset_password_form">
|
||||
{{ reset_password_form.hidden_tag() }}
|
||||
<fieldset>
|
||||
{{ render_field_with_errors(reset_password_form.password, "password") }}
|
||||
{{ render_field_with_errors(reset_password_form.password_confirm, "password") }}
|
||||
<input class="btn btn-lg btn-success btn-block" type="submit" value="{{ _('Reset Password') }}">
|
||||
</fieldset>
|
||||
<form action="{{ url_for_security('reset_password', token=reset_password_token) }}" method="POST"
|
||||
name="reset_password_form">
|
||||
{{ reset_password_form.hidden_tag() }}
|
||||
<fieldset>
|
||||
{{ render_field_with_errors(reset_password_form.password, "password") }}
|
||||
{{ render_field_with_errors(reset_password_form.password_confirm, "password") }}
|
||||
<input class="btn btn-lg btn-success btn-block" type="submit" value="{{ _('Reset Password') }}">
|
||||
</fieldset>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
@@ -78,6 +78,7 @@ class BackupMessage(IProcessDesc):
|
||||
|
||||
Defines the message shown for the backup operation.
|
||||
"""
|
||||
|
||||
def __init__(self, _type, _sid, _bfile, **kwargs):
|
||||
self.backup_type = _type
|
||||
self.sid = _sid
|
||||
|
||||
@@ -19,7 +19,7 @@ from flask.ext.babel import gettext
|
||||
from flask.ext.security import login_required
|
||||
from pgadmin.tools.sqleditor.command import *
|
||||
from pgadmin.utils import PgAdminModule
|
||||
from pgadmin.utils.ajax import make_json_response, bad_request,\
|
||||
from pgadmin.utils.ajax import make_json_response, bad_request, \
|
||||
internal_server_error
|
||||
|
||||
from config import PG_DEFAULT_DRIVER
|
||||
@@ -62,7 +62,7 @@ def datagrid_css():
|
||||
return make_response(
|
||||
render_template('datagrid/css/datagrid.css'),
|
||||
200, {'Content-Type': 'text/css'}
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route("/filter")
|
||||
@@ -74,7 +74,7 @@ def show_filter():
|
||||
@blueprint.route(
|
||||
'/initialize/datagrid/<int:cmd_type>/<obj_type>/<int:sid>/<int:did>/<int:obj_id>',
|
||||
methods=["PUT", "POST"]
|
||||
)
|
||||
)
|
||||
@login_required
|
||||
def initialize_datagrid(cmd_type, obj_type, sid, did, obj_id):
|
||||
"""
|
||||
@@ -157,14 +157,15 @@ def panel(trans_id, is_query_tool, editor_title):
|
||||
is_query_tool=is_query_tool, editor_title=editor_title,
|
||||
script_type_url=sURL)
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/initialize/query_tool/<int:sid>/<int:did>',
|
||||
methods=["POST"]
|
||||
)
|
||||
)
|
||||
@blueprint.route(
|
||||
'/initialize/query_tool/<int:sid>',
|
||||
methods=["POST"]
|
||||
)
|
||||
)
|
||||
@login_required
|
||||
def initialize_query_tool(sid, did=None):
|
||||
"""
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="filter-textarea">
|
||||
<textarea id="sql_filter" row="5"></textarea>
|
||||
<style>
|
||||
.filter-textarea .CodeMirror-scroll {
|
||||
.filter-textarea .CodeMirror-scroll {
|
||||
min-height: 120px;
|
||||
max-height: 120px;
|
||||
}
|
||||
|
||||
@@ -1,237 +1,244 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}{{ config.APP_NAME }} - Datagrid{% endblock %}
|
||||
{% block css_link %}
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('sqleditor.static', filename='css/sqleditor.css') }}">
|
||||
<link type="text/css" rel="stylesheet" href="{{ url_for('sqleditor.static', filename='css/sqleditor.css') }}">
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
<style>
|
||||
body {
|
||||
padding: 0px;
|
||||
}
|
||||
body {
|
||||
padding: 0px;
|
||||
}
|
||||
</style>
|
||||
<div id="main-editor_panel">
|
||||
<div id="fetching_data" class="sql-editor-busy-fetching hide">
|
||||
<span class="sql-editor-busy-icon"><img src="{{ url_for('browser.static', filename='css/aciTree/image/load-root.gif') }}"></span>
|
||||
<span class="sql-editor-busy-text"></span>
|
||||
</div>
|
||||
<div class="sql-editor" data-trans-id="{{ uniqueId }}">
|
||||
<div id="main-editor_panel">
|
||||
<div id="fetching_data" class="sql-editor-busy-fetching hide">
|
||||
<span class="sql-editor-busy-icon"><img
|
||||
src="{{ url_for('browser.static', filename='css/aciTree/image/load-root.gif') }}"></span>
|
||||
<span class="sql-editor-busy-text"></span>
|
||||
</div>
|
||||
<div class="sql-editor" data-trans-id="{{ uniqueId }}">
|
||||
<div id="btn-toolbar" class="pg-prop-btn-group" role="toolbar" aria-label="">
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<button id="btn-load-file" type="button" class="btn btn-default btn-load-file" title="{{ _('Open File') }}">
|
||||
<i class="fa fa-folder-open-o" aria-hidden="true"></i>
|
||||
</button>
|
||||
<button id="btn-save" type="button" class="btn btn-default" title="{{ _('Save') }}" disabled>
|
||||
<i class="fa fa-floppy-o" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<button id="btn-copy-row" type="button" class="btn btn-default" title="{{ _('Copy Row') }}" disabled>
|
||||
<i class="fa fa-files-o" aria-hidden="true"></i>
|
||||
</button>
|
||||
<button id="btn-paste-row" type="button" class="btn btn-default" title="{{ _('Paste Row') }}" disabled>
|
||||
<i class="fa fa-clipboard" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<button id="btn-add-row" type="button" class="btn btn-default" title="{{ _('Add New Row') }}" disabled>
|
||||
<i class="fa fa-plus" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<button id="btn-filter" type="button" class="btn btn-default" title="{{ _('Filter') }}" disabled>
|
||||
<i class="fa fa-filter" aria-hidden="true"></i>
|
||||
</button>
|
||||
<button id="btn-filter-dropdown" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" disabled>
|
||||
<span class="caret"></span> <span class="sr-only">Toggle Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li>
|
||||
<a id="btn-remove-filter" href="#">{{ _('Remove') }}</a>
|
||||
<a id="btn-include-filter" href="#">{{ _('By selection') }}</a>
|
||||
<a id="btn-exclude-filter" href="#">{{ _('Exclude selection') }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<select class="limit" style="height: 30px; width: 90px;" disabled>
|
||||
<option value="-1">No limit</option>
|
||||
<option value="1000">1000 rows</option>
|
||||
<option value="500">500 rows</option>
|
||||
<option value="100">100 rows</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<button id="btn-flash" type="button" class="btn btn-default" style="width: 40px;" title="{{ _('Execute/Refresh (Ctrl+Shift+E)') }}">
|
||||
<i class="fa fa-bolt" aria-hidden="true"></i>
|
||||
</button>
|
||||
<button id="btn-query-dropdown" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="caret"></span> <span class="sr-only">Toggle Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu">
|
||||
<li>
|
||||
<a id="btn-explain" href="#">
|
||||
<span>{{ _('Explain (Ctrl+Shift+X)') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a id="btn-explain-analyze" href="#">
|
||||
<span>{{ _('Explain analyze (Ctrl+Shift+A)') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li class="dropdown-submenu dropdown-submenu">
|
||||
<a href="#">{{ _('Explain Options') }}</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a id="btn-explain-verbose" href="#" class="noclose">
|
||||
<i class="explain-verbose fa fa-check visibility-hidden" aria-hidden="true"></i>
|
||||
<span> {{ _('Verbose') }} </span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a id="btn-explain-costs" href="#" class="noclose">
|
||||
<i class="explain-costs fa fa-check visibility-hidden" aria-hidden="true"></i>
|
||||
<span> {{ _('Costs') }} </span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a id="btn-explain-buffers" href="#" class="noclose">
|
||||
<i class="explain-buffers fa fa-check visibility-hidden" aria-hidden="true"></i>
|
||||
<span> {{ _('Buffers') }} </span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a id="btn-explain-timing" href="#" class="noclose">
|
||||
<i class="explain-timing fa fa-check visibility-hidden" aria-hidden="true"></i>
|
||||
<span> {{ _('Timing') }} </span>
|
||||
</a>
|
||||
</li>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<button id="btn-load-file" type="button" class="btn btn-default btn-load-file"
|
||||
title="{{ _('Open File') }}">
|
||||
<i class="fa fa-folder-open-o" aria-hidden="true"></i>
|
||||
</button>
|
||||
<button id="btn-save" type="button" class="btn btn-default" title="{{ _('Save') }}" disabled>
|
||||
<i class="fa fa-floppy-o" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<button id="btn-copy-row" type="button" class="btn btn-default" title="{{ _('Copy Row') }}" disabled>
|
||||
<i class="fa fa-files-o" aria-hidden="true"></i>
|
||||
</button>
|
||||
<button id="btn-paste-row" type="button" class="btn btn-default" title="{{ _('Paste Row') }}" disabled>
|
||||
<i class="fa fa-clipboard" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<button id="btn-add-row" type="button" class="btn btn-default" title="{{ _('Add New Row') }}" disabled>
|
||||
<i class="fa fa-plus" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<button id="btn-filter" type="button" class="btn btn-default" title="{{ _('Filter') }}" disabled>
|
||||
<i class="fa fa-filter" aria-hidden="true"></i>
|
||||
</button>
|
||||
<button id="btn-filter-dropdown" type="button" class="btn btn-default dropdown-toggle"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" disabled>
|
||||
<span class="caret"></span> <span class="sr-only">Toggle Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-right">
|
||||
<li>
|
||||
<a id="btn-remove-filter" href="#">{{ _('Remove') }}</a>
|
||||
<a id="btn-include-filter" href="#">{{ _('By selection') }}</a>
|
||||
<a id="btn-exclude-filter" href="#">{{ _('Exclude selection') }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<a id="btn-auto-commit" href="#">
|
||||
<i class="auto-commit fa fa-check visibility-hidden" aria-hidden="true"></i>
|
||||
<span> {{ _('Auto-Commit') }} </span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a id="btn-auto-rollback" href="#">
|
||||
<i class="auto-rollback fa fa-check visibility-hidden" aria-hidden="true"></i>
|
||||
<span> {{ _('Auto-Rollback') }} </span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<button id="btn-cancel-query" type="button" class="btn btn-default" title="{{ _('Cancel query') }}" disabled>
|
||||
<i class="fa fa-stop" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<button id="btn-edit" type="button" class="btn btn-default" title="{{ _('Edit') }}">
|
||||
<i class="fa fa-pencil-square-o" aria-hidden="true"></i>
|
||||
</button>
|
||||
<button id="btn-edit-dropdown" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="caret"></span> <span class="sr-only">Toggle Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu">
|
||||
<li>
|
||||
<a id="btn-clear" href="#">
|
||||
<i class="fa fa-eraser" aria-hidden="true"></i>
|
||||
<span> {{ _('Clear query window') }} </span>
|
||||
</a>
|
||||
<a id="btn-clear-history" href="#">
|
||||
<i class="fa fa-eraser" aria-hidden="true"></i>
|
||||
<span> {{ _('Clear history') }} </span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<button id="btn-download" type="button" class="btn btn-default" title="{{ _('Download as CSV') }}">
|
||||
<i class="fa fa-download" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<select class="limit" style="height: 30px; width: 90px;" disabled>
|
||||
<option value="-1">No limit</option>
|
||||
<option value="1000">1000 rows</option>
|
||||
<option value="500">500 rows</option>
|
||||
<option value="100">100 rows</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<button id="btn-flash" type="button" class="btn btn-default" style="width: 40px;"
|
||||
title="{{ _('Execute/Refresh (Ctrl+Shift+E)') }}">
|
||||
<i class="fa fa-bolt" aria-hidden="true"></i>
|
||||
</button>
|
||||
<button id="btn-query-dropdown" type="button" class="btn btn-default dropdown-toggle"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="caret"></span> <span class="sr-only">Toggle Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu">
|
||||
<li>
|
||||
<a id="btn-explain" href="#">
|
||||
<span>{{ _('Explain (Ctrl+Shift+X)') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a id="btn-explain-analyze" href="#">
|
||||
<span>{{ _('Explain analyze (Ctrl+Shift+A)') }}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li class="dropdown-submenu dropdown-submenu">
|
||||
<a href="#">{{ _('Explain Options') }}</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a id="btn-explain-verbose" href="#" class="noclose">
|
||||
<i class="explain-verbose fa fa-check visibility-hidden" aria-hidden="true"></i>
|
||||
<span> {{ _('Verbose') }} </span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a id="btn-explain-costs" href="#" class="noclose">
|
||||
<i class="explain-costs fa fa-check visibility-hidden" aria-hidden="true"></i>
|
||||
<span> {{ _('Costs') }} </span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a id="btn-explain-buffers" href="#" class="noclose">
|
||||
<i class="explain-buffers fa fa-check visibility-hidden" aria-hidden="true"></i>
|
||||
<span> {{ _('Buffers') }} </span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a id="btn-explain-timing" href="#" class="noclose">
|
||||
<i class="explain-timing fa fa-check visibility-hidden" aria-hidden="true"></i>
|
||||
<span> {{ _('Timing') }} </span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<li>
|
||||
<a id="btn-auto-commit" href="#">
|
||||
<i class="auto-commit fa fa-check visibility-hidden" aria-hidden="true"></i>
|
||||
<span> {{ _('Auto-Commit') }} </span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a id="btn-auto-rollback" href="#">
|
||||
<i class="auto-rollback fa fa-check visibility-hidden" aria-hidden="true"></i>
|
||||
<span> {{ _('Auto-Rollback') }} </span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<button id="btn-cancel-query" type="button" class="btn btn-default" title="{{ _('Cancel query') }}"
|
||||
disabled>
|
||||
<i class="fa fa-stop" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<button id="btn-edit" type="button" class="btn btn-default" title="{{ _('Edit') }}">
|
||||
<i class="fa fa-pencil-square-o" aria-hidden="true"></i>
|
||||
</button>
|
||||
<button id="btn-edit-dropdown" type="button" class="btn btn-default dropdown-toggle"
|
||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="caret"></span> <span class="sr-only">Toggle Dropdown</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu">
|
||||
<li>
|
||||
<a id="btn-clear" href="#">
|
||||
<i class="fa fa-eraser" aria-hidden="true"></i>
|
||||
<span> {{ _('Clear query window') }} </span>
|
||||
</a>
|
||||
<a id="btn-clear-history" href="#">
|
||||
<i class="fa fa-eraser" aria-hidden="true"></i>
|
||||
<span> {{ _('Clear history') }} </span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="btn-group" role="group" aria-label="">
|
||||
<button id="btn-download" type="button" class="btn btn-default" title="{{ _('Download as CSV') }}">
|
||||
<i class="fa fa-download" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="editor-title"></div>
|
||||
<div id="filter" class="filter-container hidden">
|
||||
<div class="filter-title">Filter</div>
|
||||
<div class="sql-textarea">
|
||||
<textarea id="sql_filter" row="5"></textarea>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button id="btn-cancel" type="button" class="btn btn-danger" title="{{ _('Cancel') }}">
|
||||
<i class="fa fa-times" aria-hidden="true"></i> {{ _('Cancel') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button id="btn-apply" type="button" class="btn btn-primary" title="{{ _('Apply') }}">
|
||||
<i class="fa fa-check" aria-hidden="true"></i> {{ _('Apply') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="filter-title">Filter</div>
|
||||
<div class="sql-textarea">
|
||||
<textarea id="sql_filter" row="5"></textarea>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button id="btn-cancel" type="button" class="btn btn-danger" title="{{ _('Cancel') }}">
|
||||
<i class="fa fa-times" aria-hidden="true"></i> {{ _('Cancel') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button id="btn-apply" type="button" class="btn btn-primary" title="{{ _('Apply') }}">
|
||||
<i class="fa fa-check" aria-hidden="true"></i> {{ _('Apply') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="editor-panel"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block init_script %}
|
||||
try {
|
||||
require(
|
||||
['jquery', 'pgadmin', 'pgadmin.sqleditor'],
|
||||
function($, pgAdmin) {
|
||||
require(
|
||||
['jquery', 'pgadmin', 'pgadmin.sqleditor'],
|
||||
function($, pgAdmin) {
|
||||
|
||||
var editorPanel = $('.sql-editor'),
|
||||
loadingDiv = $('#fetching_data'),
|
||||
msgDiv = loadingDiv.find('.sql-editor-busy-text');
|
||||
var editorPanel = $('.sql-editor'),
|
||||
loadingDiv = $('#fetching_data'),
|
||||
msgDiv = loadingDiv.find('.sql-editor-busy-text');
|
||||
|
||||
// Get the controller object from pgAdmin.SqlEditor
|
||||
var sqlEditorController = pgAdmin.SqlEditor.create(editorPanel);
|
||||
// Get the controller object from pgAdmin.SqlEditor
|
||||
var sqlEditorController = pgAdmin.SqlEditor.create(editorPanel);
|
||||
|
||||
// Listen on events to show/hide loading-icon and change messages.
|
||||
sqlEditorController.on('pgadmin-sqleditor:loading-icon:message', function(msg) {
|
||||
msgDiv.text(msg);
|
||||
}).on('pgadmin-sqleditor:loading-icon:show', function(msg) {
|
||||
loadingDiv.removeClass('hide');
|
||||
msgDiv.text(msg);
|
||||
}).on('pgadmin-sqleditor:loading-icon:hide', function() {
|
||||
if (!loadingDiv.hasClass('hide')) {
|
||||
loadingDiv.addClass('hide');
|
||||
}
|
||||
});
|
||||
// Listen on events to show/hide loading-icon and change messages.
|
||||
sqlEditorController.on('pgadmin-sqleditor:loading-icon:message', function(msg) {
|
||||
msgDiv.text(msg);
|
||||
}).on('pgadmin-sqleditor:loading-icon:show', function(msg) {
|
||||
loadingDiv.removeClass('hide');
|
||||
msgDiv.text(msg);
|
||||
}).on('pgadmin-sqleditor:loading-icon:hide', function() {
|
||||
if (!loadingDiv.hasClass('hide')) {
|
||||
loadingDiv.addClass('hide');
|
||||
}
|
||||
});
|
||||
|
||||
// Fetch the SQL for Scripts (eg: CREATE/UPDATE/DELETE/SELECT)
|
||||
var script_sql = '';
|
||||
{% if script_type_url%}
|
||||
// Call AJAX only if script type url is present
|
||||
$.ajax({
|
||||
url: '{{ script_type_url }}',
|
||||
type:'GET',
|
||||
async: false,
|
||||
success: function(res) {
|
||||
script_sql = res;
|
||||
},
|
||||
error: function(jqx) {
|
||||
var msg = jqx.responseText;
|
||||
/* Error from the server */
|
||||
if (jqx.status == 410 || jqx.status == 500) {
|
||||
try {
|
||||
var data = $.parseJSON(jqx.responseText);
|
||||
msg = data.errormsg;
|
||||
} catch (e) {}
|
||||
}
|
||||
pgBrowser.report_error(
|
||||
S('{{ _('Error fetching sql for script: "%%s"') }}')
|
||||
.sprintf(msg)
|
||||
.value(), msg);
|
||||
}
|
||||
});
|
||||
{% endif %}
|
||||
// Fetch the SQL for Scripts (eg: CREATE/UPDATE/DELETE/SELECT)
|
||||
var script_sql = '';
|
||||
{% if script_type_url%}
|
||||
// Call AJAX only if script type url is present
|
||||
$.ajax({
|
||||
url: '{{ script_type_url }}',
|
||||
type:'GET',
|
||||
async: false,
|
||||
success: function(res) {
|
||||
script_sql = res;
|
||||
},
|
||||
error: function(jqx) {
|
||||
var msg = jqx.responseText;
|
||||
/* Error from the server */
|
||||
if (jqx.status == 410 || jqx.status == 500) {
|
||||
try {
|
||||
var data = $.parseJSON(jqx.responseText);
|
||||
msg = data.errormsg;
|
||||
} catch (e) {}
|
||||
}
|
||||
pgBrowser.report_error(
|
||||
S('{{ _('Error fetching sql for script: "%%s"') }}')
|
||||
.sprintf(msg)
|
||||
.value(), msg);
|
||||
}
|
||||
});
|
||||
{% endif %}
|
||||
|
||||
// Start the query tool.
|
||||
sqlEditorController.start({{ is_query_tool }}, "{{ editor_title }}", script_sql);
|
||||
});
|
||||
// Start the query tool.
|
||||
sqlEditorController.start({{ is_query_tool }}, "{{ editor_title }}", script_sql);
|
||||
});
|
||||
} catch (err) {
|
||||
/* Show proper error dialog */
|
||||
console.log(err);
|
||||
/* Show proper error dialog */
|
||||
console.log(err);
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
@@ -46,18 +46,19 @@ class DebuggerModule(PgAdminModule):
|
||||
def get_own_javascripts(self):
|
||||
scripts = list()
|
||||
for name, script in [
|
||||
['pgadmin.tools.debugger.controller', 'js/debugger'],
|
||||
['pgadmin.tools.debugger.ui', 'js/debugger_ui'],
|
||||
['pgadmin.tools.debugger.direct', 'js/direct']
|
||||
]:
|
||||
['pgadmin.tools.debugger.controller', 'js/debugger'],
|
||||
['pgadmin.tools.debugger.ui', 'js/debugger_ui'],
|
||||
['pgadmin.tools.debugger.direct', 'js/direct']
|
||||
]:
|
||||
scripts.append({
|
||||
'name': name,
|
||||
'path': url_for('debugger.index') + script,
|
||||
'when': None
|
||||
})
|
||||
})
|
||||
|
||||
return scripts
|
||||
|
||||
|
||||
blueprint = DebuggerModule(MODULE_NAME, __name__)
|
||||
|
||||
|
||||
@@ -148,7 +149,8 @@ def init_function(node_type, sid, did, scid, fid):
|
||||
# Set the template path required to read the sql files
|
||||
template_path = 'debugger/sql'
|
||||
|
||||
sql = render_template("/".join([template_path, 'get_function_debug_info.sql']), is_ppas_database=ppas_server, hasFeatureFunctionDefaults= True, fid=fid)
|
||||
sql = render_template("/".join([template_path, 'get_function_debug_info.sql']), is_ppas_database=ppas_server,
|
||||
hasFeatureFunctionDefaults=True, fid=fid)
|
||||
status, r_set = conn.execute_dict(sql)
|
||||
if not status:
|
||||
current_app.logger.debug("Error retrieving function information from database")
|
||||
@@ -179,7 +181,8 @@ def init_function(node_type, sid, did, scid, fid):
|
||||
if "plugin_debugger" not in rid_pre:
|
||||
ret_status = False
|
||||
|
||||
status_in, rid_tar = conn.execute_scalar("SELECT count(*) FROM pg_proc WHERE proname = 'pldbg_get_target_info'")
|
||||
status_in, rid_tar = conn.execute_scalar(
|
||||
"SELECT count(*) FROM pg_proc WHERE proname = 'pldbg_get_target_info'")
|
||||
if not status_in:
|
||||
current_app.logger.debug("Could not fetch debugger target information.")
|
||||
return internal_server_error(gettext("Could not fetch debugger target information."))
|
||||
@@ -247,9 +250,9 @@ def init_function(node_type, sid, did, scid, fid):
|
||||
session['funcData'] = function_data
|
||||
|
||||
return make_json_response(
|
||||
data=r_set['rows'],
|
||||
status=200
|
||||
)
|
||||
data=r_set['rows'],
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route('/direct/<int:trans_id>', methods=['GET'])
|
||||
@@ -272,10 +275,11 @@ def direct_new(trans_id):
|
||||
uniqueId=trans_id,
|
||||
debug_type=debug_type,
|
||||
stylesheets=[url_for('debugger.static', filename='css/debugger.css')]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route('/initialize_target/<debug_type>/<int:sid>/<int:did>/<int:scid>/<int:func_id>', methods=['GET', 'POST'])
|
||||
@blueprint.route('/initialize_target/<debug_type>/<int:sid>/<int:did>/<int:scid>/<int:func_id>',
|
||||
methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def initialize_target(debug_type, sid, did, scid, func_id):
|
||||
"""
|
||||
@@ -324,10 +328,10 @@ def initialize_target(debug_type, sid, did, scid, func_id):
|
||||
|
||||
# Find out the debugger version and store it in session variables
|
||||
status, rid = conn.execute_scalar(
|
||||
"SELECT COUNT(*) FROM pg_catalog.pg_proc p \
|
||||
LEFT JOIN pg_catalog.pg_namespace n ON p.pronamespace = n.oid \
|
||||
WHERE n.nspname = ANY(current_schemas(false)) AND p.proname = 'pldbg_get_proxy_info';"
|
||||
)
|
||||
"SELECT COUNT(*) FROM pg_catalog.pg_proc p \
|
||||
LEFT JOIN pg_catalog.pg_namespace n ON p.pronamespace = n.oid \
|
||||
WHERE n.nspname = ANY(current_schemas(false)) AND p.proname = 'pldbg_get_proxy_info';"
|
||||
)
|
||||
|
||||
if not status:
|
||||
return internal_server_error(errormsg=rid)
|
||||
@@ -369,7 +373,7 @@ def initialize_target(debug_type, sid, did, scid, func_id):
|
||||
'debugger_version': debugger_version,
|
||||
'frame_id': 0,
|
||||
'restart_debug': 0
|
||||
}
|
||||
}
|
||||
|
||||
# Store the grid dictionary into the session variable
|
||||
session['debuggerData'] = debugger_data
|
||||
@@ -574,7 +578,8 @@ def start_debugger_listener(trans_id):
|
||||
str_query = ''
|
||||
|
||||
# Form the function name with schema name
|
||||
func_name = driver.qtIdent(conn, session['functionData'][str(trans_id)]['schema']) + '.' + driver.qtIdent(conn, session['functionData'][str(trans_id)]['name'])
|
||||
func_name = driver.qtIdent(conn, session['functionData'][str(trans_id)]['schema']) + '.' + driver.qtIdent(
|
||||
conn, session['functionData'][str(trans_id)]['name'])
|
||||
|
||||
if obj['restart_debug'] == 0:
|
||||
# render the SQL template and send the query to server
|
||||
@@ -621,19 +626,21 @@ def start_debugger_listener(trans_id):
|
||||
# Below are two different template to execute and start executer
|
||||
if manager.server_type != 'pg' and manager.version < 90300:
|
||||
str_query = render_template("/".join(['debugger/sql', 'execute_edbspl.sql']),
|
||||
func_name=func_name, is_func=session['functionData'][str(trans_id)]['is_func'],
|
||||
lan_name=session['functionData'][str(trans_id)]['language'],
|
||||
ret_type=session['functionData'][str(trans_id)]['return_type'],
|
||||
data=session['functionData'][str(trans_id)]['args_value'],
|
||||
arg_type=arg_type,
|
||||
args_mode=arg_mode
|
||||
)
|
||||
func_name=func_name,
|
||||
is_func=session['functionData'][str(trans_id)]['is_func'],
|
||||
lan_name=session['functionData'][str(trans_id)]['language'],
|
||||
ret_type=session['functionData'][str(trans_id)]['return_type'],
|
||||
data=session['functionData'][str(trans_id)]['args_value'],
|
||||
arg_type=arg_type,
|
||||
args_mode=arg_mode
|
||||
)
|
||||
else:
|
||||
str_query = render_template("/".join(['debugger/sql', 'execute_plpgsql.sql']),
|
||||
func_name=func_name, is_func=session['functionData'][str(trans_id)]['is_func'],
|
||||
ret_type=session['functionData'][str(trans_id)]['return_type'],
|
||||
data=session['functionData'][str(trans_id)]['args_value']
|
||||
)
|
||||
func_name=func_name,
|
||||
is_func=session['functionData'][str(trans_id)]['is_func'],
|
||||
ret_type=session['functionData'][str(trans_id)]['return_type'],
|
||||
data=session['functionData'][str(trans_id)]['args_value']
|
||||
)
|
||||
|
||||
status, result = conn.execute_async(str_query)
|
||||
if not status:
|
||||
@@ -814,10 +821,10 @@ def messages(trans_id):
|
||||
tmpOffset = 0
|
||||
tmpFlag = False
|
||||
|
||||
while notify[0][offset+str_len+tmpOffset].isdigit():
|
||||
while notify[0][offset + str_len + tmpOffset].isdigit():
|
||||
status = 'Success'
|
||||
tmpFlag = True
|
||||
port_number = port_number + notify[0][offset+str_len+tmpOffset]
|
||||
port_number = port_number + notify[0][offset + str_len + tmpOffset]
|
||||
tmpOffset = tmpOffset + 1
|
||||
|
||||
if tmpFlag == False:
|
||||
@@ -1006,7 +1013,7 @@ def clear_all_breakpoint(trans_id):
|
||||
line_numbers = request.form['breakpoint_list'].split(",")
|
||||
for line_no in line_numbers:
|
||||
sql = render_template("/".join([template_path, "clear_breakpoint.sql"]), session_id=obj['session_id'],
|
||||
foid=obj['function_id'], line_number=line_no)
|
||||
foid=obj['function_id'], line_number=line_no)
|
||||
|
||||
status, result = conn.execute_dict(sql)
|
||||
if not status:
|
||||
@@ -1069,7 +1076,8 @@ def deposit_parameter_value(trans_id):
|
||||
info = gettext('Value deposited successfully')
|
||||
else:
|
||||
info = gettext('Error while setting the value')
|
||||
return make_json_response(data={'status': status, 'info':info, 'result': result['rows'][0]['pldbg_deposit_value']})
|
||||
return make_json_response(
|
||||
data={'status': status, 'info': info, 'result': result['rows'][0]['pldbg_deposit_value']})
|
||||
else:
|
||||
status = False
|
||||
result = gettext('Not connected to server or connection with the server has been closed.')
|
||||
@@ -1115,7 +1123,7 @@ def select_frame(trans_id, frame_id):
|
||||
|
||||
if conn.connected():
|
||||
sql = render_template("/".join([template_path, "select_frame.sql"]), session_id=obj['session_id'],
|
||||
frame_id=frame_id)
|
||||
frame_id=frame_id)
|
||||
|
||||
status, result = conn.execute_dict(sql)
|
||||
if not status:
|
||||
@@ -1148,22 +1156,22 @@ def get_arguments_sqlite(sid, did, scid, func_id):
|
||||
|
||||
"""Get the count of the existing data available in sqlite database"""
|
||||
DbgFuncArgsCount = DebuggerFunctionArguments.query.filter_by(
|
||||
server_id=sid, database_id=did, schema_id=scid, function_id=func_id).count()
|
||||
server_id=sid, database_id=did, schema_id=scid, function_id=func_id).count()
|
||||
|
||||
args_data = []
|
||||
|
||||
if DbgFuncArgsCount:
|
||||
"""Update the Debugger Function Arguments settings"""
|
||||
DbgFuncArgs = DebuggerFunctionArguments.query.filter_by(
|
||||
server_id=sid, database_id=did, schema_id=scid, function_id=func_id)
|
||||
server_id=sid, database_id=did, schema_id=scid, function_id=func_id)
|
||||
|
||||
args_list = DbgFuncArgs.all()
|
||||
|
||||
for i in range(0, DbgFuncArgsCount):
|
||||
info = {
|
||||
"arg_id": args_list[i].arg_id,
|
||||
"is_null": args_list[i].is_null,
|
||||
"is_expression": args_list[i].is_expression,
|
||||
"is_null": args_list[i].is_null,
|
||||
"is_expression": args_list[i].is_expression,
|
||||
"use_default": args_list[i].use_default,
|
||||
"value": args_list[i].value
|
||||
}
|
||||
@@ -1201,8 +1209,8 @@ def set_arguments_sqlite(sid, did, scid, func_id):
|
||||
try:
|
||||
for i in range(0, len(data)):
|
||||
DbgFuncArgsExists = DebuggerFunctionArguments.query.filter_by(
|
||||
server_id=data[i]['server_id'], database_id=data[i]['database_id'], schema_id=data[i]['schema_id'],
|
||||
function_id=data[i]['function_id'], arg_id=data[i]['arg_id']).count()
|
||||
server_id=data[i]['server_id'], database_id=data[i]['database_id'], schema_id=data[i]['schema_id'],
|
||||
function_id=data[i]['function_id'], arg_id=data[i]['arg_id']).count()
|
||||
|
||||
# handle the Array list sent from the client
|
||||
array_string = ''
|
||||
@@ -1219,8 +1227,8 @@ def set_arguments_sqlite(sid, did, scid, func_id):
|
||||
# Check if data is already available in database then update the existing value otherwise add the new value
|
||||
if DbgFuncArgsExists:
|
||||
DbgFuncArgs = DebuggerFunctionArguments.query.filter_by(
|
||||
server_id=data[i]['server_id'], database_id=data[i]['database_id'], schema_id=data[i]['schema_id'],
|
||||
function_id=data[i]['function_id'], arg_id=data[i]['arg_id']).first()
|
||||
server_id=data[i]['server_id'], database_id=data[i]['database_id'], schema_id=data[i]['schema_id'],
|
||||
function_id=data[i]['function_id'], arg_id=data[i]['arg_id']).first()
|
||||
|
||||
DbgFuncArgs.is_null = data[i]['is_null']
|
||||
DbgFuncArgs.is_expression = data[i]['is_expression']
|
||||
@@ -1228,15 +1236,15 @@ def set_arguments_sqlite(sid, did, scid, func_id):
|
||||
DbgFuncArgs.value = array_string
|
||||
else:
|
||||
debugger_func_args = DebuggerFunctionArguments(
|
||||
server_id = data[i]['server_id'],
|
||||
database_id = data[i]['database_id'],
|
||||
schema_id = data[i]['schema_id'],
|
||||
function_id = data[i]['function_id'],
|
||||
arg_id = data[i]['arg_id'],
|
||||
is_null = data[i]['is_null'],
|
||||
is_expression = data[i]['is_expression'],
|
||||
use_default = data[i]['use_default'],
|
||||
value = array_string
|
||||
server_id=data[i]['server_id'],
|
||||
database_id=data[i]['database_id'],
|
||||
schema_id=data[i]['schema_id'],
|
||||
function_id=data[i]['function_id'],
|
||||
arg_id=data[i]['arg_id'],
|
||||
is_null=data[i]['is_null'],
|
||||
is_expression=data[i]['is_expression'],
|
||||
use_default=data[i]['use_default'],
|
||||
value=array_string
|
||||
)
|
||||
|
||||
db.session.add(debugger_func_args)
|
||||
@@ -1289,17 +1297,17 @@ def poll_end_execution_result(trans_id):
|
||||
if 'ERROR' in result:
|
||||
status = 'ERROR'
|
||||
return make_json_response(info=gettext("Execution completed with error"),
|
||||
data={'status': status, 'status_message': result})
|
||||
data={'status': status, 'status_message': result})
|
||||
else:
|
||||
status = 'Success'
|
||||
data = {}
|
||||
for i in result:
|
||||
for k, v in i.items():
|
||||
data["name"] = k
|
||||
data.setdefault("value",[]).append(v)
|
||||
data.setdefault("value", []).append(v)
|
||||
|
||||
return make_json_response(success=1, info=gettext("Execution Completed."),
|
||||
data={'status': status, 'result': data, 'status_message': statusmsg})
|
||||
data={'status': status, 'result': data, 'status_message': statusmsg})
|
||||
else:
|
||||
status = 'Busy'
|
||||
else:
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
{% block title %}{{ _('Debugger - ') + function_name }}{% endblock %}
|
||||
{% block init_script %}
|
||||
try {
|
||||
require(
|
||||
['pgadmin', 'pgadmin.tools.debugger.direct'],
|
||||
function(pgAdmin, pgDirectDebug) {
|
||||
pgDirectDebug.init({{ uniqueId }}, {{ debug_type }});
|
||||
},
|
||||
function() {
|
||||
/* TODO:: Show proper error dialog */
|
||||
console.log(arguments);
|
||||
});
|
||||
require(
|
||||
['pgadmin', 'pgadmin.tools.debugger.direct'],
|
||||
function(pgAdmin, pgDirectDebug) {
|
||||
pgDirectDebug.init({{ uniqueId }}, {{ debug_type }});
|
||||
},
|
||||
function() {
|
||||
/* TODO:: Show proper error dialog */
|
||||
console.log(arguments);
|
||||
});
|
||||
} catch (err) {
|
||||
/* Show proper error dialog */
|
||||
console.log(err);
|
||||
/* Show proper error dialog */
|
||||
console.log(err);
|
||||
}
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
|
||||
@@ -45,6 +45,7 @@ class GrantWizardModule(PgAdminModule):
|
||||
|
||||
LABEL = gettext('Browser')
|
||||
"""
|
||||
|
||||
def get_own_stylesheets(self):
|
||||
"""
|
||||
Returns:
|
||||
@@ -53,7 +54,7 @@ class GrantWizardModule(PgAdminModule):
|
||||
stylesheets = [
|
||||
url_for('browser.static', filename='css/wizard.css'),
|
||||
url_for('grant_wizard.static', filename='css/grant_wizard.css')
|
||||
]
|
||||
]
|
||||
return stylesheets
|
||||
|
||||
def get_own_javascripts(self):
|
||||
@@ -86,8 +87,9 @@ class GrantWizardModule(PgAdminModule):
|
||||
"""
|
||||
self.browser_preference = Preferences.module('browser')
|
||||
self.pref_show_system_objects = self.browser_preference.preference(
|
||||
'show_system_objects'
|
||||
)
|
||||
'show_system_objects'
|
||||
)
|
||||
|
||||
|
||||
# Create blueprint for GrantWizardModule class
|
||||
blueprint = GrantWizardModule(
|
||||
@@ -103,6 +105,7 @@ def check_precondition(f):
|
||||
Assumptions:
|
||||
This function will always be used as decorator of a class method.
|
||||
"""
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
@@ -110,7 +113,7 @@ def check_precondition(f):
|
||||
server_info.clear()
|
||||
server_info['manager'] = get_driver(
|
||||
PG_DEFAULT_DRIVER).connection_manager(
|
||||
kwargs['sid']
|
||||
kwargs['sid']
|
||||
)
|
||||
server_info['conn'] = server_info['manager'].connection(
|
||||
did=kwargs['did']
|
||||
@@ -145,9 +148,9 @@ def index():
|
||||
def script():
|
||||
"""render own javascript"""
|
||||
return Response(response=render_template(
|
||||
"grant_wizard/js/grant_wizard.js", _=gettext),
|
||||
status=200,
|
||||
mimetype="application/javascript")
|
||||
"grant_wizard/js/grant_wizard.js", _=gettext),
|
||||
status=200,
|
||||
mimetype="application/javascript")
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
@@ -158,9 +161,9 @@ def acl_list(gid, sid, did):
|
||||
"""render list of acls"""
|
||||
server_prop = server_info
|
||||
return Response(response=render_template(
|
||||
server_prop['template_path']+"/acl.json", _=gettext),
|
||||
status=200,
|
||||
mimetype="application/json")
|
||||
server_prop['template_path'] + "/acl.json", _=gettext),
|
||||
status=200,
|
||||
mimetype="application/json")
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
@@ -202,7 +205,7 @@ def properties(gid, sid, did, node_id, node_type):
|
||||
else:
|
||||
SQL = render_template("/".join(
|
||||
[server_prop['template_path'], '/sql/get_schemas.sql']),
|
||||
nspid=node_id, show_sysobj=False)
|
||||
nspid=node_id, show_sysobj=False)
|
||||
status, res = conn.execute_dict(SQL)
|
||||
|
||||
if not status:
|
||||
@@ -231,8 +234,8 @@ def properties(gid, sid, did, node_id, node_type):
|
||||
|
||||
# Fetch procedures only if server type is ppas
|
||||
if (len(server_prop) > 0 and
|
||||
server_prop['server_type'] == 'ppas' and
|
||||
ntype in ['schema', 'procedure']):
|
||||
server_prop['server_type'] == 'ppas' and
|
||||
ntype in ['schema', 'procedure']):
|
||||
SQL = render_template("/".join(
|
||||
[server_prop['template_path'], '/sql/function.sql']),
|
||||
node_id=node_id, nspname=nspname, type='procedure')
|
||||
@@ -304,9 +307,9 @@ def properties(gid, sid, did, node_id, node_type):
|
||||
res_data.extend(res['rows'])
|
||||
|
||||
return ajax_response(
|
||||
response=res_data,
|
||||
status=200
|
||||
)
|
||||
response=res_data,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
@@ -335,7 +338,7 @@ def msql(gid, sid, did):
|
||||
try:
|
||||
acls = render_template(
|
||||
"/".join([server_prop['template_path'], '/acl.json'])
|
||||
)
|
||||
)
|
||||
acls = json.loads(acls)
|
||||
except Exception as e:
|
||||
current_app.logger.exception(e)
|
||||
@@ -364,9 +367,9 @@ def msql(gid, sid, did):
|
||||
data_func['objects'] = data['objects']
|
||||
data_func['priv'] = data['priv']['function']
|
||||
SQL = render_template(
|
||||
"/".join([server_prop['template_path'],
|
||||
'/sql/grant_function.sql']),
|
||||
data=data_func, conn=conn)
|
||||
"/".join([server_prop['template_path'],
|
||||
'/sql/grant_function.sql']),
|
||||
data=data_func, conn=conn)
|
||||
if SQL and SQL.strip('\n') != '':
|
||||
SQL_data += SQL
|
||||
|
||||
@@ -374,9 +377,9 @@ def msql(gid, sid, did):
|
||||
data_seq['objects'] = data['objects']
|
||||
data_seq['priv'] = data['priv']['sequence']
|
||||
SQL = render_template(
|
||||
"/".join([server_prop['template_path'],
|
||||
'/sql/grant_sequence.sql']),
|
||||
data=data_seq, conn=conn)
|
||||
"/".join([server_prop['template_path'],
|
||||
'/sql/grant_sequence.sql']),
|
||||
data=data_seq, conn=conn)
|
||||
if SQL and SQL.strip('\n') != '':
|
||||
SQL_data += SQL
|
||||
|
||||
@@ -384,8 +387,8 @@ def msql(gid, sid, did):
|
||||
data_table['objects'] = data['objects']
|
||||
data_table['priv'] = data['priv']['table']
|
||||
SQL = render_template(
|
||||
"/".join([server_prop['template_path'], '/sql/grant_table.sql']),
|
||||
data=data_table, conn=conn)
|
||||
"/".join([server_prop['template_path'], '/sql/grant_table.sql']),
|
||||
data=data_table, conn=conn)
|
||||
if SQL and SQL.strip('\n') != '':
|
||||
SQL_data += SQL
|
||||
|
||||
@@ -394,7 +397,7 @@ def msql(gid, sid, did):
|
||||
return ajax_response(
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
return make_json_response(
|
||||
@@ -424,8 +427,8 @@ def save(gid, sid, did):
|
||||
acls = []
|
||||
try:
|
||||
acls = render_template(
|
||||
"/".join([server_prop['template_path'], 'acl.json']),
|
||||
)
|
||||
"/".join([server_prop['template_path'], 'acl.json']),
|
||||
)
|
||||
acls = json.loads(acls)
|
||||
except Exception as e:
|
||||
current_app.logger.exception(e)
|
||||
@@ -455,9 +458,9 @@ def save(gid, sid, did):
|
||||
data_func['objects'] = data['objects']
|
||||
data_func['priv'] = data['priv']['function']
|
||||
SQL = render_template(
|
||||
"/".join([server_prop['template_path'],
|
||||
'/sql/grant_function.sql']),
|
||||
data=data_func, conn=conn)
|
||||
"/".join([server_prop['template_path'],
|
||||
'/sql/grant_function.sql']),
|
||||
data=data_func, conn=conn)
|
||||
if SQL and SQL.strip('\n') != '':
|
||||
SQL_data += SQL
|
||||
|
||||
@@ -465,9 +468,9 @@ def save(gid, sid, did):
|
||||
data_seq['objects'] = data['objects']
|
||||
data_seq['priv'] = data['priv']['sequence']
|
||||
SQL = render_template(
|
||||
"/".join([server_prop['template_path'],
|
||||
'/sql/grant_sequence.sql']),
|
||||
data=data_seq, conn=conn)
|
||||
"/".join([server_prop['template_path'],
|
||||
'/sql/grant_sequence.sql']),
|
||||
data=data_seq, conn=conn)
|
||||
if SQL and SQL.strip('\n') != '':
|
||||
SQL_data += SQL
|
||||
|
||||
@@ -475,8 +478,8 @@ def save(gid, sid, did):
|
||||
data_table['objects'] = data['objects']
|
||||
data_table['priv'] = data['priv']['table']
|
||||
SQL = render_template(
|
||||
"/".join([server_prop['template_path'], '/sql/grant_table.sql']),
|
||||
data=data_table, conn=conn)
|
||||
"/".join([server_prop['template_path'], '/sql/grant_table.sql']),
|
||||
data=data_table, conn=conn)
|
||||
if SQL and SQL.strip('\n') != '':
|
||||
SQL_data += SQL
|
||||
|
||||
|
||||
@@ -42,13 +42,13 @@ class ImportExportModule(PgAdminModule):
|
||||
def get_own_javascripts(self):
|
||||
scripts = list()
|
||||
for name, script in [
|
||||
['pgadmin.tools.import_export', 'js/import_export']
|
||||
]:
|
||||
['pgadmin.tools.import_export', 'js/import_export']
|
||||
]:
|
||||
scripts.append({
|
||||
'name': name,
|
||||
'path': url_for('import_export.index') + script,
|
||||
'when': None
|
||||
})
|
||||
})
|
||||
|
||||
return scripts
|
||||
|
||||
@@ -62,6 +62,7 @@ class Message(IProcessDesc):
|
||||
|
||||
Defines the message shown for the Message operation.
|
||||
"""
|
||||
|
||||
def __init__(self, _sid, _schema, _tbl, _database, _storage):
|
||||
self.sid = _sid
|
||||
self.schema = _schema
|
||||
|
||||
@@ -45,13 +45,13 @@ class MaintenanceModule(PgAdminModule):
|
||||
def get_own_javascripts(self):
|
||||
scripts = list()
|
||||
for name, script in [
|
||||
['pgadmin.tools.maintenance', 'js/maintenance']
|
||||
]:
|
||||
['pgadmin.tools.maintenance', 'js/maintenance']
|
||||
]:
|
||||
scripts.append({
|
||||
'name': name,
|
||||
'path': url_for('maintenance.index') + script,
|
||||
'when': None
|
||||
})
|
||||
})
|
||||
|
||||
return scripts
|
||||
|
||||
@@ -62,14 +62,14 @@ class MaintenanceModule(PgAdminModule):
|
||||
"""
|
||||
stylesheets = [
|
||||
url_for('maintenance.static', filename='css/maintenance.css')
|
||||
]
|
||||
]
|
||||
return stylesheets
|
||||
|
||||
|
||||
blueprint = MaintenanceModule(MODULE_NAME, __name__)
|
||||
|
||||
|
||||
class Message(IProcessDesc):
|
||||
|
||||
def __init__(self, _sid, _data, _query):
|
||||
self.sid = _sid
|
||||
self.data = _data
|
||||
@@ -144,7 +144,7 @@ def index():
|
||||
def script():
|
||||
"""render the maintenance tool of vacuum javascript file"""
|
||||
return Response(
|
||||
response=render_template("maintenance/js/maintenance.js", _=_),
|
||||
response=render_template("maintenance/js/maintenance.js", _=_),
|
||||
status=200,
|
||||
mimetype="application/javascript"
|
||||
)
|
||||
|
||||
@@ -50,6 +50,7 @@ class RestoreModule(PgAdminModule):
|
||||
'when': None
|
||||
}]
|
||||
|
||||
|
||||
# Create blueprint for RestoreModule class
|
||||
blueprint = RestoreModule(
|
||||
MODULE_NAME, __name__, static_url_path=''
|
||||
@@ -57,7 +58,6 @@ blueprint = RestoreModule(
|
||||
|
||||
|
||||
class RestoreMessage(IProcessDesc):
|
||||
|
||||
def __init__(self, _sid, _bfile):
|
||||
self.sid = _sid
|
||||
self.bfile = _bfile
|
||||
@@ -322,6 +322,7 @@ def create_restore_job(sid):
|
||||
data={'job_id': jid, 'Success': 1}
|
||||
)
|
||||
|
||||
|
||||
"""
|
||||
TODO://
|
||||
Add browser tree
|
||||
|
||||
@@ -22,7 +22,7 @@ from pgadmin.tools.sqleditor.command import QueryToolCommand
|
||||
from pgadmin.utils import PgAdminModule
|
||||
from pgadmin.utils import get_storage_directory
|
||||
from pgadmin.utils.ajax import make_json_response, bad_request, \
|
||||
success_return, internal_server_error
|
||||
success_return, internal_server_error
|
||||
from pgadmin.utils.driver import get_driver
|
||||
from pgadmin.utils.sqlautocomplete.autocomplete import SQLAutoComplete
|
||||
|
||||
@@ -79,43 +79,44 @@ class SqlEditorModule(PgAdminModule):
|
||||
max_val=2000,
|
||||
help_str=gettext('The number of rows to display per page in the results grid. '
|
||||
'Value should be between 50 and 2000.')
|
||||
)
|
||||
)
|
||||
|
||||
self.explain_verbose = self.preference.register(
|
||||
'Explain Options', 'explain_verbose',
|
||||
gettext("Verbose"), 'boolean', False,
|
||||
category_label=gettext('Explain Options')
|
||||
)
|
||||
)
|
||||
|
||||
self.explain_costs = self.preference.register(
|
||||
'Explain Options', 'explain_costs',
|
||||
gettext("Costs"), 'boolean', False,
|
||||
category_label=gettext('Explain Options')
|
||||
)
|
||||
)
|
||||
|
||||
self.explain_buffers = self.preference.register(
|
||||
'Explain Options', 'explain_buffers',
|
||||
gettext("Buffers"), 'boolean', False,
|
||||
category_label=gettext('Explain Options')
|
||||
)
|
||||
)
|
||||
|
||||
self.explain_timing = self.preference.register(
|
||||
'Explain Options', 'explain_timing',
|
||||
gettext("Timing"), 'boolean', False,
|
||||
category_label=gettext('Explain Options')
|
||||
)
|
||||
)
|
||||
|
||||
self.auto_commit = self.preference.register(
|
||||
'Options', 'auto_commit',
|
||||
gettext("Auto-Commit"), 'boolean', True,
|
||||
category_label=gettext('Options')
|
||||
)
|
||||
)
|
||||
|
||||
self.auto_rollback = self.preference.register(
|
||||
'Options', 'auto_rollback',
|
||||
gettext("Auto-Rollback"), 'boolean', False,
|
||||
category_label=gettext('Options')
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
blueprint = SqlEditorModule(MODULE_NAME, __name__, static_url_path='/static')
|
||||
|
||||
@@ -160,7 +161,7 @@ def check_transaction_status(trans_id):
|
||||
manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(trans_obj.sid)
|
||||
conn = manager.connection(did=trans_obj.did, conn_id=trans_obj.conn_id)
|
||||
except Exception as e:
|
||||
return False, internal_server_error(errormsg=str(e)), None, None, None
|
||||
return False, internal_server_error(errormsg=str(e)), None, None, None
|
||||
|
||||
if conn.connected():
|
||||
return True, None, conn, trans_obj, session_obj
|
||||
@@ -222,8 +223,8 @@ def start_view_data(trans_id):
|
||||
'limit': limit, 'can_edit': can_edit,
|
||||
'can_filter': can_filter, 'sql': sql,
|
||||
'items_per_page': blueprint.items_per_page.get()
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route('/query_tool/start/<int:trans_id>', methods=["PUT", "POST"])
|
||||
@@ -324,8 +325,8 @@ def start_query_tool(trans_id):
|
||||
'status': status, 'result': result,
|
||||
'can_edit': can_edit, 'can_filter': can_filter,
|
||||
'items_per_page': blueprint.items_per_page.get()
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route('/query_tool/preferences/<int:trans_id>', methods=["GET", "PUT"])
|
||||
@@ -343,7 +344,6 @@ def preferences(trans_id):
|
||||
status, error_msg, conn, trans_obj, session_obj = check_transaction_status(trans_id)
|
||||
if status and conn is not None \
|
||||
and trans_obj is not None and session_obj is not None:
|
||||
|
||||
# Call the set_auto_commit and set_auto_rollback method of transaction object
|
||||
trans_obj.set_auto_commit(blueprint.auto_commit.get())
|
||||
trans_obj.set_auto_rollback(blueprint.auto_rollback.get())
|
||||
@@ -804,8 +804,8 @@ def cancel_transaction(trans_id):
|
||||
return make_json_response(
|
||||
data={
|
||||
'status': status, 'result': result
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@blueprint.route('/object/get/<int:trans_id>', methods=["GET"])
|
||||
@@ -963,7 +963,7 @@ def is_begin_required(query):
|
||||
while (word_len < query_len) and query[word_len].isalpha():
|
||||
word_len += 1
|
||||
|
||||
# Transaction control commands. These should include every keyword that
|
||||
# Transaction control commands. These should include every keyword that
|
||||
# gives rise to a TransactionStmt in the backend grammar, except for the
|
||||
# savepoint-related commands.
|
||||
#
|
||||
@@ -1012,7 +1012,7 @@ def is_begin_required(query):
|
||||
|
||||
if query[0].isalpha():
|
||||
return True # has additional words
|
||||
return False # it's CLUSTER without arguments
|
||||
return False # it's CLUSTER without arguments
|
||||
|
||||
if word_len == 6 and keyword.lower() == "create":
|
||||
query = query[word_len:query_len]
|
||||
@@ -1128,15 +1128,15 @@ def load_file():
|
||||
|
||||
# generate full path of file
|
||||
file_path = os.path.join(
|
||||
storage_manager_path,
|
||||
unquote(file_data['file_name'].lstrip('/'))
|
||||
)
|
||||
storage_manager_path,
|
||||
unquote(file_data['file_name'].lstrip('/'))
|
||||
)
|
||||
file_data = None
|
||||
|
||||
# check if file type is text or binary
|
||||
textchars = bytearray(
|
||||
[7, 8, 9, 10, 12, 13, 27]) + bytearray(
|
||||
range(0x20, 0x7f)) + bytearray(range(0x80, 0x100))
|
||||
range(0x20, 0x7f)) + bytearray(range(0x80, 0x100))
|
||||
|
||||
is_binary_string = lambda bytes: bool(
|
||||
bytes.translate(None, textchars)
|
||||
@@ -1188,9 +1188,9 @@ def save_file():
|
||||
file_path = unquote(file_data['file_name'])
|
||||
if storage_manager_path is not None:
|
||||
file_path = os.path.join(
|
||||
storage_manager_path,
|
||||
unquote(file_data['file_name'].lstrip('/'))
|
||||
)
|
||||
storage_manager_path,
|
||||
unquote(file_data['file_name'].lstrip('/'))
|
||||
)
|
||||
file_content = file_data['file_content']
|
||||
|
||||
# write to file
|
||||
|
||||
@@ -64,8 +64,8 @@ class ObjectRegistry(ABCMeta):
|
||||
return (ObjectRegistry.registry[name])(**kwargs)
|
||||
|
||||
raise NotImplementedError(
|
||||
gettext("This feature has not been implemented for object type '{0}'!").format(name)
|
||||
)
|
||||
gettext("This feature has not been implemented for object type '{0}'!").format(name)
|
||||
)
|
||||
|
||||
|
||||
@six.add_metaclass(ObjectRegistry)
|
||||
@@ -647,4 +647,3 @@ class QueryToolCommand(BaseCommand):
|
||||
|
||||
def set_auto_commit(self, auto_commit):
|
||||
self.auto_commit = auto_commit
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ from flask.ext.babel import gettext as _
|
||||
from flask.ext.security import login_required, roles_required, current_user
|
||||
from flask.ext.security.utils import encrypt_password
|
||||
from pgadmin.utils import PgAdminModule
|
||||
from pgadmin.utils.ajax import make_response as ajax_response,\
|
||||
from pgadmin.utils.ajax import make_response as ajax_response, \
|
||||
make_json_response, bad_request, internal_server_error
|
||||
|
||||
from pgadmin.model import db, Role, User, UserPreference, Server,\
|
||||
from pgadmin.model import db, Role, User, UserPreference, Server, \
|
||||
ServerGroup, Process, Setting
|
||||
|
||||
# set template path for sql scripts
|
||||
@@ -71,7 +71,7 @@ def validate_user(data):
|
||||
"(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
|
||||
|
||||
if ('newPassword' in data and data['newPassword'] != "" and
|
||||
'confirmPassword' in data and data['confirmPassword'] != ""):
|
||||
'confirmPassword' in data and data['confirmPassword'] != ""):
|
||||
|
||||
if data['newPassword'] == data['confirmPassword']:
|
||||
new_data['password'] = encrypt_password(data['newPassword'])
|
||||
@@ -150,8 +150,8 @@ def user(uid):
|
||||
res = users_data
|
||||
|
||||
return ajax_response(
|
||||
response=res,
|
||||
status=200
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
@@ -201,8 +201,8 @@ def create():
|
||||
}
|
||||
|
||||
return ajax_response(
|
||||
response=res,
|
||||
status=200
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
|
||||
@@ -240,10 +240,10 @@ def delete(uid):
|
||||
db.session.commit()
|
||||
|
||||
return make_json_response(
|
||||
success=1,
|
||||
info=_("User Deleted."),
|
||||
data={}
|
||||
)
|
||||
success=1,
|
||||
info=_("User Deleted."),
|
||||
data={}
|
||||
)
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -289,8 +289,8 @@ def update(uid):
|
||||
}
|
||||
|
||||
return ajax_response(
|
||||
response=res,
|
||||
status=200
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
@@ -325,6 +325,6 @@ def role(rid):
|
||||
res = roles_data
|
||||
|
||||
return ajax_response(
|
||||
response=res,
|
||||
status=200
|
||||
response=res,
|
||||
status=200
|
||||
)
|
||||
|
||||
@@ -129,5 +129,5 @@ class PgAdminModule(Blueprint):
|
||||
for key, value in module.menu_items.items():
|
||||
menu_items[key].extend(value)
|
||||
menu_items = dict((key, sorted(value, key=attrgetter('priority')))
|
||||
for key, value in menu_items.items())
|
||||
for key, value in menu_items.items())
|
||||
return menu_items
|
||||
|
||||
@@ -42,88 +42,88 @@ def make_json_response(success=1, errormsg='', info='', result=None,
|
||||
doc['data'] = data
|
||||
|
||||
return Response(
|
||||
response=json.dumps(doc, cls=DataTypeJSONEncoder),
|
||||
status=status,
|
||||
mimetype="text/json"
|
||||
)
|
||||
response=json.dumps(doc, cls=DataTypeJSONEncoder),
|
||||
status=status,
|
||||
mimetype="text/json"
|
||||
)
|
||||
|
||||
|
||||
def make_response(response=None, status=200):
|
||||
"""Create a JSON response handled by the backbone models."""
|
||||
return Response(
|
||||
response=json.dumps(response, cls=DataTypeJSONEncoder),
|
||||
status=status,
|
||||
mimetype="text/json"
|
||||
)
|
||||
response=json.dumps(response, cls=DataTypeJSONEncoder),
|
||||
status=status,
|
||||
mimetype="text/json"
|
||||
)
|
||||
|
||||
|
||||
def internal_server_error(errormsg=''):
|
||||
"""Create a response with HTTP status code 500 - Internal Server Error."""
|
||||
return make_json_response(
|
||||
status=500,
|
||||
success=0,
|
||||
errormsg=errormsg
|
||||
)
|
||||
status=500,
|
||||
success=0,
|
||||
errormsg=errormsg
|
||||
)
|
||||
|
||||
|
||||
def forbidden(errmsg=''):
|
||||
"""Create a response with HTTP status code 403 - Forbidden."""
|
||||
return make_json_response(
|
||||
status=403,
|
||||
success=0,
|
||||
errormsg=errmsg
|
||||
)
|
||||
status=403,
|
||||
success=0,
|
||||
errormsg=errmsg
|
||||
)
|
||||
|
||||
|
||||
def unauthorized(errormsg=''):
|
||||
"""Create a response with HTTP status code 401 - Unauthorized."""
|
||||
return make_json_response(
|
||||
status=401,
|
||||
success=0,
|
||||
errormsg=errormsg
|
||||
)
|
||||
status=401,
|
||||
success=0,
|
||||
errormsg=errormsg
|
||||
)
|
||||
|
||||
|
||||
def bad_request(errormsg=''):
|
||||
"""Create a response with HTTP status code 400 - Bad Request."""
|
||||
return make_json_response(
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=errormsg
|
||||
)
|
||||
status=400,
|
||||
success=0,
|
||||
errormsg=errormsg
|
||||
)
|
||||
|
||||
|
||||
def precondition_required(errormsg=''):
|
||||
"""Create a response with HTTP status code 428 - Precondition Required."""
|
||||
return make_json_response(
|
||||
status=428,
|
||||
success=0,
|
||||
errormsg=errormsg
|
||||
)
|
||||
status=428,
|
||||
success=0,
|
||||
errormsg=errormsg
|
||||
)
|
||||
|
||||
|
||||
def success_return(message=''):
|
||||
"""Create a response with HTTP status code 200 - OK."""
|
||||
return make_json_response(
|
||||
status=200,
|
||||
success=1,
|
||||
info=message
|
||||
)
|
||||
status=200,
|
||||
success=1,
|
||||
info=message
|
||||
)
|
||||
|
||||
|
||||
def gone(errormsg=''):
|
||||
"""Create a response with HTTP status code 410 - GONE."""
|
||||
return make_json_response(
|
||||
status=410,
|
||||
success=0,
|
||||
errormsg=errormsg
|
||||
)
|
||||
status=410,
|
||||
success=0,
|
||||
errormsg=errormsg
|
||||
)
|
||||
|
||||
|
||||
def not_implemented(errormsg=_('Not implemented.')):
|
||||
"""Create a response with HTTP status code 501 - Not Implemented."""
|
||||
return make_json_response(
|
||||
status=501,
|
||||
success=0,
|
||||
errormsg=errormsg
|
||||
)
|
||||
status=501,
|
||||
success=0,
|
||||
errormsg=errormsg
|
||||
)
|
||||
|
||||
@@ -72,7 +72,6 @@ def pad(str):
|
||||
|
||||
|
||||
def pqencryptpassword(password, user):
|
||||
|
||||
"""
|
||||
pqencryptpassword -- to encrypt a password
|
||||
This is intended to be used by client applications that wish to send
|
||||
|
||||
@@ -13,7 +13,6 @@ from .registry import DriverRegistry
|
||||
|
||||
|
||||
def get_driver(type, app=None):
|
||||
|
||||
if app is not None:
|
||||
DriverRegistry.load_drivers()
|
||||
|
||||
@@ -33,6 +32,7 @@ def get_driver(type, app=None):
|
||||
|
||||
return driver
|
||||
|
||||
|
||||
def init_app(app):
|
||||
drivers = dict()
|
||||
|
||||
|
||||
@@ -58,8 +58,10 @@ def register_date_typecasters(connection):
|
||||
Casts date and timestamp values to string, resolves issues
|
||||
with out of range dates (e.g. BC) which psycopg2 can't handle
|
||||
"""
|
||||
|
||||
def cast_date(value, cursor):
|
||||
return value
|
||||
|
||||
cursor = connection.cursor()
|
||||
cursor.execute('SELECT NULL::date')
|
||||
date_oid = cursor.description[0][1]
|
||||
@@ -149,9 +151,10 @@ class Connection(BaseConnection):
|
||||
normal error message.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, manager, conn_id, db, auto_reconnect=True, async=0):
|
||||
assert(manager is not None)
|
||||
assert(conn_id is not None)
|
||||
assert (manager is not None)
|
||||
assert (conn_id is not None)
|
||||
|
||||
self.conn_id = conn_id
|
||||
self.manager = manager
|
||||
@@ -189,7 +192,7 @@ class Connection(BaseConnection):
|
||||
'Connected' if self.conn and not self.conn.closed else
|
||||
"Disconnected",
|
||||
self.async
|
||||
)
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return "PG Connection: {0} ({1}) -> {2} (ajax:{3})".format(
|
||||
@@ -197,7 +200,7 @@ class Connection(BaseConnection):
|
||||
'Connected' if self.conn and not self.conn.closed else
|
||||
"Disconnected",
|
||||
self.async
|
||||
)
|
||||
)
|
||||
|
||||
def connect(self, **kwargs):
|
||||
if self.conn:
|
||||
@@ -227,9 +230,9 @@ class Connection(BaseConnection):
|
||||
except Exception as e:
|
||||
current_app.logger.exception(e)
|
||||
return False, \
|
||||
_("Failed to decrypt the saved password!\nError: {0}").format(
|
||||
str(e)
|
||||
)
|
||||
_("Failed to decrypt the saved password!\nError: {0}").format(
|
||||
str(e)
|
||||
)
|
||||
|
||||
# password is in bytes, for python3 we need it in string
|
||||
if isinstance(password, bytes):
|
||||
@@ -239,13 +242,13 @@ class Connection(BaseConnection):
|
||||
import os
|
||||
os.environ['PGAPPNAME'] = '{0} - {1}'.format(config.APP_NAME, self.conn_id)
|
||||
pg_conn = psycopg2.connect(
|
||||
host=mgr.host,
|
||||
port=mgr.port,
|
||||
database=self.db,
|
||||
user=mgr.user,
|
||||
password=password,
|
||||
async=self.async
|
||||
)
|
||||
host=mgr.host,
|
||||
port=mgr.port,
|
||||
database=self.db,
|
||||
user=mgr.user,
|
||||
password=password,
|
||||
async=self.async
|
||||
)
|
||||
|
||||
# If connection is asynchronous then we will have to wait
|
||||
# until the connection is ready to use.
|
||||
@@ -262,11 +265,11 @@ class Connection(BaseConnection):
|
||||
current_app.logger.info("""
|
||||
Failed to connect to the database server(#{server_id}) for connection ({conn_id}) with error message as below:
|
||||
{msg}""".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
msg=msg
|
||||
)
|
||||
)
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
msg=msg
|
||||
)
|
||||
)
|
||||
|
||||
return False, msg
|
||||
|
||||
@@ -302,15 +305,15 @@ SET client_encoding='UNICODE';""")
|
||||
Connect to the database server (#{server_id}) for connection ({conn_id}), but - failed to setup the role with error message as below:
|
||||
{msg}
|
||||
""".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
msg=res
|
||||
)
|
||||
)
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
msg=res
|
||||
)
|
||||
)
|
||||
return False, \
|
||||
_("Failed to setup the role with error message:\n{0}").format(
|
||||
res
|
||||
)
|
||||
_("Failed to setup the role with error message:\n{0}").format(
|
||||
res
|
||||
)
|
||||
|
||||
if mgr.ver is None:
|
||||
status, res = self.execute_scalar("SELECT version()")
|
||||
@@ -325,11 +328,11 @@ Connect to the database server (#{server_id}) for connection ({conn_id}), but -
|
||||
Failed to fetch the version information on the established connection to the database server (#{server_id}) for '{conn_id}' with below error message:
|
||||
{msg}
|
||||
""".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
msg=res
|
||||
)
|
||||
)
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
msg=res
|
||||
)
|
||||
)
|
||||
return False, res
|
||||
|
||||
status, res = self.execute_dict("""
|
||||
@@ -390,20 +393,20 @@ WHERE
|
||||
current_app.logger.warning("""
|
||||
Connection to database server (#{server_id}) for the connection - '{conn_id}' has been lost.
|
||||
""".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id
|
||||
)
|
||||
)
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id
|
||||
)
|
||||
)
|
||||
|
||||
if self.auto_reconnect:
|
||||
status, errmsg = self.connect()
|
||||
|
||||
if not status:
|
||||
errmsg = gettext(
|
||||
"""
|
||||
"""
|
||||
Attempt to reconnect failed with the error:
|
||||
{0}""".format(errmsg)
|
||||
)
|
||||
)
|
||||
|
||||
if not status:
|
||||
msg = gettext("Connection lost.\n{0}").format(errmsg)
|
||||
@@ -428,7 +431,7 @@ Attempting to reconnect to the database server (#{server_id}) for the connection
|
||||
""".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id
|
||||
)
|
||||
)
|
||||
)
|
||||
status, cur = self.connect()
|
||||
if not status:
|
||||
@@ -437,7 +440,7 @@ Attempting to reconnect to the database server (#{server_id}) for the connection
|
||||
Connection for server#{0} with database "{1}" was lost.
|
||||
Attempt to reconnect it failed with the error:
|
||||
{2}"""
|
||||
).format(self.driver.server_id, self.database, cur)
|
||||
).format(self.driver.server_id, self.database, cur)
|
||||
current_app.logger.error(msg)
|
||||
|
||||
return False, cur
|
||||
@@ -473,27 +476,27 @@ Attempt to reconnect it failed with the error:
|
||||
query_id = random.randint(1, 9999999)
|
||||
|
||||
current_app.logger.log(25,
|
||||
"Execute (scalar) for server #{server_id} - {conn_id} (Query-id: {query_id}):\n{query}".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
query=query,
|
||||
query_id=query_id
|
||||
)
|
||||
)
|
||||
"Execute (scalar) for server #{server_id} - {conn_id} (Query-id: {query_id}):\n{query}".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
query=query,
|
||||
query_id=query_id
|
||||
)
|
||||
)
|
||||
try:
|
||||
self.__internal_blocking_execute(cur, query, params)
|
||||
except psycopg2.Error as pe:
|
||||
cur.close()
|
||||
errmsg = self._formatted_exception_msg(pe, formatted_exception_msg)
|
||||
current_app.logger.error(
|
||||
"Failed to execute query (execute_scalar) for the server #{server_id} - {conn_id} (Query-id: {query_id}):\nError Message:{errmsg}".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
query=query,
|
||||
errmsg=errmsg,
|
||||
query_id=query_id
|
||||
)
|
||||
)
|
||||
"Failed to execute query (execute_scalar) for the server #{server_id} - {conn_id} (Query-id: {query_id}):\nError Message:{errmsg}".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
query=query,
|
||||
errmsg=errmsg,
|
||||
query_id=query_id
|
||||
)
|
||||
)
|
||||
return False, errmsg
|
||||
|
||||
self.row_count = cur.rowcount
|
||||
@@ -527,8 +530,8 @@ Execute (async) for server #{server_id} - {conn_id} (Query-id: {query_id}):\n{qu
|
||||
conn_id=self.conn_id,
|
||||
query=query,
|
||||
query_id=query_id
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
try:
|
||||
self.execution_aborted = False
|
||||
@@ -545,7 +548,7 @@ Failed to execute query (execute_async) for the server #{server_id} - {conn_id}
|
||||
query=query,
|
||||
errmsg=errmsg,
|
||||
query_id=query_id
|
||||
)
|
||||
)
|
||||
)
|
||||
return False, errmsg
|
||||
|
||||
@@ -577,8 +580,8 @@ Execute (void) for server #{server_id} - {conn_id} (Query-id: {query_id}):\n{que
|
||||
conn_id=self.conn_id,
|
||||
query=query,
|
||||
query_id=query_id
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
try:
|
||||
self.__internal_blocking_execute(cur, query, params)
|
||||
@@ -594,7 +597,7 @@ Failed to execute query (execute_void) for the server #{server_id} - {conn_id}
|
||||
query=query,
|
||||
errmsg=errmsg,
|
||||
query_id=query_id
|
||||
)
|
||||
)
|
||||
)
|
||||
return False, errmsg
|
||||
|
||||
@@ -611,34 +614,34 @@ Failed to execute query (execute_void) for the server #{server_id} - {conn_id}
|
||||
|
||||
query_id = random.randint(1, 9999999)
|
||||
current_app.logger.log(25,
|
||||
"Execute (2darray) for server #{server_id} - {conn_id} (Query-id: {query_id}):\n{query}".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
query=query,
|
||||
query_id=query_id
|
||||
)
|
||||
)
|
||||
"Execute (2darray) for server #{server_id} - {conn_id} (Query-id: {query_id}):\n{query}".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
query=query,
|
||||
query_id=query_id
|
||||
)
|
||||
)
|
||||
try:
|
||||
self.__internal_blocking_execute(cur, query, params)
|
||||
except psycopg2.Error as pe:
|
||||
cur.close()
|
||||
errmsg = self._formatted_exception_msg(pe, formatted_exception_msg)
|
||||
current_app.logger.error(
|
||||
"Failed to execute query (execute_2darray) for the server #{server_id} - {conn_id} (Query-id: {query_id}):\nError Message:{errmsg}".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
query=query,
|
||||
errmsg=errmsg,
|
||||
query_id=query_id
|
||||
)
|
||||
)
|
||||
"Failed to execute query (execute_2darray) for the server #{server_id} - {conn_id} (Query-id: {query_id}):\nError Message:{errmsg}".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
query=query,
|
||||
errmsg=errmsg,
|
||||
query_id=query_id
|
||||
)
|
||||
)
|
||||
return False, errmsg
|
||||
|
||||
import copy
|
||||
# Get Resultset Column Name, Type and size
|
||||
columns = cur.description and [
|
||||
copy.deepcopy(desc._asdict()) for desc in cur.description
|
||||
] or []
|
||||
copy.deepcopy(desc._asdict()) for desc in cur.description
|
||||
] or []
|
||||
|
||||
rows = []
|
||||
self.row_count = cur.rowcount
|
||||
@@ -656,33 +659,33 @@ Failed to execute query (execute_void) for the server #{server_id} - {conn_id}
|
||||
return False, str(cur)
|
||||
query_id = random.randint(1, 9999999)
|
||||
current_app.logger.log(25,
|
||||
"Execute (dict) for server #{server_id} - {conn_id} (Query-id: {query_id}):\n{query}".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
query=query,
|
||||
query_id=query_id
|
||||
)
|
||||
)
|
||||
"Execute (dict) for server #{server_id} - {conn_id} (Query-id: {query_id}):\n{query}".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
query=query,
|
||||
query_id=query_id
|
||||
)
|
||||
)
|
||||
try:
|
||||
self.__internal_blocking_execute(cur, query, params)
|
||||
except psycopg2.Error as pe:
|
||||
cur.close()
|
||||
errmsg = self._formatted_exception_msg(pe, formatted_exception_msg)
|
||||
current_app.logger.error(
|
||||
"Failed to execute query (execute_dict) for the server #{server_id}- {conn_id} (Query-id: {query_id}):\nError Message:{errmsg}".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
query_id=query_id,
|
||||
errmsg=errmsg
|
||||
)
|
||||
)
|
||||
"Failed to execute query (execute_dict) for the server #{server_id}- {conn_id} (Query-id: {query_id}):\nError Message:{errmsg}".format(
|
||||
server_id=self.manager.sid,
|
||||
conn_id=self.conn_id,
|
||||
query_id=query_id,
|
||||
errmsg=errmsg
|
||||
)
|
||||
)
|
||||
return False, errmsg
|
||||
|
||||
import copy
|
||||
# Get Resultset Column Name, Type and size
|
||||
columns = cur.description and [
|
||||
copy.deepcopy(desc._asdict()) for desc in cur.description
|
||||
] or []
|
||||
copy.deepcopy(desc._asdict()) for desc in cur.description
|
||||
] or []
|
||||
|
||||
rows = []
|
||||
self.row_count = cur.rowcount
|
||||
@@ -719,12 +722,12 @@ Failed to execute query (execute_void) for the server #{server_id} - {conn_id}
|
||||
|
||||
try:
|
||||
pg_conn = psycopg2.connect(
|
||||
host=mgr.host,
|
||||
port=mgr.port,
|
||||
database=self.db,
|
||||
user=mgr.user,
|
||||
password=password
|
||||
)
|
||||
host=mgr.host,
|
||||
port=mgr.port,
|
||||
database=self.db,
|
||||
user=mgr.user,
|
||||
password=password
|
||||
)
|
||||
|
||||
except psycopg2.Error as e:
|
||||
msg = e.pgerror if e.pgerror else e.message \
|
||||
@@ -736,8 +739,8 @@ Failed to execute query (execute_void) for the server #{server_id} - {conn_id}
|
||||
"""
|
||||
Failed to reset the connection to the server due to following error:
|
||||
{0}"""
|
||||
).Format(msg)
|
||||
)
|
||||
).Format(msg)
|
||||
)
|
||||
return False, msg
|
||||
|
||||
self.conn = pg_conn
|
||||
@@ -824,7 +827,7 @@ Failed to reset the connection to the server due to following error:
|
||||
else:
|
||||
raise psycopg2.OperationalError(
|
||||
"poll() returned %s from _wait_timeout function" % state
|
||||
)
|
||||
)
|
||||
|
||||
def poll(self, formatted_exception_msg=False):
|
||||
"""
|
||||
@@ -842,14 +845,14 @@ Failed to reset the connection to the server due to following error:
|
||||
if not cur:
|
||||
return False, gettext(
|
||||
"Cursor could not be found for the async connection."
|
||||
), None
|
||||
), None
|
||||
|
||||
current_app.logger.log(
|
||||
25,
|
||||
"Polling result for (Query-id: {query_id})".format(
|
||||
query_id=self.__async_query_id
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
try:
|
||||
status = self._wait_timeout(self.conn, ASYNC_WAIT_TIMEOUT)
|
||||
@@ -901,8 +904,8 @@ Failed to reset the connection to the server due to following error:
|
||||
25,
|
||||
"Status message for (Query-id: {query_id})".format(
|
||||
query_id=self.__async_query_id
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
return cur.statusmessage
|
||||
|
||||
@@ -1014,7 +1017,7 @@ Failed to reset the connection to the server due to following error:
|
||||
if exception_obj.diag.severity is not None \
|
||||
and exception_obj.diag.message_primary is not None:
|
||||
errmsg += exception_obj.diag.severity + ": " + \
|
||||
exception_obj.diag.message_primary
|
||||
exception_obj.diag.message_primary
|
||||
elif exception_obj.diag.message_primary is not None:
|
||||
errmsg += exception_obj.diag.message_primary
|
||||
|
||||
@@ -1058,14 +1061,15 @@ class ServerManager(object):
|
||||
This class contains the information about the given server.
|
||||
And, acts as connection manager for that particular session.
|
||||
"""
|
||||
|
||||
def __init__(self, server):
|
||||
self.connections = dict()
|
||||
|
||||
self.update(server)
|
||||
|
||||
def update(self, server):
|
||||
assert(server is not None)
|
||||
assert(isinstance(server, Server))
|
||||
assert (server is not None)
|
||||
assert (isinstance(server, Server))
|
||||
|
||||
self.ver = None
|
||||
self.sversion = None
|
||||
@@ -1140,10 +1144,10 @@ class ServerManager(object):
|
||||
|
||||
def connection(
|
||||
self, database=None, conn_id=None, auto_reconnect=True, did=None
|
||||
):
|
||||
):
|
||||
msg_active_conn = gettext(
|
||||
"Server has no active connection. Please connect to the server."
|
||||
)
|
||||
)
|
||||
|
||||
if database is None:
|
||||
if did is None:
|
||||
@@ -1172,13 +1176,13 @@ WHERE db.oid = {0}""".format(did))
|
||||
if did not in self.db_info:
|
||||
raise Exception(gettext(
|
||||
"Couldn't find the specified database."
|
||||
))
|
||||
))
|
||||
|
||||
if database is None:
|
||||
raise Exception(msg_active_conn)
|
||||
|
||||
my_id = ('CONN:' + str(conn_id)) if conn_id is not None else \
|
||||
('DB:' + str(database))
|
||||
('DB:' + str(database))
|
||||
|
||||
self.pinged = datetime.datetime.now()
|
||||
|
||||
@@ -1187,8 +1191,8 @@ WHERE db.oid = {0}""".format(did))
|
||||
else:
|
||||
async = 1 if conn_id is not None else 0
|
||||
self.connections[my_id] = Connection(
|
||||
self, my_id, database, auto_reconnect, async
|
||||
)
|
||||
self, my_id, database, auto_reconnect, async
|
||||
)
|
||||
|
||||
return self.connections[my_id]
|
||||
|
||||
@@ -1217,13 +1221,13 @@ WHERE db.oid = {0}""".format(did))
|
||||
conn = self.connections[conn_info['conn_id']] = Connection(
|
||||
self, conn_info['conn_id'], conn_info['database'],
|
||||
True, conn_info['async']
|
||||
)
|
||||
)
|
||||
|
||||
try:
|
||||
conn.connect(
|
||||
password=data['password'],
|
||||
server_types=ServerType.types()
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
current_app.logger.exception(e)
|
||||
self.connections.pop(conn_info['conn_id'])
|
||||
@@ -1238,7 +1242,7 @@ WHERE db.oid = {0}""".format(did))
|
||||
return False
|
||||
|
||||
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
|
||||
|
||||
if my_id is not None:
|
||||
if my_id in self.connections:
|
||||
@@ -1330,6 +1334,7 @@ class Driver(BaseDriver):
|
||||
* connection_manager(sid, reset)
|
||||
- It returns the server connection manager for this session.
|
||||
"""
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.managers = dict()
|
||||
|
||||
@@ -1392,12 +1397,12 @@ class Driver(BaseDriver):
|
||||
return version
|
||||
|
||||
raise Exception(
|
||||
"Driver Version information for psycopg2 is not available!"
|
||||
)
|
||||
"Driver Version information for psycopg2 is not available!"
|
||||
)
|
||||
|
||||
def get_connection(
|
||||
self, sid, database=None, conn_id=None, auto_reconnect=True
|
||||
):
|
||||
):
|
||||
"""
|
||||
get_connection(...)
|
||||
|
||||
@@ -1455,7 +1460,7 @@ class Driver(BaseDriver):
|
||||
|
||||
if (curr_time - sess_mgr['pinged'] >= session_idle_timeout):
|
||||
for mgr in [m for m in sess_mgr if isinstance(m,
|
||||
ServerManager)]:
|
||||
ServerManager)]:
|
||||
mgr.release()
|
||||
|
||||
@staticmethod
|
||||
@@ -1497,7 +1502,7 @@ class Driver(BaseDriver):
|
||||
'tinyint': 3,
|
||||
'tinytext': 3,
|
||||
'varchar2': 3
|
||||
};
|
||||
};
|
||||
|
||||
return (key in extraKeywords and extraKeywords[key]) or ScanKeyword(key)
|
||||
|
||||
@@ -1529,7 +1534,7 @@ class Driver(BaseDriver):
|
||||
u'time with time zone',
|
||||
u'"trigger"',
|
||||
u'"unknown"'
|
||||
]:
|
||||
]:
|
||||
return False
|
||||
|
||||
if u'0' <= valNoArray[0] <= u'9':
|
||||
|
||||
@@ -17,12 +17,12 @@ import os
|
||||
import re
|
||||
|
||||
if __name__ == '__main__':
|
||||
include_dir = os.popen('pg_config --includedir').read().rstrip()
|
||||
version = os.popen('pg_config --version').read().rstrip()
|
||||
include_dir = os.popen('pg_config --includedir').read().rstrip()
|
||||
version = os.popen('pg_config --version').read().rstrip()
|
||||
|
||||
keywords_file = open('keywords.py', 'w')
|
||||
keywords_file = open('keywords.py', 'w')
|
||||
|
||||
keywords_file.write("""##########################################################################
|
||||
keywords_file.write("""##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
@@ -31,32 +31,32 @@ if __name__ == '__main__':
|
||||
#
|
||||
##########################################################################
|
||||
""")
|
||||
keywords_file.write('# ScanKeyword function for ' + version)
|
||||
keywords_file.write('\n\ndef ScanKeyword(key):')
|
||||
keywords_file.write('\n keywordDict = {\n')
|
||||
keywords_file.write('# ScanKeyword function for ' + version)
|
||||
keywords_file.write('\n\ndef ScanKeyword(key):')
|
||||
keywords_file.write('\n keywordDict = {\n')
|
||||
|
||||
idx = 0
|
||||
idx = 0
|
||||
|
||||
with open(include_dir + "/postgresql/server/parser/kwlist.h", "rb") as ins:
|
||||
with open(include_dir + "/postgresql/server/parser/kwlist.h", "rb") as ins:
|
||||
|
||||
pattern = re.compile(r'"([^"]+)",\s*[^,]*\s*,\s*(.*)$')
|
||||
keyword_types = [
|
||||
u'UNRESERVED_KEYWORD', u'COL_NAME_KEYWORD',
|
||||
u'TYPE_FUNC_NAME_KEYWORD', u'RESERVED_KEYWORD'
|
||||
]
|
||||
pattern = re.compile(r'"([^"]+)",\s*[^,]*\s*,\s*(.*)$')
|
||||
keyword_types = [
|
||||
u'UNRESERVED_KEYWORD', u'COL_NAME_KEYWORD',
|
||||
u'TYPE_FUNC_NAME_KEYWORD', u'RESERVED_KEYWORD'
|
||||
]
|
||||
|
||||
for line in ins:
|
||||
line = line.decode().rstrip()
|
||||
if line[0:11] == 'PG_KEYWORD(' and line[-1] == ')':
|
||||
match = pattern.match(line[11:-1])
|
||||
if idx != 0:
|
||||
keywords_file.write(", ")
|
||||
else:
|
||||
keywords_file.write(" ")
|
||||
keywords_file.write(
|
||||
'"' + match.group(1) + u'": ' +
|
||||
str(keyword_types.index(match.group(2)))
|
||||
)
|
||||
idx += 1
|
||||
keywords_file.write('\n }\n')
|
||||
keywords_file.write(' return (key in keywordDict and keywordDict[key]) or None')
|
||||
for line in ins:
|
||||
line = line.decode().rstrip()
|
||||
if line[0:11] == 'PG_KEYWORD(' and line[-1] == ')':
|
||||
match = pattern.match(line[11:-1])
|
||||
if idx != 0:
|
||||
keywords_file.write(", ")
|
||||
else:
|
||||
keywords_file.write(" ")
|
||||
keywords_file.write(
|
||||
'"' + match.group(1) + u'": ' +
|
||||
str(keyword_types.index(match.group(2)))
|
||||
)
|
||||
idx += 1
|
||||
keywords_file.write('\n }\n')
|
||||
keywords_file.write(' return (key in keywordDict and keywordDict[key]) or None')
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user