Fixed following SoanrQube issues

1) Rename field "node_type" to prevent any misunderstanding/clash with field "NODE_TYPE" defined.
  2) Define a constant instead of duplicating this literal.

Solution:
  1) Rename the field "NODE_TYPE" and "COLLECTION_LABEL" to "_NODE_TYPE" and "_COLLECTION_LABEL"
  2) Declare the constant in PGChildNodeView for SQL files.
This commit is contained in:
Akshay Joshi 2020-07-16 19:39:55 +05:30
parent 5d8c79da38
commit 703faf3b15
55 changed files with 816 additions and 751 deletions

View File

@ -119,7 +119,7 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
@property @property
def node_type(self): def node_type(self):
return '%s' % (self.NODE_TYPE) return '%s' % (self._NODE_TYPE)
@property @property
def csssnippets(self): def csssnippets(self):
@ -147,13 +147,13 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
def collection_label(self): def collection_label(self):
""" """
Label to be shown for the collection node, do not forget to set the Label to be shown for the collection node, do not forget to set the
class level variable COLLECTION_LABEL. class level variable _COLLECTION_LABEL.
""" """
return gettext(self.COLLECTION_LABEL) return gettext(self._COLLECTION_LABEL)
@property @property
def label(self): def label(self):
return gettext(self.COLLECTION_LABEL) return gettext(self._COLLECTION_LABEL)
@property @property
def collection_icon(self): def collection_icon(self):

View File

@ -26,7 +26,7 @@ from pgadmin.model import db, ServerGroup
class ServerGroupModule(BrowserPluginModule): class ServerGroupModule(BrowserPluginModule):
NODE_TYPE = "server_group" _NODE_TYPE = "server_group"
def get_nodes(self, *arg, **kwargs): def get_nodes(self, *arg, **kwargs):
"""Return a JSON document listing the server groups for the user""" """Return a JSON document listing the server groups for the user"""
@ -47,10 +47,10 @@ class ServerGroupModule(BrowserPluginModule):
def node_type(self): def node_type(self):
""" """
node_type node_type
Node type for Server Group is server-group. It is defined by NODE_TYPE Node type for Server Group is server-group. It is defined by _NODE_TYPE
static attribute of the class. static attribute of the class.
""" """
return self.NODE_TYPE return self._NODE_TYPE
@property @property
def script_load(self): def script_load(self):
@ -72,7 +72,7 @@ class ServerGroupModule(BrowserPluginModule):
class ServerGroupMenuItem(MenuItem): class ServerGroupMenuItem(MenuItem):
def __init__(self, **kwargs): def __init__(self, **kwargs):
kwargs.setdefault("type", ServerGroupModule.NODE_TYPE) kwargs.setdefault("type", ServerGroupModule.node_type)
super(ServerGroupMenuItem, self).__init__(**kwargs) super(ServerGroupMenuItem, self).__init__(**kwargs)
@ -91,7 +91,7 @@ blueprint = ServerGroupModule(__name__)
class ServerGroupView(NodeView): class ServerGroupView(NodeView):
node_type = ServerGroupModule.NODE_TYPE node_type = ServerGroupModule.node_type
parent_ids = [] parent_ids = []
ids = [{'type': 'int', 'id': 'gid'}] ids = [{'type': 'int', 'id': 'gid'}]

View File

@ -97,12 +97,12 @@ def server_icon_and_background(is_connected, manager, server):
class ServerModule(sg.ServerGroupPluginModule): class ServerModule(sg.ServerGroupPluginModule):
NODE_TYPE = "server" _NODE_TYPE = "server"
LABEL = gettext("Servers") LABEL = gettext("Servers")
@property @property
def node_type(self): def node_type(self):
return self.NODE_TYPE return self._NODE_TYPE
@property @property
def script_load(self): def script_load(self):
@ -110,7 +110,7 @@ class ServerModule(sg.ServerGroupPluginModule):
Load the module script for server, when any of the server-group node is Load the module script for server, when any of the server-group node is
initialized. initialized.
""" """
return sg.ServerGroupModule.NODE_TYPE return sg.ServerGroupModule.node_type
@login_required @login_required
def get_nodes(self, gid): def get_nodes(self, gid):
@ -144,7 +144,7 @@ class ServerModule(sg.ServerGroupPluginModule):
server.name, server.name,
server_icon_and_background(connected, manager, server), server_icon_and_background(connected, manager, server),
True, True,
self.NODE_TYPE, self.node_type,
connected=connected, connected=connected,
server_type=manager.server_type if connected else "pg", server_type=manager.server_type if connected else "pg",
version=manager.version, version=manager.version,
@ -231,7 +231,7 @@ class ServerModule(sg.ServerGroupPluginModule):
class ServerMenuItem(MenuItem): class ServerMenuItem(MenuItem):
def __init__(self, **kwargs): def __init__(self, **kwargs):
kwargs.setdefault("type", ServerModule.NODE_TYPE) kwargs.setdefault("type", ServerModule.node_type)
super(ServerMenuItem, self).__init__(**kwargs) super(ServerMenuItem, self).__init__(**kwargs)
@ -239,7 +239,7 @@ blueprint = ServerModule(__name__)
class ServerNode(PGChildNodeView): class ServerNode(PGChildNodeView):
node_type = ServerModule.NODE_TYPE node_type = ServerModule._NODE_TYPE
parent_ids = [{'type': 'int', 'id': 'gid'}] parent_ids = [{'type': 'int', 'id': 'gid'}]
ids = [{'type': 'int', 'id': 'sid'}] ids = [{'type': 'int', 'id': 'sid'}]

View File

@ -36,8 +36,8 @@ from pgadmin.model import db, Server, Database
class DatabaseModule(CollectionNodeModule): class DatabaseModule(CollectionNodeModule):
NODE_TYPE = 'database' _NODE_TYPE = 'database'
COLLECTION_LABEL = _("Databases") _COLLECTION_LABEL = _("Databases")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.min_ver = None self.min_ver = None
@ -58,7 +58,7 @@ class DatabaseModule(CollectionNodeModule):
Load the module script for server, when any of the server-group node is Load the module script for server, when any of the server-group node is
initialized. initialized.
""" """
return servers.ServerModule.NODE_TYPE return servers.ServerModule.node_type
@property @property
def csssnippets(self): def csssnippets(self):
@ -218,7 +218,7 @@ class DatabaseView(PGChildNodeView):
params = tuple(self.manager.db_res.split(',')) params = tuple(self.manager.db_res.split(','))
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
conn=self.conn, conn=self.conn,
last_system_oid=last_system_oid, last_system_oid=last_system_oid,
db_restrictions=db_disp_res db_restrictions=db_disp_res
@ -265,7 +265,7 @@ class DatabaseView(PGChildNodeView):
) )
params = tuple(server_node_res.db_res.split(',')) params = tuple(server_node_res.db_res.split(','))
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
last_system_oid=last_system_oid, last_system_oid=last_system_oid,
db_restrictions=db_disp_res db_restrictions=db_disp_res
) )
@ -323,7 +323,7 @@ class DatabaseView(PGChildNodeView):
""" """
res = [] res = []
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
last_system_oid=0, last_system_oid=0,
) )
status, rset = self.conn.execute_dict(SQL) status, rset = self.conn.execute_dict(SQL)
@ -342,7 +342,7 @@ class DatabaseView(PGChildNodeView):
@check_precondition(action="node") @check_precondition(action="node")
def node(self, gid, sid, did): def node(self, gid, sid, did):
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
did=did, conn=self.conn, last_system_oid=0 did=did, conn=self.conn, last_system_oid=0
) )
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -380,7 +380,7 @@ class DatabaseView(PGChildNodeView):
def properties(self, gid, sid, did): def properties(self, gid, sid, did):
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
did=did, conn=self.conn, last_system_oid=0 did=did, conn=self.conn, last_system_oid=0
) )
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -394,7 +394,7 @@ class DatabaseView(PGChildNodeView):
) )
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'acl.sql']), "/".join([self.template_path, self._ACL_SQL]),
did=did, conn=self.conn did=did, conn=self.conn
) )
status, dataclres = self.conn.execute_dict(SQL) status, dataclres = self.conn.execute_dict(SQL)
@ -582,7 +582,7 @@ class DatabaseView(PGChildNodeView):
) )
# The below SQL will execute CREATE DDL only # The below SQL will execute CREATE DDL only
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
status, msg = self.conn.execute_scalar(SQL) status, msg = self.conn.execute_scalar(SQL)
@ -595,7 +595,7 @@ class DatabaseView(PGChildNodeView):
# The below SQL will execute rest DMLs because we cannot execute # The below SQL will execute rest DMLs because we cannot execute
# CREATE with any other # CREATE with any other
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'grant.sql']), "/".join([self.template_path, self._GRANT_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
SQL = SQL.strip('\n').strip(' ') SQL = SQL.strip('\n').strip(' ')
@ -606,7 +606,7 @@ class DatabaseView(PGChildNodeView):
# We need oid of newly created database # We need oid of newly created database
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
name=data['name'], conn=self.conn, last_system_oid=0 name=data['name'], conn=self.conn, last_system_oid=0
) )
SQL = SQL.strip('\n').strip(' ') SQL = SQL.strip('\n').strip(' ')
@ -682,7 +682,7 @@ class DatabaseView(PGChildNodeView):
# Fetch the name of database for comparison # Fetch the name of database for comparison
status, rset = self.conn.execute_dict( status, rset = self.conn.execute_dict(
render_template( render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
did=did, conn=self.conn, last_system_oid=0 did=did, conn=self.conn, last_system_oid=0
) )
) )
@ -786,7 +786,7 @@ class DatabaseView(PGChildNodeView):
# generation # generation
status, rset = self.conn.execute_dict( status, rset = self.conn.execute_dict(
render_template( render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
did=did, conn=self.conn, last_system_oid=0 did=did, conn=self.conn, last_system_oid=0
) )
) )
@ -843,7 +843,7 @@ class DatabaseView(PGChildNodeView):
for did in data['ids']: for did in data['ids']:
default_conn = self.manager.connection() default_conn = self.manager.connection()
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
did=did, conn=self.conn did=did, conn=self.conn
) )
status, res = default_conn.execute_scalar(SQL) status, res = default_conn.execute_scalar(SQL)
@ -866,7 +866,7 @@ class DatabaseView(PGChildNodeView):
status = self.manager.release(did=did) status = self.manager.release(did=did)
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
datname=res, conn=self.conn datname=res, conn=self.conn
) )
@ -917,7 +917,7 @@ class DatabaseView(PGChildNodeView):
conn = self.manager.connection() conn = self.manager.connection()
status, rset = conn.execute_dict( status, rset = conn.execute_dict(
render_template( render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
did=did, conn=conn, last_system_oid=0 did=did, conn=conn, last_system_oid=0
) )
) )
@ -974,13 +974,13 @@ class DatabaseView(PGChildNodeView):
) )
sql_acl = render_template( sql_acl = render_template(
"/".join([self.template_path, 'grant.sql']), "/".join([self.template_path, self._GRANT_SQL]),
data=data, data=data,
conn=self.conn conn=self.conn
) )
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
SQL += "\n" SQL += "\n"
@ -1087,7 +1087,7 @@ class DatabaseView(PGChildNodeView):
conn = self.manager.connection() conn = self.manager.connection()
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
did=did, conn=conn, last_system_oid=0 did=did, conn=conn, last_system_oid=0
) )
status, res = conn.execute_dict(SQL) status, res = conn.execute_dict(SQL)
@ -1101,7 +1101,7 @@ class DatabaseView(PGChildNodeView):
) )
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'acl.sql']), "/".join([self.template_path, self._ACL_SQL]),
did=did, conn=self.conn did=did, conn=self.conn
) )
status, dataclres = self.conn.execute_dict(SQL) status, dataclres = self.conn.execute_dict(SQL)
@ -1142,7 +1142,7 @@ class DatabaseView(PGChildNodeView):
sql_header = u"-- Database: {0}\n\n-- ".format(result['name']) sql_header = u"-- Database: {0}\n\n-- ".format(result['name'])
sql_header += render_template( sql_header += render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
datname=result['name'], conn=conn datname=result['name'], conn=conn
) )

View File

@ -45,8 +45,8 @@ class CastModule(CollectionNodeModule):
initialized. initialized.
""" """
NODE_TYPE = 'cast' _NODE_TYPE = 'cast'
COLLECTION_LABEL = gettext('Casts') _COLLECTION_LABEL = gettext('Casts')
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(CastModule, self).__init__(*args, **kwargs) super(CastModule, self).__init__(*args, **kwargs)
@ -74,7 +74,7 @@ class CastModule(CollectionNodeModule):
Load the module script for cast, when any of the database node is Load the module script for cast, when any of the database node is
initialized. initialized.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -224,7 +224,7 @@ class CastView(PGChildNodeView):
if self.manager.db_info is not None and \ if self.manager.db_info is not None and \
did in self.manager.db_info else 0 did in self.manager.db_info else 0
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
datlastsysoid=last_system_oid, datlastsysoid=last_system_oid,
showsysobj=self.blueprint.show_system_objects showsysobj=self.blueprint.show_system_objects
) )
@ -258,7 +258,7 @@ class CastView(PGChildNodeView):
if self.manager.db_info is not None and \ if self.manager.db_info is not None and \
did in self.manager.db_info else 0 did in self.manager.db_info else 0
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
datlastsysoid=last_system_oid, datlastsysoid=last_system_oid,
showsysobj=self.blueprint.show_system_objects showsysobj=self.blueprint.show_system_objects
) )
@ -286,7 +286,7 @@ class CastView(PGChildNodeView):
This function will fetch properties of the cast node This function will fetch properties of the cast node
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
cid=cid cid=cid
) )
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
@ -320,7 +320,7 @@ class CastView(PGChildNodeView):
self.manager.db_info is not None and \ self.manager.db_info is not None and \
did in self.manager.db_info else 0 did in self.manager.db_info else 0
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
cid=cid, cid=cid,
datlastsysoid=last_system_oid, datlastsysoid=last_system_oid,
showsysobj=self.blueprint.show_system_objects showsysobj=self.blueprint.show_system_objects
@ -368,7 +368,8 @@ class CastView(PGChildNodeView):
).format(arg) ).format(arg)
) )
try: try:
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=data, data=data,
conn=self.conn, conn=self.conn,
) )
@ -383,7 +384,7 @@ class CastView(PGChildNodeView):
if self.manager.db_info is not None and \ if self.manager.db_info is not None and \
did in self.manager.db_info else 0 did in self.manager.db_info else 0
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
srctyp=data['srctyp'], srctyp=data['srctyp'],
trgtyp=data['trgtyp'], trgtyp=data['trgtyp'],
datlastsysoid=last_system_oid, datlastsysoid=last_system_oid,
@ -466,7 +467,7 @@ class CastView(PGChildNodeView):
try: try:
# Get name for cast from cid # Get name for cast from cid
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
cid=cid) cid=cid)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -487,7 +488,7 @@ class CastView(PGChildNodeView):
# drop cast # drop cast
result = res['rows'][0] result = res['rows'][0]
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
castsource=result['castsource'], castsource=result['castsource'],
casttarget=result['casttarget'], casttarget=result['casttarget'],
cascade=cascade cascade=cascade
@ -544,7 +545,7 @@ class CastView(PGChildNodeView):
if self.manager.db_info is not None and \ if self.manager.db_info is not None and \
did in self.manager.db_info else 0 did in self.manager.db_info else 0
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
cid=cid, cid=cid,
datlastsysoid=last_system_oid, datlastsysoid=last_system_oid,
showsysobj=self.blueprint.show_system_objects showsysobj=self.blueprint.show_system_objects
@ -561,14 +562,14 @@ class CastView(PGChildNodeView):
old_data = res['rows'][0] old_data = res['rows'][0]
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data data=data, o_data=old_data
) )
return sql, data['name'] if 'name' in data else old_data['name'] return sql, data['name'] if 'name' in data else old_data['name']
else: else:
if 'srctyp' in data and 'trgtyp' in data: if 'srctyp' in data and 'trgtyp' in data:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
else: else:

View File

@ -43,8 +43,8 @@ class EventTriggerModule(CollectionNodeModule):
is initialized. is initialized.
""" """
NODE_TYPE = 'event_trigger' _NODE_TYPE = 'event_trigger'
COLLECTION_LABEL = gettext("Event Triggers") _COLLECTION_LABEL = gettext("Event Triggers")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -80,7 +80,7 @@ class EventTriggerModule(CollectionNodeModule):
Load the module script for event_trigger, when any of the database node Load the module script for event_trigger, when any of the database node
is initialized. is initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -215,7 +215,8 @@ class EventTriggerView(PGChildNodeView):
Returns: Returns:
""" """
sql = render_template("/".join([self.template_path, 'properties.sql'])) sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]))
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -242,7 +243,7 @@ class EventTriggerView(PGChildNodeView):
""" """
result = [] result = []
sql = render_template("/".join([self.template_path, 'nodes.sql'])) sql = render_template("/".join([self.template_path, self._NODES_SQL]))
status, res = self.conn.execute_2darray(sql) status, res = self.conn.execute_2darray(sql)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
@ -275,7 +276,7 @@ class EventTriggerView(PGChildNodeView):
Returns: Returns:
Json object of trigger node Json object of trigger node
""" """
sql = render_template("/".join([self.template_path, 'nodes.sql']), sql = render_template("/".join([self.template_path, self._NODES_SQL]),
etid=etid) etid=etid)
status, res = self.conn.execute_2darray(sql) status, res = self.conn.execute_2darray(sql)
if not status: if not status:
@ -326,7 +327,7 @@ class EventTriggerView(PGChildNodeView):
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
etid=etid, conn=self.conn etid=etid, conn=self.conn
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -385,14 +386,14 @@ class EventTriggerView(PGChildNodeView):
) )
try: try:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
status, res = self.conn.execute_scalar(sql) status, res = self.conn.execute_scalar(sql)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'grant.sql']), "/".join([self.template_path, self._GRANT_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
sql = sql.strip('\n').strip(' ') sql = sql.strip('\n').strip(' ')
@ -402,7 +403,7 @@ class EventTriggerView(PGChildNodeView):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'get_oid.sql']), "/".join([self.template_path, self._OID_SQL]),
data=data data=data
) )
status, etid = self.conn.execute_scalar(sql) status, etid = self.conn.execute_scalar(sql)
@ -451,7 +452,7 @@ class EventTriggerView(PGChildNodeView):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'get_oid.sql']), "/".join([self.template_path, self._OID_SQL]),
data=data data=data
) )
status, etid = self.conn.execute_scalar(sql) status, etid = self.conn.execute_scalar(sql)
@ -510,7 +511,7 @@ class EventTriggerView(PGChildNodeView):
try: try:
for etid in data['ids']: for etid in data['ids']:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
etid=etid etid=etid
) )
status, name = self.conn.execute_scalar(sql) status, name = self.conn.execute_scalar(sql)
@ -530,7 +531,7 @@ class EventTriggerView(PGChildNodeView):
) )
sql = render_template( sql = render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
name=name, cascade=cascade name=name, cascade=cascade
) )
status, res = self.conn.execute_scalar(sql) status, res = self.conn.execute_scalar(sql)
@ -600,7 +601,7 @@ class EventTriggerView(PGChildNodeView):
if etid is not None: if etid is not None:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
etid=etid etid=etid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -619,7 +620,7 @@ class EventTriggerView(PGChildNodeView):
if arg not in data: if arg not in data:
data[arg] = old_data[arg] data[arg] = old_data[arg]
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data data=data, o_data=old_data
) )
else: else:
@ -648,12 +649,12 @@ class EventTriggerView(PGChildNodeView):
).format(arg) ).format(arg)
) )
sql = render_template( sql = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data data=data
) )
sql += "\n" sql += "\n"
sql += render_template( sql += render_template(
"/".join([self.template_path, 'grant.sql']), "/".join([self.template_path, self._GRANT_SQL]),
data=data data=data
) )
return sql return sql
@ -674,7 +675,7 @@ class EventTriggerView(PGChildNodeView):
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
etid=etid etid=etid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -692,12 +693,12 @@ class EventTriggerView(PGChildNodeView):
result = self._formatter(result) result = self._formatter(result)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=result, conn=self.conn data=result, conn=self.conn
) )
sql += "\n\n" sql += "\n\n"
sql += render_template( sql += render_template(
"/".join([self.template_path, 'grant.sql']), "/".join([self.template_path, self._GRANT_SQL]),
data=result, conn=self.conn data=result, conn=self.conn
) )
@ -714,7 +715,7 @@ class EventTriggerView(PGChildNodeView):
) )
sql_header += render_template( sql_header += render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
name=result['name'], ) name=result['name'], )
sql_header += "\n" sql_header += "\n"

View File

@ -31,8 +31,8 @@ class ExtensionModule(CollectionNodeModule):
class and define methods to get child nodes, to load its own class and define methods to get child nodes, to load its own
javascript file. javascript file.
""" """
NODE_TYPE = "extension" _NODE_TYPE = "extension"
COLLECTION_LABEL = gettext("Extensions") _COLLECTION_LABEL = gettext("Extensions")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -60,7 +60,7 @@ class ExtensionModule(CollectionNodeModule):
Load the module script for extension, when any of the database nodes Load the module script for extension, when any of the database nodes
are initialized. are initialized.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -147,7 +147,8 @@ class ExtensionView(PGChildNodeView):
""" """
Fetches all extensions properties and render into properties tab Fetches all extensions properties and render into properties tab
""" """
SQL = render_template("/".join([self.template_path, 'properties.sql'])) SQL = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]))
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -163,7 +164,8 @@ class ExtensionView(PGChildNodeView):
Lists all extensions under the Extensions Collection node Lists all extensions under the Extensions Collection node
""" """
res = [] res = []
SQL = render_template("/".join([self.template_path, 'properties.sql'])) SQL = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]))
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
@ -187,7 +189,8 @@ class ExtensionView(PGChildNodeView):
""" """
This function will fetch the properties of extension This function will fetch the properties of extension
""" """
SQL = render_template("/".join([self.template_path, 'properties.sql']), SQL = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
eid=eid) eid=eid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
@ -212,7 +215,7 @@ class ExtensionView(PGChildNodeView):
Fetch the properties of a single extension and render in properties tab Fetch the properties of a single extension and render in properties tab
""" """
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'properties.sql']), eid=eid) [self.template_path, self._PROPERTIES_SQL]), eid=eid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
@ -254,7 +257,7 @@ class ExtensionView(PGChildNodeView):
status, res = self.conn.execute_dict( status, res = self.conn.execute_dict(
render_template( render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data data=data
) )
) )
@ -264,7 +267,7 @@ class ExtensionView(PGChildNodeView):
status, rset = self.conn.execute_dict( status, rset = self.conn.execute_dict(
render_template( render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
ename=data['name'] ename=data['name']
) )
) )
@ -331,7 +334,7 @@ class ExtensionView(PGChildNodeView):
for eid in data['ids']: for eid in data['ids']:
# check if extension with eid exists # check if extension with eid exists
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'delete.sql']), eid=eid) [self.template_path, self._DELETE_SQL]), eid=eid)
status, name = self.conn.execute_scalar(SQL) status, name = self.conn.execute_scalar(SQL)
if not status: if not status:
return internal_server_error(errormsg=name) return internal_server_error(errormsg=name)
@ -350,7 +353,7 @@ class ExtensionView(PGChildNodeView):
# drop extension # drop extension
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'delete.sql'] [self.template_path, self._DELETE_SQL]
), name=name, cascade=cascade) ), name=name, cascade=cascade)
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
if not status: if not status:
@ -395,7 +398,7 @@ class ExtensionView(PGChildNodeView):
if eid is not None: if eid is not None:
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'properties.sql'] [self.template_path, self._PROPERTIES_SQL]
), eid=eid) ), eid=eid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -411,12 +414,12 @@ class ExtensionView(PGChildNodeView):
if arg not in data: if arg not in data:
data[arg] = old_data[arg] data[arg] = old_data[arg]
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'update.sql'] [self.template_path, self._UPDATE_SQL]
), data=data, o_data=old_data) ), data=data, o_data=old_data)
return SQL, data['name'] if 'name' in data else old_data['name'] return SQL, data['name'] if 'name' in data else old_data['name']
else: else:
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'create.sql'] [self.template_path, self._CREATE_SQL]
), data=data) ), data=data)
return SQL, data['name'] return SQL, data['name']
@ -454,7 +457,7 @@ class ExtensionView(PGChildNodeView):
This function will generate sql for the sql panel This function will generate sql for the sql panel
""" """
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'properties.sql'] [self.template_path, self._PROPERTIES_SQL]
), eid=eid) ), eid=eid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -467,7 +470,7 @@ class ExtensionView(PGChildNodeView):
result = res['rows'][0] result = res['rows'][0]
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'create.sql'] [self.template_path, self._CREATE_SQL]
), ),
data=result, data=result,
conn=self.conn, conn=self.conn,

View File

@ -52,8 +52,8 @@ class ExternalTablesModule(CollectionNodeModule):
the database node is initialized. the database node is initialized.
""" """
NODE_TYPE = 'external_table' _NODE_TYPE = 'external_table'
COLLECTION_LABEL = gettext("External Tables") _COLLECTION_LABEL = gettext("External Tables")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -80,7 +80,7 @@ class ExternalTablesModule(CollectionNodeModule):
Returns: node type of the database module. Returns: node type of the database module.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -191,7 +191,7 @@ class ExternalTablesView(PGChildNodeView):
sql_statement = render_template( sql_statement = render_template(
template_name_or_list=os.path.join( template_name_or_list=os.path.join(
self.sql_template_path, self.sql_template_path,
'node.sql' self._NODE_SQL
), ),
external_table_id=external_table_id external_table_id=external_table_id
) )

View File

@ -46,8 +46,8 @@ class ForeignDataWrapperModule(CollectionNodeModule):
when any of the database node is initialized. when any of the database node is initialized.
""" """
NODE_TYPE = 'foreign_data_wrapper' _NODE_TYPE = 'foreign_data_wrapper'
COLLECTION_LABEL = gettext("Foreign Data Wrappers") _COLLECTION_LABEL = gettext("Foreign Data Wrappers")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -84,7 +84,7 @@ class ForeignDataWrapperModule(CollectionNodeModule):
Returns: node type of the databse module. Returns: node type of the databse module.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -238,7 +238,8 @@ class ForeignDataWrapperView(PGChildNodeView):
sid: Server ID sid: Server ID
did: Database ID did: Database ID
""" """
sql = render_template("/".join([self.template_path, 'properties.sql']), sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
conn=self.conn) conn=self.conn)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -268,7 +269,8 @@ class ForeignDataWrapperView(PGChildNodeView):
did: Database ID did: Database ID
""" """
res = [] res = []
sql = render_template("/".join([self.template_path, 'properties.sql']), sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
conn=self.conn conn=self.conn
) )
status, r_set = self.conn.execute_2darray(sql) status, r_set = self.conn.execute_2darray(sql)
@ -300,7 +302,8 @@ class ForeignDataWrapperView(PGChildNodeView):
did: Database ID did: Database ID
fid: Foreign data wrapper ID fid: Foreign data wrapper ID
""" """
sql = render_template("/".join([self.template_path, 'properties.sql']), sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
conn=self.conn, fid=fid) conn=self.conn, fid=fid)
status, r_set = self.conn.execute_2darray(sql) status, r_set = self.conn.execute_2darray(sql)
if not status: if not status:
@ -333,7 +336,7 @@ class ForeignDataWrapperView(PGChildNodeView):
fid: foreign data wrapper ID fid: foreign data wrapper ID
""" """
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
fid=fid, conn=self.conn fid=fid, conn=self.conn
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -356,7 +359,7 @@ class ForeignDataWrapperView(PGChildNodeView):
'fdwoption', 'fdwvalue' 'fdwoption', 'fdwvalue'
) )
sql = render_template("/".join([self.template_path, 'acl.sql']), sql = render_template("/".join([self.template_path, self._ACL_SQL]),
fid=fid fid=fid
) )
status, fdw_acl_res = self.conn.execute_dict(sql) status, fdw_acl_res = self.conn.execute_dict(sql)
@ -412,7 +415,8 @@ class ForeignDataWrapperView(PGChildNodeView):
data['fdwoptions'], 'fdwoption', 'fdwvalue' data['fdwoptions'], 'fdwoption', 'fdwvalue'
) )
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=data, data=data,
conn=self.conn, conn=self.conn,
is_valid_options=is_valid_options is_valid_options=is_valid_options
@ -422,7 +426,7 @@ class ForeignDataWrapperView(PGChildNodeView):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
fname=data['name'], fname=data['name'],
conn=self.conn conn=self.conn
) )
@ -508,7 +512,7 @@ class ForeignDataWrapperView(PGChildNodeView):
try: try:
# Get name of foreign data wrapper from fid # Get name of foreign data wrapper from fid
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
fid=fid, conn=self.conn fid=fid, conn=self.conn
) )
status, name = self.conn.execute_scalar(sql) status, name = self.conn.execute_scalar(sql)
@ -529,7 +533,7 @@ class ForeignDataWrapperView(PGChildNodeView):
) )
# drop foreign data wrapper node # drop foreign data wrapper node
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
name=name, name=name,
cascade=cascade, cascade=cascade,
conn=self.conn) conn=self.conn)
@ -601,7 +605,7 @@ class ForeignDataWrapperView(PGChildNodeView):
if fid is not None: if fid is not None:
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
fid=fid, fid=fid,
conn=self.conn conn=self.conn
) )
@ -661,7 +665,7 @@ class ForeignDataWrapperView(PGChildNodeView):
'fdwvalue') 'fdwvalue')
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, data=data,
o_data=old_data, o_data=old_data,
is_valid_added_options=is_valid_added_options, is_valid_added_options=is_valid_added_options,
@ -683,7 +687,7 @@ class ForeignDataWrapperView(PGChildNodeView):
) )
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=data, conn=self.conn, data=data, conn=self.conn,
is_valid_options=is_valid_options is_valid_options=is_valid_options
) )
@ -702,7 +706,8 @@ class ForeignDataWrapperView(PGChildNodeView):
did: Database ID did: Database ID
fid: Foreign data wrapper ID fid: Foreign data wrapper ID
""" """
sql = render_template("/".join([self.template_path, 'properties.sql']), sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
fid=fid, conn=self.conn fid=fid, conn=self.conn
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -724,7 +729,7 @@ class ForeignDataWrapperView(PGChildNodeView):
if len(res['rows'][0]['fdwoptions']) > 0: if len(res['rows'][0]['fdwoptions']) > 0:
is_valid_options = True is_valid_options = True
sql = render_template("/".join([self.template_path, 'acl.sql']), sql = render_template("/".join([self.template_path, self._ACL_SQL]),
fid=fid) fid=fid)
status, fdw_acl_res = self.conn.execute_dict(sql) status, fdw_acl_res = self.conn.execute_dict(sql)
if not status: if not status:
@ -745,7 +750,8 @@ class ForeignDataWrapperView(PGChildNodeView):
) )
sql = '' sql = ''
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=res['rows'][0], conn=self.conn, data=res['rows'][0], conn=self.conn,
is_valid_options=is_valid_options is_valid_options=is_valid_options
) )

View File

@ -46,8 +46,8 @@ class ForeignServerModule(CollectionNodeModule):
the database node is initialized. the database node is initialized.
""" """
NODE_TYPE = 'foreign_server' _NODE_TYPE = 'foreign_server'
COLLECTION_LABEL = gettext("Foreign Servers") _COLLECTION_LABEL = gettext("Foreign Servers")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -84,7 +84,7 @@ class ForeignServerModule(CollectionNodeModule):
Returns: node type of the server module. Returns: node type of the server module.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -230,7 +230,8 @@ class ForeignServerView(PGChildNodeView):
fid: Foreign data wrapper ID fid: Foreign data wrapper ID
""" """
sql = render_template("/".join([self.template_path, 'properties.sql']), sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
fid=fid, conn=self.conn) fid=fid, conn=self.conn)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -257,7 +258,8 @@ class ForeignServerView(PGChildNodeView):
""" """
res = [] res = []
sql = render_template("/".join([self.template_path, 'properties.sql']), sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
fid=fid, conn=self.conn) fid=fid, conn=self.conn)
status, r_set = self.conn.execute_2darray(sql) status, r_set = self.conn.execute_2darray(sql)
@ -291,7 +293,8 @@ class ForeignServerView(PGChildNodeView):
fsid: Foreign server ID fsid: Foreign server ID
""" """
sql = render_template("/".join([self.template_path, 'properties.sql']), sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
fsid=fsid, conn=self.conn) fsid=fsid, conn=self.conn)
status, r_set = self.conn.execute_2darray(sql) status, r_set = self.conn.execute_2darray(sql)
@ -326,7 +329,8 @@ class ForeignServerView(PGChildNodeView):
fsid: foreign server ID fsid: foreign server ID
""" """
sql = render_template("/".join([self.template_path, 'properties.sql']), sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
fsid=fsid, conn=self.conn) fsid=fsid, conn=self.conn)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -346,7 +350,7 @@ class ForeignServerView(PGChildNodeView):
res['rows'][0]['fsrvoptions'], 'fsrvoption', 'fsrvvalue' res['rows'][0]['fsrvoptions'], 'fsrvoption', 'fsrvvalue'
) )
sql = render_template("/".join([self.template_path, 'acl.sql']), sql = render_template("/".join([self.template_path, self._ACL_SQL]),
fsid=fsid fsid=fsid
) )
status, fs_rv_acl_res = self.conn.execute_dict(sql) status, fs_rv_acl_res = self.conn.execute_dict(sql)
@ -399,7 +403,7 @@ class ForeignServerView(PGChildNodeView):
data['fsrvacl'] = parse_priv_to_db(data['fsrvacl'], ['U']) data['fsrvacl'] = parse_priv_to_db(data['fsrvacl'], ['U'])
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
fdwid=fid, conn=self.conn) fdwid=fid, conn=self.conn)
status, res1 = self.conn.execute_dict(sql) status, res1 = self.conn.execute_dict(sql)
if not status: if not status:
@ -416,7 +420,8 @@ class ForeignServerView(PGChildNodeView):
data['fsrvoptions'], 'fsrvoption', 'fsrvvalue' data['fsrvoptions'], 'fsrvoption', 'fsrvvalue'
) )
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=data, fdwdata=fdw_data, data=data, fdwdata=fdw_data,
is_valid_options=is_valid_options, is_valid_options=is_valid_options,
conn=self.conn) conn=self.conn)
@ -425,7 +430,7 @@ class ForeignServerView(PGChildNodeView):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
data=data, fdwdata=fdw_data, data=data, fdwdata=fdw_data,
conn=self.conn) conn=self.conn)
status, r_set = self.conn.execute_dict(sql) status, r_set = self.conn.execute_dict(sql)
@ -513,7 +518,7 @@ class ForeignServerView(PGChildNodeView):
for fsid in data['ids']: for fsid in data['ids']:
# Get name of foreign data wrapper from fid # Get name of foreign data wrapper from fid
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
fsid=fsid, conn=self.conn) fsid=fsid, conn=self.conn)
status, name = self.conn.execute_scalar(sql) status, name = self.conn.execute_scalar(sql)
if not status: if not status:
@ -534,7 +539,7 @@ class ForeignServerView(PGChildNodeView):
# drop foreign server # drop foreign server
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
name=name, cascade=cascade, name=name, cascade=cascade,
conn=self.conn) conn=self.conn)
status, res = self.conn.execute_scalar(sql) status, res = self.conn.execute_scalar(sql)
@ -608,7 +613,7 @@ class ForeignServerView(PGChildNodeView):
if fsid is not None: if fsid is not None:
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
fsid=fsid, conn=self.conn) fsid=fsid, conn=self.conn)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -662,7 +667,7 @@ class ForeignServerView(PGChildNodeView):
'fsrvvalue') 'fsrvvalue')
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, data=data,
o_data=old_data, o_data=old_data,
is_valid_added_options=is_valid_added_options, is_valid_added_options=is_valid_added_options,
@ -672,7 +677,7 @@ class ForeignServerView(PGChildNodeView):
return sql, data['name'] if 'name' in data else old_data['name'] return sql, data['name'] if 'name' in data else old_data['name']
else: else:
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
fdwid=fid, conn=self.conn) fdwid=fid, conn=self.conn)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -690,7 +695,8 @@ class ForeignServerView(PGChildNodeView):
data['fsrvoptions'], 'fsrvoption', 'fsrvvalue' data['fsrvoptions'], 'fsrvoption', 'fsrvvalue'
) )
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=data, fdwdata=fdw_data, data=data, fdwdata=fdw_data,
is_valid_options=is_valid_options, is_valid_options=is_valid_options,
conn=self.conn) conn=self.conn)
@ -711,7 +717,8 @@ class ForeignServerView(PGChildNodeView):
fsid: Foreign server ID fsid: Foreign server ID
""" """
sql = render_template("/".join([self.template_path, 'properties.sql']), sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
fsid=fsid, conn=self.conn) fsid=fsid, conn=self.conn)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -730,7 +737,7 @@ class ForeignServerView(PGChildNodeView):
if len(res['rows'][0]['fsrvoptions']) > 0: if len(res['rows'][0]['fsrvoptions']) > 0:
is_valid_options = True is_valid_options = True
sql = render_template("/".join([self.template_path, 'acl.sql']), sql = render_template("/".join([self.template_path, self._ACL_SQL]),
fsid=fsid) fsid=fsid)
status, fs_rv_acl_res = self.conn.execute_dict(sql) status, fs_rv_acl_res = self.conn.execute_dict(sql)
if not status: if not status:
@ -750,7 +757,8 @@ class ForeignServerView(PGChildNodeView):
['U'] ['U']
) )
sql = render_template("/".join([self.template_path, 'properties.sql']), sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
fdwid=fid, conn=self.conn) fdwid=fid, conn=self.conn)
status, res1 = self.conn.execute_dict(sql) status, res1 = self.conn.execute_dict(sql)
if not status: if not status:
@ -759,7 +767,8 @@ class ForeignServerView(PGChildNodeView):
fdw_data = res1['rows'][0] fdw_data = res1['rows'][0]
sql = '' sql = ''
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=res['rows'][0], fdwdata=fdw_data, data=res['rows'][0], fdwdata=fdw_data,
is_valid_options=is_valid_options, is_valid_options=is_valid_options,
conn=self.conn) conn=self.conn)

View File

@ -50,8 +50,8 @@ class UserMappingModule(CollectionNodeModule):
foreign server node is initialized. foreign server node is initialized.
""" """
NODE_TYPE = 'user_mapping' _NODE_TYPE = 'user_mapping'
COLLECTION_LABEL = gettext("User Mappings") _COLLECTION_LABEL = gettext("User Mappings")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -100,7 +100,7 @@ class UserMappingModule(CollectionNodeModule):
Returns: node type of the server module. Returns: node type of the server module.
""" """
return servers.ServerModule.NODE_TYPE return servers.ServerModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -248,7 +248,7 @@ class UserMappingView(PGChildNodeView):
""" """
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
fsid=fsid, conn=self.conn) fsid=fsid, conn=self.conn)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -277,7 +277,7 @@ class UserMappingView(PGChildNodeView):
res = [] res = []
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
fsid=fsid, conn=self.conn) fsid=fsid, conn=self.conn)
status, r_set = self.conn.execute_2darray(sql) status, r_set = self.conn.execute_2darray(sql)
@ -312,7 +312,7 @@ class UserMappingView(PGChildNodeView):
umid: User mapping ID umid: User mapping ID
""" """
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
conn=self.conn, umid=umid) conn=self.conn, umid=umid)
status, r_set = self.conn.execute_2darray(sql) status, r_set = self.conn.execute_2darray(sql)
@ -348,7 +348,7 @@ class UserMappingView(PGChildNodeView):
""" """
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
umid=umid, conn=self.conn) umid=umid, conn=self.conn)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -405,7 +405,7 @@ class UserMappingView(PGChildNodeView):
try: try:
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
fserid=fsid, conn=self.conn) fserid=fsid, conn=self.conn)
status, res1 = self.conn.execute_dict(sql) status, res1 = self.conn.execute_dict(sql)
@ -423,7 +423,8 @@ class UserMappingView(PGChildNodeView):
data['umoptions'], 'umoption', 'umvalue' data['umoptions'], 'umoption', 'umvalue'
) )
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=data, fdwdata=fdw_data, data=data, fdwdata=fdw_data,
is_valid_options=is_valid_options, is_valid_options=is_valid_options,
conn=self.conn) conn=self.conn)
@ -432,7 +433,7 @@ class UserMappingView(PGChildNodeView):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
fsid=fsid, data=data, fsid=fsid, data=data,
conn=self.conn) conn=self.conn)
status, r_set = self.conn.execute_dict(sql) status, r_set = self.conn.execute_dict(sql)
@ -521,7 +522,7 @@ class UserMappingView(PGChildNodeView):
for umid in data['ids']: for umid in data['ids']:
# Get name of foreign server from fsid # Get name of foreign server from fsid
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
fsid=fsid, conn=self.conn) fsid=fsid, conn=self.conn)
status, name = self.conn.execute_scalar(sql) status, name = self.conn.execute_scalar(sql)
if not status: if not status:
@ -541,7 +542,7 @@ class UserMappingView(PGChildNodeView):
) )
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
umid=umid, conn=self.conn) umid=umid, conn=self.conn)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -560,7 +561,7 @@ class UserMappingView(PGChildNodeView):
# drop user mapping # drop user mapping
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
data=data, name=name, cascade=cascade, data=data, name=name, cascade=cascade,
conn=self.conn) conn=self.conn)
status, res = self.conn.execute_scalar(sql) status, res = self.conn.execute_scalar(sql)
@ -626,7 +627,7 @@ class UserMappingView(PGChildNodeView):
if umid is not None: if umid is not None:
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
umid=umid, conn=self.conn) umid=umid, conn=self.conn)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -644,7 +645,7 @@ class UserMappingView(PGChildNodeView):
old_data = res['rows'][0] old_data = res['rows'][0]
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
fserid=fsid, conn=self.conn) fserid=fsid, conn=self.conn)
status, res1 = self.conn.execute_dict(sql) status, res1 = self.conn.execute_dict(sql)
if not status: if not status:
@ -673,7 +674,7 @@ class UserMappingView(PGChildNodeView):
'umvalue') 'umvalue')
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, data=data,
o_data=old_data, o_data=old_data,
is_valid_added_options=is_valid_added_options, is_valid_added_options=is_valid_added_options,
@ -684,7 +685,7 @@ class UserMappingView(PGChildNodeView):
return sql, data['name'] if 'name' in data else old_data['name'] return sql, data['name'] if 'name' in data else old_data['name']
else: else:
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
fserid=fsid, conn=self.conn) fserid=fsid, conn=self.conn)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -697,7 +698,8 @@ class UserMappingView(PGChildNodeView):
data['umoptions'], 'umoption', 'umvalue' data['umoptions'], 'umoption', 'umvalue'
) )
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=data, fdwdata=fdw_data, data=data, fdwdata=fdw_data,
is_valid_options=is_valid_options, is_valid_options=is_valid_options,
conn=self.conn) conn=self.conn)
@ -719,7 +721,8 @@ class UserMappingView(PGChildNodeView):
umid: User mapping ID umid: User mapping ID
""" """
sql = render_template("/".join([self.template_path, 'properties.sql']), sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
umid=umid, conn=self.conn) umid=umid, conn=self.conn)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -738,7 +741,8 @@ class UserMappingView(PGChildNodeView):
if len(res['rows'][0]['umoptions']) > 0: if len(res['rows'][0]['umoptions']) > 0:
is_valid_options = True is_valid_options = True
sql = render_template("/".join([self.template_path, 'properties.sql']), sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
fserid=fsid, conn=self.conn fserid=fsid, conn=self.conn
) )
status, res1 = self.conn.execute_dict(sql) status, res1 = self.conn.execute_dict(sql)
@ -748,7 +752,8 @@ class UserMappingView(PGChildNodeView):
fdw_data = res1['rows'][0] fdw_data = res1['rows'][0]
sql = '' sql = ''
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=res['rows'][0], fdwdata=fdw_data, data=res['rows'][0], fdwdata=fdw_data,
is_valid_options=is_valid_options, is_valid_options=is_valid_options,
conn=self.conn) conn=self.conn)

View File

@ -47,8 +47,8 @@ class LanguageModule(CollectionNodeModule):
initialized. initialized.
""" """
NODE_TYPE = 'language' _NODE_TYPE = 'language'
COLLECTION_LABEL = gettext("Languages") _COLLECTION_LABEL = gettext("Languages")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -91,7 +91,7 @@ class LanguageModule(CollectionNodeModule):
Returns: node type of the server module. Returns: node type of the server module.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -253,7 +253,8 @@ class LanguageView(PGChildNodeView):
sid: Server ID sid: Server ID
did: Database ID did: Database ID
""" """
sql = render_template("/".join([self.template_path, 'properties.sql'])) sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]))
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -275,7 +276,8 @@ class LanguageView(PGChildNodeView):
did: Database ID did: Database ID
""" """
res = [] res = []
sql = render_template("/".join([self.template_path, 'properties.sql'])) sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]))
status, result = self.conn.execute_2darray(sql) status, result = self.conn.execute_2darray(sql)
if not status: if not status:
return internal_server_error(errormsg=result) return internal_server_error(errormsg=result)
@ -305,7 +307,8 @@ class LanguageView(PGChildNodeView):
did: Database ID did: Database ID
lid: Language ID lid: Language ID
""" """
sql = render_template("/".join([self.template_path, 'properties.sql']), sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
lid=lid) lid=lid)
status, result = self.conn.execute_2darray(sql) status, result = self.conn.execute_2darray(sql)
if not status: if not status:
@ -336,7 +339,7 @@ class LanguageView(PGChildNodeView):
lid: Language ID lid: Language ID
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
lid=lid lid=lid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -353,7 +356,7 @@ class LanguageView(PGChildNodeView):
res['rows'][0]['oid'] <= self.datlastsysoid) res['rows'][0]['oid'] <= self.datlastsysoid)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'acl.sql']), "/".join([self.template_path, self._ACL_SQL]),
lid=lid lid=lid
) )
status, result = self.conn.execute_dict(sql) status, result = self.conn.execute_dict(sql)
@ -465,14 +468,15 @@ class LanguageView(PGChildNodeView):
if 'lanacl' in data: if 'lanacl' in data:
data['lanacl'] = parse_priv_to_db(data['lanacl'], ['U']) data['lanacl'] = parse_priv_to_db(data['lanacl'], ['U'])
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=data, conn=self.conn) data=data, conn=self.conn)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
lanname=data['name'], conn=self.conn lanname=data['name'], conn=self.conn
) )
@ -521,7 +525,7 @@ class LanguageView(PGChildNodeView):
for lid in data['ids']: for lid in data['ids']:
# Get name for language from lid # Get name for language from lid
sql = render_template( sql = render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
lid=lid, conn=self.conn lid=lid, conn=self.conn
) )
status, lname = self.conn.execute_scalar(sql) status, lname = self.conn.execute_scalar(sql)
@ -531,7 +535,7 @@ class LanguageView(PGChildNodeView):
# drop language # drop language
sql = render_template( sql = render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
lname=lname, cascade=cascade, conn=self.conn lname=lname, cascade=cascade, conn=self.conn
) )
status, res = self.conn.execute_scalar(sql) status, res = self.conn.execute_scalar(sql)
@ -599,7 +603,7 @@ class LanguageView(PGChildNodeView):
if lid is not None: if lid is not None:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), lid=lid "/".join([self.template_path, self._PROPERTIES_SQL]), lid=lid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -630,7 +634,7 @@ class LanguageView(PGChildNodeView):
if arg not in data: if arg not in data:
data[arg] = old_data[arg] data[arg] = old_data[arg]
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data, conn=self.conn data=data, o_data=old_data, conn=self.conn
) )
return sql.strip('\n'), data['name'] if 'name' in data \ return sql.strip('\n'), data['name'] if 'name' in data \
@ -640,7 +644,8 @@ class LanguageView(PGChildNodeView):
if 'lanacl' in data: if 'lanacl' in data:
data['lanacl'] = parse_priv_to_db(data['lanacl'], ["U"]) data['lanacl'] = parse_priv_to_db(data['lanacl'], ["U"])
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=data, conn=self.conn) data=data, conn=self.conn)
return sql.strip('\n'), data['name'] return sql.strip('\n'), data['name']
@ -696,7 +701,7 @@ class LanguageView(PGChildNodeView):
lid: Language ID lid: Language ID
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
lid=lid lid=lid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -712,7 +717,7 @@ class LanguageView(PGChildNodeView):
old_data = dict(res['rows'][0]) old_data = dict(res['rows'][0])
sql = render_template( sql = render_template(
"/".join([self.template_path, 'acl.sql']), "/".join([self.template_path, self._ACL_SQL]),
lid=lid lid=lid
) )
status, result = self.conn.execute_dict(sql) status, result = self.conn.execute_dict(sql)

View File

@ -65,8 +65,8 @@ class SchemaModule(CollectionNodeModule):
- Load the module script for schema, when any of the server node is - Load the module script for schema, when any of the server node is
initialized. initialized.
""" """
NODE_TYPE = 'schema' _NODE_TYPE = 'schema'
COLLECTION_LABEL = gettext("Schemas") _COLLECTION_LABEL = gettext("Schemas")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -93,7 +93,7 @@ class SchemaModule(CollectionNodeModule):
Load the module script for schema, when any of the server node is Load the module script for schema, when any of the server node is
initialized. initialized.
""" """
return servers.ServerModule.NODE_TYPE return servers.ServerModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -111,8 +111,8 @@ class CatalogModule(SchemaModule):
A module class for the catalog schema node derived from SchemaModule. A module class for the catalog schema node derived from SchemaModule.
""" """
NODE_TYPE = 'catalog' _NODE_TYPE = 'catalog'
COLLECTION_LABEL = gettext("Catalogs") _COLLECTION_LABEL = gettext("Catalogs")
schema_blueprint = SchemaModule(__name__) schema_blueprint = SchemaModule(__name__)

View File

@ -43,8 +43,8 @@ class CatalogObjectModule(SchemaChildModule):
- Load the module script for Catalog objects, when any of the server node - Load the module script for Catalog objects, when any of the server node
is initialized. is initialized.
""" """
NODE_TYPE = 'catalog_object' _NODE_TYPE = 'catalog_object'
COLLECTION_LABEL = gettext("Catalog Objects") _COLLECTION_LABEL = gettext("Catalog Objects")
# Flag for not to show node under Schema/Catalog node # Flag for not to show node under Schema/Catalog node
# By default its set to True to display node in schema/catalog # By default its set to True to display node in schema/catalog
@ -78,7 +78,7 @@ class CatalogObjectModule(SchemaChildModule):
Load the module script for server, when any of the database node is Load the module script for server, when any of the database node is
initialized. initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
blueprint = CatalogObjectModule(__name__) blueprint = CatalogObjectModule(__name__)
@ -176,7 +176,7 @@ class CatalogObjectView(PGChildNodeView):
""" """
SQL = render_template("/".join([ SQL = render_template("/".join([
self.template_path, 'properties.sql' self.template_path, self._PROPERTIES_SQL
]), scid=scid ]), scid=scid
) )
@ -207,7 +207,7 @@ class CatalogObjectView(PGChildNodeView):
""" """
res = [] res = []
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'nodes.sql']), scid=scid "/".join([self.template_path, self._NODES_SQL]), scid=scid
) )
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -244,7 +244,7 @@ class CatalogObjectView(PGChildNodeView):
JSON of given catalog objects child node JSON of given catalog objects child node
""" """
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'nodes.sql']), coid=coid "/".join([self.template_path, self._NODES_SQL]), coid=coid
) )
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -283,7 +283,7 @@ class CatalogObjectView(PGChildNodeView):
JSON of selected catalog objects node JSON of selected catalog objects node
""" """
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid, coid=coid scid=scid, coid=coid
) )
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)

View File

@ -47,8 +47,8 @@ class CatalogObjectColumnsModule(CollectionNodeModule):
initialized. initialized.
""" """
NODE_TYPE = 'catalog_object_column' _NODE_TYPE = 'catalog_object_column'
COLLECTION_LABEL = gettext("Columns") _COLLECTION_LABEL = gettext("Columns")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -74,7 +74,7 @@ class CatalogObjectColumnsModule(CollectionNodeModule):
Load the module script for server, when any of the database node is Load the module script for server, when any of the database node is
initialized. initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def node_inode(self): def node_inode(self):
@ -201,7 +201,7 @@ class CatalogObjectColumnsView(PGChildNodeView):
JSON of available column nodes JSON of available column nodes
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), coid=coid) self._PROPERTIES_SQL]), coid=coid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -230,7 +230,7 @@ class CatalogObjectColumnsView(PGChildNodeView):
""" """
res = [] res = []
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), coid=coid) self._NODES_SQL]), coid=coid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
@ -267,7 +267,7 @@ class CatalogObjectColumnsView(PGChildNodeView):
JSON of selected column node JSON of selected column node
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), coid=coid, self._PROPERTIES_SQL]), coid=coid,
clid=clid) clid=clid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)

View File

@ -50,8 +50,8 @@ class CollationModule(SchemaChildModule):
initialized. initialized.
""" """
NODE_TYPE = 'collation' _NODE_TYPE = 'collation'
COLLECTION_LABEL = gettext("Collations") _COLLECTION_LABEL = gettext("Collations")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -79,7 +79,7 @@ class CollationModule(SchemaChildModule):
Load the module script for database, when any of the database node is Load the module script for database, when any of the database node is
initialized. initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def node_inode(self): def node_inode(self):
@ -225,7 +225,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), scid=scid) self._PROPERTIES_SQL]), scid=scid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -254,7 +254,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
res = [] res = []
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), scid=scid) self._NODES_SQL]), scid=scid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
@ -290,7 +290,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), coid=coid) self._NODES_SQL]), coid=coid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
@ -343,7 +343,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, coid=coid, scid=scid, coid=coid,
datlastsysoid=self.datlastsysoid) datlastsysoid=self.datlastsysoid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -474,7 +474,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
) )
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
@ -483,7 +483,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
# We need oid to to add object in tree at browser # We need oid to to add object in tree at browser
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'get_oid.sql']), data=data "/".join([self.template_path, self._OID_SQL]), data=data
) )
status, coid = self.conn.execute_scalar(SQL) status, coid = self.conn.execute_scalar(SQL)
if not status: if not status:
@ -491,7 +491,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
# Get updated schema oid # Get updated schema oid
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'get_oid.sql']), coid=coid "/".join([self.template_path, self._OID_SQL]), coid=coid
) )
status, new_scid = self.conn.execute_scalar(SQL) status, new_scid = self.conn.execute_scalar(SQL)
@ -551,7 +551,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
data = res['rows'][0] data = res['rows'][0]
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
name=data['name'], name=data['name'],
nspname=data['schema'], nspname=data['schema'],
cascade=cascade, cascade=cascade,
@ -600,7 +600,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
# We need oid to to add object in tree at browser # We need oid to to add object in tree at browser
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'get_oid.sql']), coid=coid) self._OID_SQL]), coid=coid)
status, res = self.conn.execute_2darray(SQL) status, res = self.conn.execute_2darray(SQL)
if not status: if not status:
@ -662,7 +662,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
if coid is not None: if coid is not None:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, coid=coid) scid=scid, coid=coid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -675,7 +675,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
old_data = res['rows'][0] old_data = res['rows'][0]
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data, conn=self.conn data=data, o_data=old_data, conn=self.conn
) )
return SQL.strip('\n'), data['name'] if 'name' in data else \ return SQL.strip('\n'), data['name'] if 'name' in data else \
@ -693,7 +693,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
return "-- missing definition" return "-- missing definition"
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=data, conn=self.conn) data=data, conn=self.conn)
return SQL.strip('\n'), data['name'] return SQL.strip('\n'), data['name']
@ -716,7 +716,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
json_resp = kwargs.get('json_resp', True) json_resp = kwargs.get('json_resp', True)
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, coid=coid) scid=scid, coid=coid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -732,13 +732,13 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
data['schema'] = diff_schema data['schema'] = diff_schema
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=data, conn=self.conn) data=data, conn=self.conn)
sql_header = u"-- Collation: {0};\n\n-- ".format(data['name']) sql_header = u"-- Collation: {0};\n\n-- ".format(data['name'])
sql_header += render_template("/".join([self.template_path, sql_header += render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
name=data['name'], name=data['name'],
nspname=data['schema']) nspname=data['schema'])
SQL = sql_header + '\n\n' + SQL.strip('\n') SQL = sql_header + '\n\n' + SQL.strip('\n')
@ -805,7 +805,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = dict() res = dict()
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), scid=scid) self._NODES_SQL]), scid=scid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)

View File

@ -49,8 +49,8 @@ class DomainModule(SchemaChildModule):
initialized. initialized.
""" """
NODE_TYPE = 'domain' _NODE_TYPE = 'domain'
COLLECTION_LABEL = gettext("Domains") _COLLECTION_LABEL = gettext("Domains")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(DomainModule, self).__init__(*args, **kwargs) super(DomainModule, self).__init__(*args, **kwargs)
@ -70,7 +70,7 @@ class DomainModule(SchemaChildModule):
Load the module script for domain, when schema node is Load the module script for domain, when schema node is
initialized. initialized.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
blueprint = DomainModule(__name__) blueprint = DomainModule(__name__)
@ -288,7 +288,7 @@ class DomainView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
scid: Schema Id scid: Schema Id
""" """
SQL = render_template("/".join([self.template_path, 'node.sql']), SQL = render_template("/".join([self.template_path, self._NODE_SQL]),
scid=scid) scid=scid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -312,7 +312,7 @@ class DomainView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
""" """
res = [] res = []
SQL = render_template("/".join([self.template_path, 'node.sql']), SQL = render_template("/".join([self.template_path, self._NODE_SQL]),
scid=scid) scid=scid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
@ -345,7 +345,7 @@ class DomainView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
doid: Domain Id doid: Domain Id
""" """
SQL = render_template("/".join([self.template_path, 'node.sql']), SQL = render_template("/".join([self.template_path, self._NODE_SQL]),
doid=doid) doid=doid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
@ -393,7 +393,8 @@ class DomainView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
:param doid: :param doid:
:return: :return:
""" """
SQL = render_template("/".join([self.template_path, 'properties.sql']), SQL = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
scid=scid, doid=doid) scid=scid, doid=doid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -559,7 +560,7 @@ AND relkind != 'c'))"""
# We need oid to to add object in tree at browser, below sql will # We need oid to to add object in tree at browser, below sql will
# gives the same # gives the same
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'get_oid.sql']), self._OID_SQL]),
basensp=data['basensp'], basensp=data['basensp'],
name=data['name']) name=data['name'])
status, doid = self.conn.execute_scalar(SQL) status, doid = self.conn.execute_scalar(SQL)
@ -568,7 +569,7 @@ AND relkind != 'c'))"""
# Get updated schema oid # Get updated schema oid
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'get_oid.sql']), self._OID_SQL]),
doid=doid) doid=doid)
status, scid = self.conn.execute_scalar(SQL) status, scid = self.conn.execute_scalar(SQL)
if not status: if not status:
@ -611,7 +612,7 @@ AND relkind != 'c'))"""
for doid in data['ids']: for doid in data['ids']:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
scid=scid, doid=doid) scid=scid, doid=doid)
status, res = self.conn.execute_2darray(SQL) status, res = self.conn.execute_2darray(SQL)
if not status: if not status:
@ -633,7 +634,7 @@ AND relkind != 'c'))"""
basensp = res['rows'][0]['basensp'] basensp = res['rows'][0]['basensp']
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
name=name, basensp=basensp, cascade=cascade) name=name, basensp=basensp, cascade=cascade)
# Used for schema diff tool # Used for schema diff tool
@ -674,7 +675,7 @@ AND relkind != 'c'))"""
# Get Schema Id # Get Schema Id
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'get_oid.sql']), self._OID_SQL]),
doid=doid) doid=doid)
status, scid = self.conn.execute_scalar(SQL) status, scid = self.conn.execute_scalar(SQL)
if not status: if not status:
@ -707,7 +708,7 @@ AND relkind != 'c'))"""
json_resp = kwargs.get('json_resp', True) json_resp = kwargs.get('json_resp', True)
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, doid=doid) scid=scid, doid=doid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -740,7 +741,7 @@ AND relkind != 'c'))"""
data.update(parse_sec_labels_from_db(data['seclabels'])) data.update(parse_sec_labels_from_db(data['seclabels']))
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), data=data) self._CREATE_SQL]), data=data)
sql_header = u"""-- DOMAIN: {0}.{1}\n\n""".format( sql_header = u"""-- DOMAIN: {0}.{1}\n\n""".format(
data['basensp'], data['name']) data['basensp'], data['name'])
@ -807,7 +808,7 @@ AND relkind != 'c'))"""
if doid is not None: if doid is not None:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, doid=doid) scid=scid, doid=doid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -845,13 +846,13 @@ AND relkind != 'c'))"""
data['is_schema_diff'] = True data['is_schema_diff'] = True
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data) data=data, o_data=old_data)
return SQL.strip('\n'), data['name'] if 'name' in data else \ return SQL.strip('\n'), data['name'] if 'name' in data else \
old_data['name'] old_data['name']
else: else:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=data) data=data)
return SQL.strip('\n'), data['name'] return SQL.strip('\n'), data['name']
@ -906,7 +907,7 @@ AND relkind != 'c'))"""
""" """
res = dict() res = dict()
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'node.sql']), scid=scid) self._NODE_SQL]), scid=scid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)

View File

@ -47,8 +47,8 @@ class DomainConstraintModule(CollectionNodeModule):
- Load the module script for the Domain Constraint, when any of the - Load the module script for the Domain Constraint, when any of the
Domain node is initialized. Domain node is initialized.
""" """
NODE_TYPE = 'domain_constraints' _NODE_TYPE = 'domain_constraints'
COLLECTION_LABEL = gettext("Domain Constraints") _COLLECTION_LABEL = gettext("Domain Constraints")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(DomainConstraintModule, self).__init__(*args, **kwargs) super(DomainConstraintModule, self).__init__(*args, **kwargs)
@ -74,7 +74,7 @@ class DomainConstraintModule(CollectionNodeModule):
Load the module script for the Domain Constraint, when any of the Load the module script for the Domain Constraint, when any of the
Domain node is initialized. Domain node is initialized.
""" """
return domains.DomainModule.NODE_TYPE return domains.DomainModule.node_type
@property @property
def csssnippets(self): def csssnippets(self):
@ -272,7 +272,7 @@ class DomainConstraintView(PGChildNodeView):
doid: Domain Id doid: Domain Id
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
doid=doid) doid=doid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -297,7 +297,7 @@ class DomainConstraintView(PGChildNodeView):
""" """
res = [] res = []
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
doid=doid) doid=doid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -338,7 +338,7 @@ class DomainConstraintView(PGChildNodeView):
coid: Domain Constraint Id coid: Domain Constraint Id
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
coid=coid) coid=coid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -381,7 +381,7 @@ class DomainConstraintView(PGChildNodeView):
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
doid=doid, coid=coid) doid=doid, coid=coid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -430,7 +430,7 @@ class DomainConstraintView(PGChildNodeView):
# Get the recently added constraints oid # Get the recently added constraints oid
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'get_oid.sql']), self._OID_SQL]),
doid=doid, name=data['name']) doid=doid, name=data['name'])
status, coid = self.conn.execute_scalar(SQL) status, coid = self.conn.execute_scalar(SQL)
if not status: if not status:
@ -479,7 +479,7 @@ class DomainConstraintView(PGChildNodeView):
try: try:
for coid in data['ids']: for coid in data['ids']:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
doid=doid, coid=coid) doid=doid, coid=coid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -502,7 +502,7 @@ class DomainConstraintView(PGChildNodeView):
data = res['rows'][0] data = res['rows'][0]
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
data=data) data=data)
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
if not status: if not status:
@ -591,7 +591,7 @@ class DomainConstraintView(PGChildNodeView):
schema, domain = self._get_domain(doid) schema, domain = self._get_domain(doid)
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
doid=doid, coid=coid) doid=doid, coid=coid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -605,7 +605,7 @@ class DomainConstraintView(PGChildNodeView):
data = res['rows'][0] data = res['rows'][0]
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=data, domain=domain, schema=schema) data=data, domain=domain, schema=schema)
sql_header = u"""-- CHECK: {1}.{0} sql_header = u"""-- CHECK: {1}.{0}
@ -662,7 +662,7 @@ class DomainConstraintView(PGChildNodeView):
try: try:
if coid is not None: if coid is not None:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
doid=doid, coid=coid) doid=doid, coid=coid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -677,14 +677,14 @@ class DomainConstraintView(PGChildNodeView):
old_data = res['rows'][0] old_data = res['rows'][0]
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data, conn=self.conn data=data, o_data=old_data, conn=self.conn
) )
else: else:
schema, domain = self._get_domain(doid) schema, domain = self._get_domain(doid)
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=data, domain=domain, schema=schema) data=data, domain=domain, schema=schema)
if 'name' in data: if 'name' in data:
return True, SQL.strip('\n'), data['name'] return True, SQL.strip('\n'), data['name']

View File

@ -56,8 +56,8 @@ class ForeignTableModule(SchemaChildModule):
- Load the module script for Foreign Table, when schema node is - Load the module script for Foreign Table, when schema node is
initialized. initialized.
""" """
NODE_TYPE = 'foreign_table' _NODE_TYPE = 'foreign_table'
COLLECTION_LABEL = gettext("Foreign Tables") _COLLECTION_LABEL = gettext("Foreign Tables")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(ForeignTableModule, self).__init__(*args, **kwargs) super(ForeignTableModule, self).__init__(*args, **kwargs)
@ -84,7 +84,7 @@ class ForeignTableModule(SchemaChildModule):
Load the module script for foreign table, when the Load the module script for foreign table, when the
schema node is initialized. schema node is initialized.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
blueprint = ForeignTableModule(__name__) blueprint = ForeignTableModule(__name__)
@ -363,7 +363,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
did: Database Id did: Database Id
scid: Schema Id scid: Schema Id
""" """
SQL = render_template("/".join([self.template_path, 'node.sql']), SQL = render_template("/".join([self.template_path, self._NODE_SQL]),
scid=scid) scid=scid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -388,7 +388,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
res = [] res = []
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'node.sql']), scid=scid) self._NODE_SQL]), scid=scid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
@ -422,7 +422,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'node.sql']), foid=foid) self._NODE_SQL]), foid=foid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
@ -680,7 +680,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
basensp = self.request['basensp'] if ('basensp' in self.request) \ basensp = self.request['basensp'] if ('basensp' in self.request) \
else None else None
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'get_oid.sql']), self._OID_SQL]),
basensp=basensp, basensp=basensp,
name=self.request['name']) name=self.request['name'])
status, res = self.conn.execute_2darray(SQL) status, res = self.conn.execute_2darray(SQL)
@ -731,7 +731,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
for foid in data['ids']: for foid in data['ids']:
# Fetch Name and Schema Name to delete the foreign table. # Fetch Name and Schema Name to delete the foreign table.
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'delete.sql']), scid=scid, self._DELETE_SQL]), scid=scid,
foid=foid) foid=foid)
status, res = self.conn.execute_2darray(SQL) status, res = self.conn.execute_2darray(SQL)
if not status: if not status:
@ -752,7 +752,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
basensp = res['rows'][0]['basensp'] basensp = res['rows'][0]['basensp']
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
name=name, name=name,
basensp=basensp, basensp=basensp,
cascade=cascade) cascade=cascade)
@ -800,7 +800,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'get_oid.sql']), self._OID_SQL]),
foid=foid) foid=foid)
status, res = self.conn.execute_2darray(SQL) status, res = self.conn.execute_2darray(SQL)
if not status: if not status:
@ -860,7 +860,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
["a", "r", "w", "x"]) ["a", "r", "w", "x"])
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), data=data, is_sql=True) self._CREATE_SQL]),
data=data, is_sql=True)
if not json_resp: if not json_resp:
return SQL.strip('\n') return SQL.strip('\n')
@ -1011,7 +1012,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
data=data, o_data=old_data) data=data, o_data=old_data)
else: else:
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data data=data, o_data=old_data
) )
return SQL, data['name'] if 'name' in data else old_data['name'] return SQL, data['name'] if 'name' in data else old_data['name']
@ -1024,7 +1025,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
["a", "r", "w", "x"]) ["a", "r", "w", "x"])
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), data=data) self._CREATE_SQL]), data=data)
return SQL, data['name'] return SQL, data['name']
@check_precondition @check_precondition
@ -1099,7 +1100,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, foid=foid) scid=scid, foid=foid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -1114,7 +1115,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
if self.manager.version >= 90200: if self.manager.version >= 90200:
# Fetch privileges # Fetch privileges
SQL = render_template("/".join([self.template_path, 'acl.sql']), SQL = render_template("/".join([self.template_path,
self._ACL_SQL]),
foid=foid) foid=foid)
status, aclres = self.conn.execute_dict(SQL) status, aclres = self.conn.execute_dict(SQL)
if not status: if not status:
@ -1433,7 +1435,7 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
""" """
res = dict() res = dict()
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'node.sql']), scid=scid) self._NODE_SQL]), scid=scid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)

View File

@ -51,8 +51,8 @@ class FtsConfigurationModule(SchemaChildModule):
node is initialized. node is initialized.
""" """
NODE_TYPE = 'fts_configuration' _NODE_TYPE = 'fts_configuration'
COLLECTION_LABEL = _('FTS Configurations') _COLLECTION_LABEL = _('FTS Configurations')
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.min_ver = None self.min_ver = None
@ -84,7 +84,7 @@ class FtsConfigurationModule(SchemaChildModule):
Load the module script for fts template, when any of the schema Load the module script for fts template, when any of the schema
node is initialized. node is initialized.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
blueprint = FtsConfigurationModule(__name__) blueprint = FtsConfigurationModule(__name__)
@ -250,7 +250,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid scid=scid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -277,7 +277,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
res = [] res = []
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
scid=scid scid=scid
) )
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
@ -312,7 +312,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
cfgid=cfgid cfgid=cfgid
) )
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
@ -365,7 +365,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
:return: :return:
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid, scid=scid,
cfgid=cfgid cfgid=cfgid
) )
@ -440,7 +440,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
# Fetch schema name from schema oid # Fetch schema name from schema oid
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'schema.sql']), self._SCHEMA_SQL]),
data=data, data=data,
conn=self.conn, conn=self.conn,
) )
@ -455,7 +455,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
new_data['schema'] = schema new_data['schema'] = schema
sql = render_template( sql = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=new_data, data=new_data,
conn=self.conn, conn=self.conn,
) )
@ -466,7 +466,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
# We need cfgid to add object in tree at browser, # We need cfgid to add object in tree at browser,
# Below sql will give the same # Below sql will give the same
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
name=data['name'], name=data['name'],
scid=data['schema'] scid=data['schema']
) )
@ -510,7 +510,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
if cfgid is not None: if cfgid is not None:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
cfgid=cfgid, cfgid=cfgid,
scid=data['schema'] if 'schema' in data else scid scid=data['schema'] if 'schema' in data else scid
) )
@ -583,7 +583,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
# Drop FTS Configuration # Drop FTS Configuration
result = res['rows'][0] result = res['rows'][0]
sql = render_template( sql = render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
name=result['name'], name=result['name'],
schema=result['schema'], schema=result['schema'],
cascade=cascade cascade=cascade
@ -658,7 +658,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
'schema' in new_data 'schema' in new_data
): ):
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=new_data, data=new_data,
conn=self.conn conn=self.conn
) )
@ -689,7 +689,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
# Fetch sql for update # Fetch sql for update
if cfgid is not None: if cfgid is not None:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
cfgid=cfgid, cfgid=cfgid,
scid=scid scid=scid
) )
@ -707,7 +707,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
# If user has changed the schema then fetch new schema directly # If user has changed the schema then fetch new schema directly
# using its oid otherwise fetch old schema name using its oid # using its oid otherwise fetch old schema name using its oid
sql = render_template( sql = render_template(
"/".join([self.template_path, 'schema.sql']), "/".join([self.template_path, self._SCHEMA_SQL]),
data=data) data=data)
status, new_schema = self.conn.execute_scalar(sql) status, new_schema = self.conn.execute_scalar(sql)
@ -720,7 +720,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
# Fetch old schema name using old schema oid # Fetch old schema name using old schema oid
sql = render_template( sql = render_template(
"/".join([self.template_path, 'schema.sql']), "/".join([self.template_path, self._SCHEMA_SQL]),
data=old_data data=old_data
) )
@ -732,7 +732,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
old_data['schema'] = old_schema old_data['schema'] = old_schema
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=new_data, o_data=old_data data=new_data, o_data=old_data
) )
# Fetch sql query for modified data # Fetch sql query for modified data
@ -743,7 +743,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
else: else:
# Fetch schema name from schema oid # Fetch schema name from schema oid
sql = render_template( sql = render_template(
"/".join([self.template_path, 'schema.sql']), "/".join([self.template_path, self._SCHEMA_SQL]),
data=data data=data
) )
@ -936,7 +936,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
data = {'schema': scid} data = {'schema': scid}
# Fetch schema name from schema oid # Fetch schema name from schema oid
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'schema.sql']), self._SCHEMA_SQL]),
data=data, data=data,
conn=self.conn, conn=self.conn,
) )
@ -1007,7 +1007,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = dict() res = dict()
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), scid=scid) self._NODES_SQL]), scid=scid)
status, fts_cfg = self.conn.execute_2darray(SQL) status, fts_cfg = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)

View File

@ -49,8 +49,8 @@ class FtsDictionaryModule(SchemaChildModule):
- Load the module script for FTS Dictionary, when any of the schema - Load the module script for FTS Dictionary, when any of the schema
node is initialized. node is initialized.
""" """
NODE_TYPE = 'fts_dictionary' _NODE_TYPE = 'fts_dictionary'
COLLECTION_LABEL = _('FTS Dictionaries') _COLLECTION_LABEL = _('FTS Dictionaries')
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.min_ver = None self.min_ver = None
@ -82,7 +82,7 @@ class FtsDictionaryModule(SchemaChildModule):
Load the module script for fts template, when any of the schema Load the module script for fts template, when any of the schema
node is initialized. node is initialized.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
blueprint = FtsDictionaryModule(__name__) blueprint = FtsDictionaryModule(__name__)
@ -259,7 +259,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid scid=scid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -290,7 +290,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
res = [] res = []
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
scid=scid scid=scid
) )
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
@ -325,7 +325,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
dcid=dcid dcid=dcid
) )
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
@ -376,7 +376,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
:return: :return:
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid, scid=scid,
dcid=dcid dcid=dcid
) )
@ -439,7 +439,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
) )
# Fetch schema name from schema oid # Fetch schema name from schema oid
sql = render_template( sql = render_template(
"/".join([self.template_path, 'schema.sql']), "/".join([self.template_path, self._SCHEMA_SQL]),
data=data, data=data,
conn=self.conn, conn=self.conn,
) )
@ -453,7 +453,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
new_data = data.copy() new_data = data.copy()
new_data['schema'] = schema new_data['schema'] = schema
sql = render_template( sql = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=new_data, data=new_data,
conn=self.conn, conn=self.conn,
) )
@ -464,7 +464,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
# We need dcid to add object in tree at browser, # We need dcid to add object in tree at browser,
# Below sql will give the same # Below sql will give the same
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
name=data['name'], name=data['name'],
scid=data['schema'] scid=data['schema']
) )
@ -508,7 +508,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
if dcid is not None: if dcid is not None:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
dcid=dcid dcid=dcid
) )
@ -559,7 +559,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
for dcid in data['ids']: for dcid in data['ids']:
# Get name for FTS Dictionary from dcid # Get name for FTS Dictionary from dcid
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
dcid=dcid) dcid=dcid)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -579,7 +579,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
# Drop FTS Dictionary # Drop FTS Dictionary
result = res['rows'][0] result = res['rows'][0]
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
name=result['name'], name=result['name'],
schema=result['schema'], schema=result['schema'],
cascade=cascade cascade=cascade
@ -655,7 +655,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
'schema' in new_data 'schema' in new_data
): ):
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=new_data, data=new_data,
conn=self.conn conn=self.conn
) )
@ -694,7 +694,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
# Fetch sql for update # Fetch sql for update
if dcid is not None: if dcid is not None:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
dcid=dcid, dcid=dcid,
scid=scid scid=scid
) )
@ -711,7 +711,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
# If user has changed the schema then fetch new schema directly # If user has changed the schema then fetch new schema directly
# using its oid otherwise fetch old schema name using its oid # using its oid otherwise fetch old schema name using its oid
sql = render_template( sql = render_template(
"/".join([self.template_path, 'schema.sql']), "/".join([self.template_path, self._SCHEMA_SQL]),
data=data) data=data)
status, new_schema = self.conn.execute_scalar(sql) status, new_schema = self.conn.execute_scalar(sql)
@ -725,7 +725,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
# Fetch old schema name using old schema oid # Fetch old schema name using old schema oid
sql = render_template( sql = render_template(
"/".join([self.template_path, 'schema.sql']), "/".join([self.template_path, self._SCHEMA_SQL]),
data=old_data) data=old_data)
status, old_schema = self.conn.execute_scalar(sql) status, old_schema = self.conn.execute_scalar(sql)
@ -736,7 +736,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
old_data['schema'] = old_schema old_data['schema'] = old_schema
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=new_data, o_data=old_data data=new_data, o_data=old_data
) )
# Fetch sql query for modified data # Fetch sql query for modified data
@ -746,8 +746,8 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
return sql.strip('\n'), old_data['name'] return sql.strip('\n'), old_data['name']
else: else:
# Fetch schema name from schema oid # Fetch schema name from schema oid
sql = render_template("/".join([self.template_path, 'schema.sql']), sql = render_template("/".join([self.template_path,
data=data) self._SCHEMA_SQL]), data=data)
status, schema = self.conn.execute_scalar(sql) status, schema = self.conn.execute_scalar(sql)
if not status: if not status:
@ -805,7 +805,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
json_resp = kwargs.get('json_resp', True) json_resp = kwargs.get('json_resp', True)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid, scid=scid,
dcid=dcid dcid=dcid
) )
@ -837,7 +837,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
# Fetch schema name from schema oid # Fetch schema name from schema oid
sql = render_template("/".join( sql = render_template("/".join(
[self.template_path, 'schema.sql']), data=res['rows'][0]) [self.template_path, self._SCHEMA_SQL]), data=res['rows'][0])
status, schema = self.conn.execute_scalar(sql) status, schema = self.conn.execute_scalar(sql)
@ -850,7 +850,8 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
if diff_schema: if diff_schema:
res['rows'][0]['schema'] = diff_schema res['rows'][0]['schema'] = diff_schema
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=res['rows'][0], data=res['rows'][0],
conn=self.conn, is_displaying=True) conn=self.conn, is_displaying=True)
@ -918,7 +919,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = dict() res = dict()
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), scid=scid) self._NODES_SQL]), scid=scid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)

View File

@ -45,8 +45,8 @@ class FtsParserModule(SchemaChildModule):
- Load the module script for FTS Parser, when any of the schema node is - Load the module script for FTS Parser, when any of the schema node is
initialized. initialized.
""" """
NODE_TYPE = 'fts_parser' _NODE_TYPE = 'fts_parser'
COLLECTION_LABEL = _('FTS Parsers') _COLLECTION_LABEL = _('FTS Parsers')
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(FtsParserModule, self).__init__(*args, **kwargs) super(FtsParserModule, self).__init__(*args, **kwargs)
@ -75,7 +75,7 @@ class FtsParserModule(SchemaChildModule):
Load the module script for fts template, when any of the schema node is Load the module script for fts template, when any of the schema node is
initialized. initialized.
""" """
return DatabaseModule.NODE_TYPE return DatabaseModule.node_type
blueprint = FtsParserModule(__name__) blueprint = FtsParserModule(__name__)
@ -243,7 +243,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
@check_precondition @check_precondition
def list(self, gid, sid, did, scid): def list(self, gid, sid, did, scid):
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid scid=scid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -260,7 +260,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
def nodes(self, gid, sid, did, scid): def nodes(self, gid, sid, did, scid):
res = [] res = []
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
scid=scid scid=scid
) )
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
@ -284,7 +284,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
@check_precondition @check_precondition
def node(self, gid, sid, did, scid, pid): def node(self, gid, sid, did, scid, pid):
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
pid=pid pid=pid
) )
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
@ -334,7 +334,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
:return: :return:
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid, scid=scid,
pid=pid pid=pid
) )
@ -385,7 +385,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
) )
# Fetch schema name from schema oid # Fetch schema name from schema oid
sql = render_template( sql = render_template(
"/".join([self.template_path, 'schema.sql']), "/".join([self.template_path, self._SCHEMA_SQL]),
data=data, data=data,
conn=self.conn, conn=self.conn,
) )
@ -399,7 +399,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
new_data = data.copy() new_data = data.copy()
new_data['schema'] = schema new_data['schema'] = schema
sql = render_template( sql = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=new_data, data=new_data,
conn=self.conn, conn=self.conn,
) )
@ -410,7 +410,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
# we need fts_parser id to to add object in tree at browser, # we need fts_parser id to to add object in tree at browser,
# below sql will give the same # below sql will give the same
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
name=data['name'], name=data['name'],
scid=data['schema'] if 'schema' in data else scid scid=data['schema'] if 'schema' in data else scid
) )
@ -453,7 +453,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
if pid is not None: if pid is not None:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
pid=pid, pid=pid,
scid=data['schema'] if 'schema' in data else scid scid=data['schema'] if 'schema' in data else scid
) )
@ -505,7 +505,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
for pid in data['ids']: for pid in data['ids']:
# Get name for Parser from pid # Get name for Parser from pid
sql = render_template( sql = render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
pid=pid pid=pid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -525,7 +525,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
# Drop fts Parser # Drop fts Parser
result = res['rows'][0] result = res['rows'][0]
sql = render_template( sql = render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
name=result['name'], name=result['name'],
schema=result['schema'], schema=result['schema'],
cascade=cascade cascade=cascade
@ -613,7 +613,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
'schema' in new_data 'schema' in new_data
): ):
sql = render_template( sql = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=new_data, data=new_data,
conn=self.conn conn=self.conn
) )
@ -634,7 +634,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
# Fetch sql for update # Fetch sql for update
if pid is not None: if pid is not None:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
pid=pid, pid=pid,
scid=scid scid=scid
) )
@ -652,7 +652,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
# If user has changed the schema then fetch new schema directly # If user has changed the schema then fetch new schema directly
# using its oid otherwise fetch old schema name with parser oid # using its oid otherwise fetch old schema name with parser oid
sql = render_template( sql = render_template(
"/".join([self.template_path, 'schema.sql']), "/".join([self.template_path, self._SCHEMA_SQL]),
data=data) data=data)
status, new_schema = self.conn.execute_scalar(sql) status, new_schema = self.conn.execute_scalar(sql)
@ -665,7 +665,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
# Fetch old schema name using old schema oid # Fetch old schema name using old schema oid
sql = render_template( sql = render_template(
"/".join([self.template_path, 'schema.sql']), "/".join([self.template_path, self._SCHEMA_SQL]),
data=old_data data=old_data
) )
@ -677,7 +677,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
old_data['schema'] = old_schema old_data['schema'] = old_schema
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=new_data, data=new_data,
o_data=old_data o_data=old_data
) )
@ -688,7 +688,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
else: else:
# Fetch schema name from schema oid # Fetch schema name from schema oid
sql = render_template( sql = render_template(
"/".join([self.template_path, 'schema.sql']), "/".join([self.template_path, self._SCHEMA_SQL]),
data=data data=data
) )
@ -878,7 +878,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
data = {'schema': scid} data = {'schema': scid}
# Fetch schema name from schema oid # Fetch schema name from schema oid
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'schema.sql']), self._SCHEMA_SQL]),
data=data, data=data,
conn=self.conn, conn=self.conn,
) )
@ -949,7 +949,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = dict() res = dict()
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), scid=scid) self._NODES_SQL]), scid=scid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)

View File

@ -49,8 +49,8 @@ class FtsTemplateModule(SchemaChildModule):
- Load the module script for FTS Template, when any of the schema node is - Load the module script for FTS Template, when any of the schema node is
initialized. initialized.
""" """
NODE_TYPE = 'fts_template' _NODE_TYPE = 'fts_template'
COLLECTION_LABEL = gettext('FTS Templates') _COLLECTION_LABEL = gettext('FTS Templates')
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.min_ver = None self.min_ver = None
@ -81,7 +81,7 @@ class FtsTemplateModule(SchemaChildModule):
Load the module script for fts template, when any of the schema node is Load the module script for fts template, when any of the schema node is
initialized. initialized.
""" """
return DatabaseModule.NODE_TYPE return DatabaseModule.node_type
blueprint = FtsTemplateModule(__name__) blueprint = FtsTemplateModule(__name__)
@ -221,7 +221,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
@check_precondition @check_precondition
def list(self, gid, sid, did, scid): def list(self, gid, sid, did, scid):
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid scid=scid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -238,7 +238,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
def nodes(self, gid, sid, did, scid): def nodes(self, gid, sid, did, scid):
res = [] res = []
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
scid=scid scid=scid
) )
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
@ -262,7 +262,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
@check_precondition @check_precondition
def node(self, gid, sid, did, scid, tid): def node(self, gid, sid, did, scid, tid):
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
tid=tid tid=tid
) )
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
@ -312,7 +312,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
:return: :return:
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid, scid=scid,
tid=tid tid=tid
) )
@ -358,7 +358,8 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
).format(arg) ).format(arg)
) )
# Fetch schema name from schema oid # Fetch schema name from schema oid
sql = render_template("/".join([self.template_path, 'schema.sql']), sql = render_template("/".join([self.template_path,
self._SCHEMA_SQL]),
data=data, data=data,
conn=self.conn, conn=self.conn,
) )
@ -371,7 +372,8 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
# to generate proper sql query # to generate proper sql query
new_data = data.copy() new_data = data.copy()
new_data['schema'] = schema new_data['schema'] = schema
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=new_data, data=new_data,
conn=self.conn, conn=self.conn,
) )
@ -382,7 +384,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
# we need fts_template id to to add object in tree at browser, # we need fts_template id to to add object in tree at browser,
# below sql will give the same # below sql will give the same
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
name=data['name'], name=data['name'],
scid=data['schema'] if 'schema' in data else scid scid=data['schema'] if 'schema' in data else scid
) )
@ -424,7 +426,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
tid=tid tid=tid
) )
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
@ -469,7 +471,8 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
for tid in data['ids']: for tid in data['ids']:
# Get name for template from tid # Get name for template from tid
sql = render_template("/".join([self.template_path, 'delete.sql']), sql = render_template("/".join([self.template_path,
self._DELETE_SQL]),
tid=tid) tid=tid)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -488,7 +491,8 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
# Drop fts template # Drop fts template
result = res['rows'][0] result = res['rows'][0]
sql = render_template("/".join([self.template_path, 'delete.sql']), sql = render_template("/".join([self.template_path,
self._DELETE_SQL]),
name=result['name'], name=result['name'],
schema=result['schema'], schema=result['schema'],
cascade=cascade cascade=cascade
@ -556,7 +560,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
# Fetch old schema name using old schema oid # Fetch old schema name using old schema oid
sql = render_template( sql = render_template(
"/".join([self.template_path, 'schema.sql']), "/".join([self.template_path, self._SCHEMA_SQL]),
data=old_data) data=old_data)
status, old_schema = self.conn.execute_scalar(sql) status, old_schema = self.conn.execute_scalar(sql)
@ -584,7 +588,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
'schema' in new_data 'schema' in new_data
): ):
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=new_data, data=new_data,
conn=self.conn conn=self.conn
) )
@ -606,7 +610,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
# Fetch sql for update # Fetch sql for update
if tid is not None: if tid is not None:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
tid=tid, tid=tid,
scid=scid scid=scid
) )
@ -627,7 +631,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
# using its oid otherwise fetch old schema name using # using its oid otherwise fetch old schema name using
# fts template oid # fts template oid
sql = render_template( sql = render_template(
"/".join([self.template_path, 'schema.sql']), "/".join([self.template_path, self._SCHEMA_SQL]),
data=data) data=data)
status, new_schema = self.conn.execute_scalar(sql) status, new_schema = self.conn.execute_scalar(sql)
@ -644,7 +648,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=errmsg) return internal_server_error(errormsg=errmsg)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=new_data, o_data=old_data data=new_data, o_data=old_data
) )
@ -654,7 +658,8 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
return sql.strip('\n'), old_data['name'] return sql.strip('\n'), old_data['name']
else: else:
# Fetch schema name from schema oid # Fetch schema name from schema oid
sql = render_template("/".join([self.template_path, 'schema.sql']), sql = render_template("/".join([self.template_path,
self._SCHEMA_SQL]),
data=data) data=data)
status, schema = self.conn.execute_scalar(sql) status, schema = self.conn.execute_scalar(sql)
@ -762,7 +767,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
data = {'schema': scid} data = {'schema': scid}
# Fetch schema name from schema oid # Fetch schema name from schema oid
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'schema.sql']), self._SCHEMA_SQL]),
data=data, data=data,
conn=self.conn, conn=self.conn,
) )
@ -829,7 +834,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = dict() res = dict()
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), scid=scid) self._NODES_SQL]), scid=scid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)

View File

@ -61,8 +61,8 @@ class FunctionModule(SchemaChildModule):
- Returns a snippet of css. - Returns a snippet of css.
""" """
NODE_TYPE = 'function' _NODE_TYPE = 'function'
COLLECTION_LABEL = gettext("Functions") _COLLECTION_LABEL = gettext("Functions")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -99,7 +99,7 @@ class FunctionModule(SchemaChildModule):
Load the module script for Functions, when the Load the module script for Functions, when the
schema node is initialized. schema node is initialized.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
@property @property
def csssnippets(self): def csssnippets(self):
@ -383,7 +383,8 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
scid: Schema Id scid: Schema Id
""" """
sql = render_template("/".join([self.sql_template_path, 'node.sql']), sql = render_template("/".join([self.sql_template_path,
self._NODE_SQL]),
scid=scid) scid=scid)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -408,7 +409,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
res = [] res = []
sql = render_template( sql = render_template(
"/".join([self.sql_template_path, 'node.sql']), "/".join([self.sql_template_path, self._NODE_SQL]),
scid=scid, scid=scid,
fnid=fnid fnid=fnid
) )
@ -852,7 +853,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
sql = render_template( sql = render_template(
"/".join( "/".join(
[self.sql_template_path, 'get_oid.sql'] [self.sql_template_path, self._OID_SQL]
), ),
nspname=self.request['pronamespace'], nspname=self.request['pronamespace'],
name=self.request['name'] name=self.request['name']
@ -903,7 +904,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
for fnid in data['ids']: for fnid in data['ids']:
# Fetch Name and Schema Name to delete the Function. # Fetch Name and Schema Name to delete the Function.
sql = render_template("/".join([self.sql_template_path, sql = render_template("/".join([self.sql_template_path,
'delete.sql']), scid=scid, self._DELETE_SQL]), scid=scid,
fnid=fnid) fnid=fnid)
status, res = self.conn.execute_2darray(sql) status, res = self.conn.execute_2darray(sql)
if not status: if not status:
@ -920,7 +921,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
) )
sql = render_template("/".join([self.sql_template_path, sql = render_template("/".join([self.sql_template_path,
'delete.sql']), self._DELETE_SQL]),
name=res['rows'][0]['name'], name=res['rows'][0]['name'],
func_args=res['rows'][0]['func_args'], func_args=res['rows'][0]['func_args'],
nspname=res['rows'][0]['nspname'], nspname=res['rows'][0]['nspname'],
@ -1148,7 +1149,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
# func_def is procedure signature with default arguments # func_def is procedure signature with default arguments
# query_for - To distinguish the type of call # query_for - To distinguish the type of call
func_def = render_template("/".join([self.sql_template_path, func_def = render_template("/".join([self.sql_template_path,
'create.sql']), self._CREATE_SQL]),
data=resp_data, query_type="create", data=resp_data, query_type="create",
func_def=name_with_default_args, func_def=name_with_default_args,
query_for="sql_panel") query_for="sql_panel")
@ -1185,7 +1186,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
# func_def is function signature with default arguments # func_def is function signature with default arguments
# query_for - To distinguish the type of call # query_for - To distinguish the type of call
func_def = render_template("/".join([self.sql_template_path, func_def = render_template("/".join([self.sql_template_path,
'create.sql']), self._CREATE_SQL]),
data=resp_data, query_type="create", data=resp_data, query_type="create",
func_def=name_with_default_args, func_def=name_with_default_args,
query_for="sql_panel") query_for="sql_panel")
@ -1427,7 +1428,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
self.reformat_prosrc_code(data) self.reformat_prosrc_code(data)
sql = render_template( sql = render_template(
"/".join([self.sql_template_path, 'update.sql']), "/".join([self.sql_template_path, self._UPDATE_SQL]),
data=data, o_data=old_data data=data, o_data=old_data
) )
return sql return sql
@ -1496,7 +1497,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
# Create mode # Create mode
sql = render_template("/".join([self.sql_template_path, sql = render_template("/".join([self.sql_template_path,
'create.sql']), self._CREATE_SQL]),
data=data, is_sql=is_sql) data=data, is_sql=is_sql)
return True, sql.strip('\n') return True, sql.strip('\n')
@ -1514,7 +1515,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
""" """
sql = render_template("/".join([self.sql_template_path, sql = render_template("/".join([self.sql_template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, fnid=fnid) scid=scid, fnid=fnid)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -1533,7 +1534,8 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
resp_data.update(frmtd_proargs) resp_data.update(frmtd_proargs)
# Fetch privileges # Fetch privileges
sql = render_template("/".join([self.sql_template_path, 'acl.sql']), sql = render_template("/".join([self.sql_template_path,
self._ACL_SQL]),
fnid=fnid) fnid=fnid)
status, proaclres = self.conn.execute_dict(sql) status, proaclres = self.conn.execute_dict(sql)
if not status: if not status:
@ -1896,7 +1898,7 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
if not oid: if not oid:
sql = render_template("/".join([self.sql_template_path, sql = render_template("/".join([self.sql_template_path,
'node.sql']), scid=scid) self._NODE_SQL]), scid=scid)
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
@ -1939,8 +1941,8 @@ class ProcedureModule(SchemaChildModule):
""" """
NODE_TYPE = 'procedure' _NODE_TYPE = 'procedure'
COLLECTION_LABEL = gettext("Procedures") _COLLECTION_LABEL = gettext("Procedures")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -1978,7 +1980,7 @@ class ProcedureModule(SchemaChildModule):
Load the module script for Procedures, when the Load the module script for Procedures, when the
database node is initialized. database node is initialized.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
procedure_blueprint = ProcedureModule(__name__) procedure_blueprint = ProcedureModule(__name__)
@ -2040,8 +2042,8 @@ class TriggerFunctionModule(SchemaChildModule):
""" """
NODE_TYPE = 'trigger_function' _NODE_TYPE = 'trigger_function'
COLLECTION_LABEL = gettext("Trigger Functions") _COLLECTION_LABEL = gettext("Trigger Functions")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -2077,7 +2079,7 @@ class TriggerFunctionModule(SchemaChildModule):
Load the module script for Trigger function, when the Load the module script for Trigger function, when the
schema node is initialized. schema node is initialized.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
trigger_function_blueprint = TriggerFunctionModule(__name__) trigger_function_blueprint = TriggerFunctionModule(__name__)

View File

@ -53,8 +53,8 @@ class PackageModule(SchemaChildModule):
""" """
NODE_TYPE = 'package' _NODE_TYPE = 'package'
COLLECTION_LABEL = _("Packages") _COLLECTION_LABEL = _("Packages")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(PackageModule, self).__init__(*args, **kwargs) super(PackageModule, self).__init__(*args, **kwargs)
@ -74,7 +74,7 @@ class PackageModule(SchemaChildModule):
Load the module script for schema, when any of the database node is Load the module script for schema, when any of the database node is
initialized. initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
blueprint = PackageModule(__name__) blueprint = PackageModule(__name__)
@ -172,7 +172,8 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
Returns: Returns:
""" """
SQL = render_template("/".join([self.template_path, 'properties.sql']), SQL = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
scid=scid) scid=scid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -201,7 +202,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = [] res = []
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
scid=scid, scid=scid,
pkgid=pkgid pkgid=pkgid
) )
@ -256,7 +257,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = [] res = []
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid, pkgid=pkgid scid=scid, pkgid=pkgid
) )
status, rset = self.conn.execute_dict(sql) status, rset = self.conn.execute_dict(sql)
@ -314,7 +315,8 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
:param pkgid: :param pkgid:
:return: :return:
""" """
sql = render_template("/".join([self.template_path, 'properties.sql']), sql = render_template("/".join([self.template_path,
self._PROPERTIES_SQL]),
scid=scid, pkgid=pkgid) scid=scid, pkgid=pkgid)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -331,7 +333,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
res['rows'][0]['pkgbodysrc'] = self.get_inner( res['rows'][0]['pkgbodysrc'] = self.get_inner(
res['rows'][0]['pkgbodysrc']) res['rows'][0]['pkgbodysrc'])
sql = render_template("/".join([self.template_path, 'acl.sql']), sql = render_template("/".join([self.template_path, self._ACL_SQL]),
scid=scid, scid=scid,
pkgid=pkgid) pkgid=pkgid)
status, rset1 = self.conn.execute_dict(sql) status, rset1 = self.conn.execute_dict(sql)
@ -390,7 +392,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
# We need oid of newly created package. # We need oid of newly created package.
sql = render_template( sql = render_template(
"/".join([ "/".join([
self.template_path, 'get_oid.sql' self.template_path, self._OID_SQL
]), ]),
name=data['name'], scid=scid name=data['name'], scid=scid
) )
@ -444,7 +446,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
try: try:
for pkgid in data['ids']: for pkgid in data['ids']:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid, scid=scid,
pkgid=pkgid) pkgid=pkgid)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -465,7 +467,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
res['rows'][0]['schema'] = self.schema res['rows'][0]['schema'] = self.schema
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
data=res['rows'][0], data=res['rows'][0],
cascade=cascade) cascade=cascade)
@ -596,7 +598,8 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
if 'pkgacl' in data: if 'pkgacl' in data:
data['pkgacl'] = parse_priv_to_db(data['pkgacl'], self.acl) data['pkgacl'] = parse_priv_to_db(data['pkgacl'], self.acl)
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=data, conn=self.conn) data=data, conn=self.conn)
return sql, data['name'] return sql, data['name']
@ -620,7 +623,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
u'name' u'name'
] ]
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), scid=scid, "/".join([self.template_path, self._PROPERTIES_SQL]), scid=scid,
pkgid=pkgid) pkgid=pkgid)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
@ -635,7 +638,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
res['rows'][0]['pkgbodysrc'] = self.get_inner( res['rows'][0]['pkgbodysrc'] = self.get_inner(
res['rows'][0]['pkgbodysrc']) res['rows'][0]['pkgbodysrc'])
sql = render_template("/".join([self.template_path, 'acl.sql']), sql = render_template("/".join([self.template_path, self._ACL_SQL]),
scid=scid, scid=scid,
pkgid=pkgid) pkgid=pkgid)
@ -660,7 +663,8 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
if arg not in data: if arg not in data:
data[arg] = old_data[arg] data[arg] = old_data[arg]
sql = render_template("/".join([self.template_path, 'update.sql']), sql = render_template("/".join([self.template_path,
self._UPDATE_SQL]),
data=data, o_data=old_data, conn=self.conn, data=data, o_data=old_data, conn=self.conn,
is_schema_diff=diff_schema) is_schema_diff=diff_schema)
return sql, data['name'] if 'name' in data else old_data['name'] return sql, data['name'] if 'name' in data else old_data['name']
@ -684,8 +688,8 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
try: try:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), scid=scid, "/".join([self.template_path, self._PROPERTIES_SQL]),
pkgid=pkgid) scid=scid, pkgid=pkgid)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
@ -699,7 +703,8 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
res['rows'][0]['pkgbodysrc'] = self.get_inner( res['rows'][0]['pkgbodysrc'] = self.get_inner(
res['rows'][0]['pkgbodysrc']) res['rows'][0]['pkgbodysrc'])
sql = render_template("/".join([self.template_path, 'acl.sql']), sql = render_template("/".join([self.template_path,
self._ACL_SQL]),
scid=scid, scid=scid,
pkgid=pkgid) pkgid=pkgid)
status, rset1 = self.conn.execute_dict(sql) status, rset1 = self.conn.execute_dict(sql)
@ -728,7 +733,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
self.schema, result['name']) self.schema, result['name'])
sql_header += render_template( sql_header += render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
data=result) data=result)
sql_header += "\n\n" sql_header += "\n\n"
@ -812,7 +817,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
return res return res
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'nodes.sql']), scid=scid) self._NODES_SQL]), scid=scid)
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)

View File

@ -55,8 +55,8 @@ class EdbFuncModule(CollectionNodeModule):
- Returns a snippet of css. - Returns a snippet of css.
""" """
NODE_TYPE = 'edbfunc' _NODE_TYPE = 'edbfunc'
COLLECTION_LABEL = gettext("Functions") _COLLECTION_LABEL = gettext("Functions")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -83,7 +83,7 @@ class EdbFuncModule(CollectionNodeModule):
Load the module script for Functions, when the Load the module script for Functions, when the
package node is initialized. package node is initialized.
""" """
return packages.PackageModule.NODE_TYPE return packages.PackageModule.node_type
@property @property
def node_inode(self): def node_inode(self):
@ -246,7 +246,8 @@ class EdbFuncView(PGChildNodeView, DataTypeReader):
scid: Schema Id scid: Schema Id
""" """
SQL = render_template("/".join([self.sql_template_path, 'node.sql']), SQL = render_template("/".join([self.sql_template_path,
self._NODE_SQL]),
pkgid=pkgid) pkgid=pkgid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -271,7 +272,7 @@ class EdbFuncView(PGChildNodeView, DataTypeReader):
res = [] res = []
SQL = render_template( SQL = render_template(
"/".join([self.sql_template_path, 'node.sql']), "/".join([self.sql_template_path, self._NODE_SQL]),
pkgid=pkgid, pkgid=pkgid,
fnid=edbfnid fnid=edbfnid
) )
@ -326,7 +327,7 @@ class EdbFuncView(PGChildNodeView, DataTypeReader):
edbfnid: Function Id edbfnid: Function Id
""" """
SQL = render_template("/".join([self.sql_template_path, SQL = render_template("/".join([self.sql_template_path,
'properties.sql']), self._PROPERTIES_SQL]),
pkgid=pkgid, edbfnid=edbfnid) pkgid=pkgid, edbfnid=edbfnid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -618,8 +619,8 @@ class EdbProcModule(CollectionNodeModule):
""" """
NODE_TYPE = 'edbproc' _NODE_TYPE = 'edbproc'
COLLECTION_LABEL = gettext("Procedures") _COLLECTION_LABEL = gettext("Procedures")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -655,7 +656,7 @@ class EdbProcModule(CollectionNodeModule):
Load the module script for Procedures, when the Load the module script for Procedures, when the
database node is initialized. database node is initialized.
""" """
return packages.PackageModule.NODE_TYPE return packages.PackageModule.node_type
def register_preferences(self): def register_preferences(self):
""" """

View File

@ -52,8 +52,8 @@ class EdbVarModule(CollectionNodeModule):
- Returns a snippet of css. - Returns a snippet of css.
""" """
NODE_TYPE = 'edbvar' _NODE_TYPE = 'edbvar'
COLLECTION_LABEL = gettext("Variables") _COLLECTION_LABEL = gettext("Variables")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -80,7 +80,7 @@ class EdbVarModule(CollectionNodeModule):
Load the module script for Functions, when the Load the module script for Functions, when the
package node is initialized. package node is initialized.
""" """
return packages.PackageModule.NODE_TYPE return packages.PackageModule.node_type
@property @property
def node_inode(self): def node_inode(self):
@ -209,7 +209,8 @@ class EdbVarView(PGChildNodeView, DataTypeReader):
pkgid: Package Id pkgid: Package Id
""" """
SQL = render_template("/".join([self.sql_template_path, 'node.sql']), SQL = render_template("/".join([self.sql_template_path,
self._NODE_SQL]),
pkgid=pkgid) pkgid=pkgid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -235,7 +236,7 @@ class EdbVarView(PGChildNodeView, DataTypeReader):
res = [] res = []
SQL = render_template( SQL = render_template(
"/".join([self.sql_template_path, 'node.sql']), "/".join([self.sql_template_path, self._NODE_SQL]),
pkgid=pkgid pkgid=pkgid
) )
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -272,7 +273,7 @@ class EdbVarView(PGChildNodeView, DataTypeReader):
""" """
resp_data = {} resp_data = {}
SQL = render_template("/".join([self.sql_template_path, SQL = render_template("/".join([self.sql_template_path,
'properties.sql']), self._PROPERTIES_SQL]),
pkgid=pkgid, varid=varid) pkgid=pkgid, varid=varid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -304,7 +305,7 @@ class EdbVarView(PGChildNodeView, DataTypeReader):
varid: variable Id varid: variable Id
""" """
SQL = render_template( SQL = render_template(
"/".join([self.sql_template_path, 'properties.sql']), "/".join([self.sql_template_path, self._PROPERTIES_SQL]),
varid=varid, varid=varid,
pkgid=pkgid) pkgid=pkgid)

View File

@ -52,8 +52,8 @@ class SequenceModule(SchemaChildModule):
""" """
NODE_TYPE = 'sequence' _NODE_TYPE = 'sequence'
COLLECTION_LABEL = _("Sequences") _COLLECTION_LABEL = _("Sequences")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(SequenceModule, self).__init__(*args, **kwargs) super(SequenceModule, self).__init__(*args, **kwargs)
@ -73,7 +73,7 @@ class SequenceModule(SchemaChildModule):
Load the module script for database, when any of the database node is Load the module script for database, when any of the database node is
initialized. initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def node_inode(self): def node_inode(self):
@ -167,7 +167,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid scid=scid
) )
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -198,7 +198,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = [] res = []
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
scid=scid, scid=scid,
seid=seid seid=seid
) )
@ -295,7 +295,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid, seid=seid scid=scid, seid=seid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -329,7 +329,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
self._add_securities_to_row(row) self._add_securities_to_row(row)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'acl.sql']), "/".join([self.template_path, self._ACL_SQL]),
scid=scid, seid=seid scid=scid, seid=seid
) )
status, dataclres = self.conn.execute_dict(sql) status, dataclres = self.conn.execute_dict(sql)
@ -394,7 +394,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
try: try:
# The SQL below will execute CREATE DDL only # The SQL below will execute CREATE DDL only
sql = render_template( sql = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
except Exception as e: except Exception as e:
@ -410,7 +410,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
# The SQL below will execute rest DMLs because we cannot execute # The SQL below will execute rest DMLs because we cannot execute
# CREATE with any other # CREATE with any other
sql = render_template( sql = render_template(
"/".join([self.template_path, 'grant.sql']), "/".join([self.template_path, self._GRANT_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
sql = sql.strip('\n').strip(' ') sql = sql.strip('\n').strip(' ')
@ -421,7 +421,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
# We need oid of newly created sequence. # We need oid of newly created sequence.
sql = render_template( sql = render_template(
"/".join([self.template_path, 'get_oid.sql']), "/".join([self.template_path, self._OID_SQL]),
name=data['name'], name=data['name'],
schema=data['schema'] schema=data['schema']
) )
@ -474,7 +474,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
try: try:
for seid in data['ids']: for seid in data['ids']:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid, seid=seid scid=scid, seid=seid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -493,7 +493,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
) )
sql = render_template( sql = render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
data=res['rows'][0], cascade=cascade data=res['rows'][0], cascade=cascade
) )
@ -542,7 +542,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
seid=seid seid=seid
) )
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
@ -631,7 +631,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
if seid is not None: if seid is not None:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid, seid=seid scid=scid, seid=seid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -652,7 +652,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
if arg not in data: if arg not in data:
data[arg] = old_data[arg] data[arg] = old_data[arg]
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data, conn=self.conn data=data, o_data=old_data, conn=self.conn
) )
return sql, data['name'] if 'name' in data else old_data['name'] return sql, data['name'] if 'name' in data else old_data['name']
@ -662,11 +662,11 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
data['relacl'] = parse_priv_to_db(data['relacl'], self.acl) data['relacl'] = parse_priv_to_db(data['relacl'], self.acl)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
sql += render_template( sql += render_template(
"/".join([self.template_path, 'grant.sql']), "/".join([self.template_path, self._GRANT_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
return sql, data['name'] return sql, data['name']
@ -706,7 +706,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
json_resp = kwargs.get('json_resp', True) json_resp = kwargs.get('json_resp', True)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid, seid=seid scid=scid, seid=seid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -780,7 +780,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
data['securities'] = seclabels data['securities'] = seclabels
# We need to parse & convert ACL coming from database to json format # We need to parse & convert ACL coming from database to json format
sql = render_template("/".join([self.template_path, 'acl.sql']), sql = render_template("/".join([self.template_path, self._ACL_SQL]),
scid=scid, seid=seid) scid=scid, seid=seid)
status, acl = self.conn.execute_dict(sql) status, acl = self.conn.execute_dict(sql)
if not status: if not status:
@ -928,7 +928,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = dict() res = dict()
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'nodes.sql']), scid=scid) self._NODES_SQL]), scid=scid)
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)

View File

@ -49,8 +49,8 @@ class SynonymModule(SchemaChildModule):
initialized. initialized.
""" """
NODE_TYPE = 'synonym' _NODE_TYPE = 'synonym'
COLLECTION_LABEL = gettext("Synonyms") _COLLECTION_LABEL = gettext("Synonyms")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -78,7 +78,7 @@ class SynonymModule(SchemaChildModule):
Load the module script for database, when any of the database node is Load the module script for database, when any of the database node is
initialized. initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def node_inode(self): def node_inode(self):
@ -233,7 +233,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), scid=scid) self._PROPERTIES_SQL]), scid=scid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -262,7 +262,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
res = [] res = []
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), scid=scid) self._NODES_SQL]), scid=scid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
@ -295,7 +295,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
syid=syid, scid=scid syid=syid, scid=scid
) )
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
@ -409,7 +409,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
try: try:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, syid=syid) scid=scid, syid=syid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -458,7 +458,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
try: try:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=data, conn=self.conn, comment=False) data=data, conn=self.conn, comment=False)
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
@ -512,7 +512,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
try: try:
for syid in data['ids']: for syid in data['ids']:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, syid=syid) scid=scid, syid=syid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -528,7 +528,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
) )
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
data=data, data=data,
conn=self.conn) conn=self.conn)
if only_sql: if only_sql:
@ -622,7 +622,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
name = None name = None
if syid is not None: if syid is not None:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, syid=syid) scid=scid, syid=syid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -641,7 +641,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
data['synobjname'] = old_data['synobjname'] data['synobjname'] = old_data['synobjname']
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data, conn=self.conn data=data, o_data=old_data, conn=self.conn
) )
else: else:
@ -655,7 +655,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
name = data['name'] name = data['name']
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), comment=False, self._CREATE_SQL]), comment=False,
data=data, conn=self.conn) data=data, conn=self.conn)
return SQL.strip('\n'), name return SQL.strip('\n'), name
@ -677,7 +677,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
json_resp = kwargs.get('json_resp', True) json_resp = kwargs.get('json_resp', True)
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, syid=syid) scid=scid, syid=syid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -694,7 +694,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
data['schema'] = diff_schema data['schema'] = diff_schema
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=data, conn=self.conn, comment=True) data=data, conn=self.conn, comment=True)
if not json_resp: if not json_resp:
return SQL return SQL
@ -757,7 +757,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
return res return res
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), scid=scid) self._PROPERTIES_SQL]), scid=scid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)

View File

@ -53,8 +53,8 @@ class TableModule(SchemaChildModule):
- Load the module script for schema, when any of the server node is - Load the module script for schema, when any of the server node is
initialized. initialized.
""" """
NODE_TYPE = 'table' _NODE_TYPE = 'table'
COLLECTION_LABEL = gettext("Tables") _COLLECTION_LABEL = gettext("Tables")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -80,7 +80,7 @@ class TableModule(SchemaChildModule):
Load the module script for database, when any of the database node is Load the module script for database, when any of the database node is
initialized. initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def csssnippets(self): def csssnippets(self):
@ -304,7 +304,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
JSON of available table nodes JSON of available table nodes
""" """
SQL = render_template( SQL = render_template(
"/".join([self.table_template_path, 'properties.sql']), "/".join([self.table_template_path, self._PROPERTIES_SQL]),
did=did, scid=scid, did=did, scid=scid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
) )
@ -357,7 +357,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
""" """
res = [] res = []
SQL = render_template( SQL = render_template(
"/".join([self.table_template_path, 'nodes.sql']), "/".join([self.table_template_path, self._NODES_SQL]),
scid=scid, tid=tid scid=scid, tid=tid
) )
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -401,7 +401,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
""" """
res = [] res = []
SQL = render_template( SQL = render_template(
"/".join([self.table_template_path, 'nodes.sql']), "/".join([self.table_template_path, self._NODES_SQL]),
scid=scid scid=scid
) )
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -626,7 +626,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
:return: :return:
""" """
sql = render_template( sql = render_template(
"/".join([self.table_template_path, 'properties.sql']), "/".join([self.table_template_path, self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
) )
@ -993,7 +993,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
BaseTableView.update_vacuum_settings(self, 'vacuum_toast', data) BaseTableView.update_vacuum_settings(self, 'vacuum_toast', data)
sql = render_template( sql = render_template(
"/".join([self.table_template_path, 'create.sql']), "/".join([self.table_template_path, self._CREATE_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
@ -1024,7 +1024,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
# we need oid to to add object in tree at browser # we need oid to to add object in tree at browser
sql = render_template( sql = render_template(
"/".join([self.table_template_path, 'get_oid.sql']), "/".join([self.table_template_path, self._OID_SQL]),
scid=new_scid, data=data scid=new_scid, data=data
) )
@ -1103,7 +1103,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
try: try:
for tid in data['ids']: for tid in data['ids']:
SQL = render_template( SQL = render_template(
"/".join([self.table_template_path, 'properties.sql']), "/".join([self.table_template_path, self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
) )
@ -1151,7 +1151,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
try: try:
SQL = render_template( SQL = render_template(
"/".join([self.table_template_path, 'properties.sql']), "/".join([self.table_template_path, self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
) )
@ -1190,7 +1190,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
try: try:
SQL = render_template( SQL = render_template(
"/".join([self.table_template_path, 'properties.sql']), "/".join([self.table_template_path, self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
) )
@ -1258,7 +1258,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
main_sql = [] main_sql = []
SQL = render_template( SQL = render_template(
"/".join([self.table_template_path, 'properties.sql']), "/".join([self.table_template_path, self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
) )
@ -1404,7 +1404,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
SELECT Script sql for the object SELECT Script sql for the object
""" """
SQL = render_template( SQL = render_template(
"/".join([self.table_template_path, 'properties.sql']), "/".join([self.table_template_path, self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
) )
@ -1452,7 +1452,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
INSERT Script sql for the object INSERT Script sql for the object
""" """
SQL = render_template( SQL = render_template(
"/".join([self.table_template_path, 'properties.sql']), "/".join([self.table_template_path, self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
) )
@ -1503,7 +1503,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
UPDATE Script sql for the object UPDATE Script sql for the object
""" """
SQL = render_template( SQL = render_template(
"/".join([self.table_template_path, 'properties.sql']), "/".join([self.table_template_path, self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
) )
@ -1556,7 +1556,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
DELETE Script sql for the object DELETE Script sql for the object
""" """
SQL = render_template( SQL = render_template(
"/".join([self.table_template_path, 'properties.sql']), "/".join([self.table_template_path, self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
) )
@ -1636,7 +1636,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
@BaseTableView.check_precondition @BaseTableView.check_precondition
def get_drop_sql(self, sid, did, scid, tid): def get_drop_sql(self, sid, did, scid, tid):
SQL = render_template("/".join( SQL = render_template("/".join(
[self.table_template_path, 'properties.sql']), [self.table_template_path, self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
) )
@ -1686,7 +1686,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
else: else:
res = dict() res = dict()
sql = render_template("/".join([self.table_template_path, sql = render_template("/".join([self.table_template_path,
'nodes.sql']), scid=scid) self._NODES_SQL]), scid=scid)
status, tables = self.conn.execute_2darray(sql) status, tables = self.conn.execute_2darray(sql)
if not status: if not status:
current_app.logger.error(tables) current_app.logger.error(tables)

View File

@ -52,8 +52,8 @@ class ColumnsModule(CollectionNodeModule):
initialized. initialized.
""" """
NODE_TYPE = 'column' _NODE_TYPE = 'column'
COLLECTION_LABEL = gettext("Columns") _COLLECTION_LABEL = gettext("Columns")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -82,7 +82,7 @@ class ColumnsModule(CollectionNodeModule):
Load the module script for server, when any of the server-group node is Load the module script for server, when any of the server-group node is
initialized. initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def node_inode(self): def node_inode(self):
@ -239,7 +239,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
""" """
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
tid=tid, show_sys_objects=self.blueprint.show_system_objects tid=tid, show_sys_objects=self.blueprint.show_system_objects
) )
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -269,7 +269,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
""" """
res = [] res = []
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
tid=tid, tid=tid,
clid=clid, clid=clid,
show_sys_objects=self.blueprint.show_system_objects show_sys_objects=self.blueprint.show_system_objects
@ -328,7 +328,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
""" """
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
tid=tid, clid=clid, tid=tid, clid=clid,
show_sys_objects=self.blueprint.show_system_objects show_sys_objects=self.blueprint.show_system_objects
) )
@ -406,7 +406,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
data = column_utils.convert_length_precision_to_string(data) data = column_utils.convert_length_precision_to_string(data)
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=data, conn=self.conn) data=data, conn=self.conn)
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
if not status: if not status:
@ -455,7 +455,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
try: try:
for clid in data['ids']: for clid in data['ids']:
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
tid=tid, clid=clid, tid=tid, clid=clid,
show_sys_objects=self.blueprint.show_system_objects show_sys_objects=self.blueprint.show_system_objects
) )
@ -481,7 +481,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
data['table'] = self.table data['table'] = self.table
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
data=data, conn=self.conn) data=data, conn=self.conn)
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
if not status: if not status:
@ -591,7 +591,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
if clid is not None: if clid is not None:
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
tid=tid, clid=clid, tid=tid, clid=clid,
show_sys_objects=self.blueprint.show_system_objects show_sys_objects=self.blueprint.show_system_objects
) )
@ -647,7 +647,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
) )
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data, conn=self.conn data=data, o_data=old_data, conn=self.conn
) )
else: else:
@ -667,7 +667,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
self.acl) self.acl)
# If the request for new object which do not have did # If the request for new object which do not have did
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, conn=self.conn, is_sql=is_sql data=data, conn=self.conn, is_sql=is_sql
) )
return SQL, data['name'] if 'name' in data else old_data['name'] return SQL, data['name'] if 'name' in data else old_data['name']
@ -687,7 +687,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
""" """
try: try:
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
tid=tid, clid=clid, tid=tid, clid=clid,
show_sys_objects=self.blueprint.show_system_objects show_sys_objects=self.blueprint.show_system_objects
) )
@ -728,7 +728,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
) )
sql_header += render_template( sql_header += render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
SQL = sql_header + '\n\n' + SQL SQL = sql_header + '\n\n' + SQL
@ -839,7 +839,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
""" """
# Fetch column name # Fetch column name
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
tid=tid, clid=clid, tid=tid, clid=clid,
show_sys_objects=self.blueprint.show_system_objects show_sys_objects=self.blueprint.show_system_objects
) )

View File

@ -55,8 +55,8 @@ class CompoundTriggerModule(CollectionNodeModule):
node is initialized. node is initialized.
""" """
NODE_TYPE = 'compound_trigger' _NODE_TYPE = 'compound_trigger'
COLLECTION_LABEL = gettext("Compound Triggers") _COLLECTION_LABEL = gettext("Compound Triggers")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -118,7 +118,7 @@ class CompoundTriggerModule(CollectionNodeModule):
Load the module script for server, when any of the server-group node is Load the module script for server, when any of the server-group node is
initialized. initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def node_inode(self): def node_inode(self):
@ -313,7 +313,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), tid=tid) self._PROPERTIES_SQL]), tid=tid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -343,7 +343,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = [] res = []
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), self._NODES_SQL]),
tid=tid, tid=tid,
trid=trid) trid=trid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -388,7 +388,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = [] res = []
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), tid=tid) self._NODES_SQL]), tid=tid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
@ -445,7 +445,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
def _fetch_properties(self, tid, trid): def _fetch_properties(self, tid, trid):
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
tid=tid, trid=trid, tid=tid, trid=trid,
datlastsysoid=self.datlastsysoid) datlastsysoid=self.datlastsysoid)
@ -515,7 +515,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
try: try:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=data, conn=self.conn) data=data, conn=self.conn)
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
if not status: if not status:
@ -523,7 +523,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
# we need oid to to add object in tree at browser # we need oid to to add object in tree at browser
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'get_oid.sql']), self._OID_SQL]),
tid=tid, data=data) tid=tid, data=data)
status, trid = self.conn.execute_scalar(SQL) status, trid = self.conn.execute_scalar(SQL)
if not status: if not status:
@ -576,7 +576,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
# current request so that we create template for # current request so that we create template for
# dropping compound trigger # dropping compound trigger
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
tid=tid, trid=trid, tid=tid, trid=trid,
datlastsysoid=self.datlastsysoid) datlastsysoid=self.datlastsysoid)
@ -599,7 +599,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
data = dict(res['rows'][0]) data = dict(res['rows'][0])
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
data=data, data=data,
conn=self.conn, conn=self.conn,
cascade=cascade cascade=cascade
@ -653,7 +653,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
# update the compound trigger then new OID is getting generated # update the compound trigger then new OID is getting generated
# so we need to return new OID of compound trigger. # so we need to return new OID of compound trigger.
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'get_oid.sql']), "/".join([self.template_path, self._OID_SQL]),
tid=tid, data=data tid=tid, data=data
) )
status, new_trid = self.conn.execute_scalar(SQL) status, new_trid = self.conn.execute_scalar(SQL)
@ -661,7 +661,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=new_trid) return internal_server_error(errormsg=new_trid)
# Fetch updated properties # Fetch updated properties
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
tid=tid, trid=new_trid, tid=tid, trid=new_trid,
datlastsysoid=self.datlastsysoid) datlastsysoid=self.datlastsysoid)
@ -783,7 +783,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
try: try:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
tid=tid, trid=trid, tid=tid, trid=trid,
datlastsysoid=self.datlastsysoid) datlastsysoid=self.datlastsysoid)
@ -906,7 +906,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
trid=oid, only_sql=True) trid=oid, only_sql=True)
else: else:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
tid=tid, trid=oid, tid=tid, trid=oid,
datlastsysoid=self.datlastsysoid) datlastsysoid=self.datlastsysoid)
@ -971,7 +971,7 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
res = data res = data
else: else:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), tid=tid) self._NODES_SQL]), tid=tid)
status, triggers = self.conn.execute_2darray(SQL) status, triggers = self.conn.execute_2darray(SQL)
if not status: if not status:
current_app.logger.error(triggers) current_app.logger.error(triggers)

View File

@ -47,8 +47,8 @@ class ConstraintsModule(CollectionNodeModule):
node is initialized. node is initialized.
""" """
NODE_TYPE = 'constraints' _NODE_TYPE = 'constraints'
COLLECTION_LABEL = gettext("Constraints") _COLLECTION_LABEL = gettext("Constraints")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.min_ver = None self.min_ver = None
@ -73,7 +73,7 @@ class ConstraintsModule(CollectionNodeModule):
Load the module script for constraints, when any of the table node is Load the module script for constraints, when any of the table node is
initialized. initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):

View File

@ -48,8 +48,8 @@ class CheckConstraintModule(CollectionNodeModule):
- Load the module script for the Check Constraint, when any of the - Load the module script for the Check Constraint, when any of the
Check node is initialized. Check node is initialized.
""" """
NODE_TYPE = 'check_constraint' _NODE_TYPE = 'check_constraint'
COLLECTION_LABEL = _("Check Constraints") _COLLECTION_LABEL = _("Check Constraints")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(CheckConstraintModule, self).__init__(*args, **kwargs) super(CheckConstraintModule, self).__init__(*args, **kwargs)
@ -75,7 +75,7 @@ class CheckConstraintModule(CollectionNodeModule):
Load the module script for the Check Constraint, when any of the Load the module script for the Check Constraint, when any of the
Check node is initialized. Check node is initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -272,8 +272,8 @@ class CheckConstraintView(PGChildNodeView):
self.schema = schema self.schema = schema
self.table = table self.table = table
SQL = render_template("/".join([self.template_path, 'properties.sql']), SQL = render_template("/".join([self.template_path,
tid=tid) self._PROPERTIES_SQL]), tid=tid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
for row in res['rows']: for row in res['rows']:
@ -295,7 +295,7 @@ class CheckConstraintView(PGChildNodeView):
cid: Check constraint Id. cid: Check constraint Id.
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), self._NODES_SQL]),
tid=tid, tid=tid,
cid=cid) cid=cid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -337,7 +337,7 @@ class CheckConstraintView(PGChildNodeView):
""" """
res = [] res = []
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), self._NODES_SQL]),
tid=tid) tid=tid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -391,7 +391,7 @@ class CheckConstraintView(PGChildNodeView):
res = [] res = []
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), self._NODES_SQL]),
tid=tid) tid=tid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -506,7 +506,7 @@ class CheckConstraintView(PGChildNodeView):
# The below SQL will execute CREATE DDL only # The below SQL will execute CREATE DDL only
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data data=data
) )
@ -533,7 +533,7 @@ class CheckConstraintView(PGChildNodeView):
else: else:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'get_oid.sql']), "/".join([self.template_path, self._OID_SQL]),
tid=tid, tid=tid,
name=data['name'] name=data['name']
) )
@ -591,7 +591,7 @@ class CheckConstraintView(PGChildNodeView):
try: try:
for cid in data['ids']: for cid in data['ids']:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
tid=tid, cid=cid) tid=tid, cid=cid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -613,7 +613,7 @@ class CheckConstraintView(PGChildNodeView):
data = res['rows'][0] data = res['rows'][0]
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
data=data) data=data)
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
if not status: if not status:
@ -698,7 +698,7 @@ class CheckConstraintView(PGChildNodeView):
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
tid=tid, cid=cid) tid=tid, cid=cid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -713,13 +713,13 @@ class CheckConstraintView(PGChildNodeView):
data['table'] = self.table data['table'] = self.table
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=data) data=data)
sql_header = u"-- Constraint: {0}\n\n-- ".format(data['name']) sql_header = u"-- Constraint: {0}\n\n-- ".format(data['name'])
sql_header += render_template( sql_header += render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
data=data) data=data)
sql_header += "\n" sql_header += "\n"

View File

@ -50,8 +50,8 @@ class ExclusionConstraintModule(ConstraintTypeModule):
initialized. initialized.
""" """
NODE_TYPE = 'exclusion_constraint' _NODE_TYPE = 'exclusion_constraint'
COLLECTION_LABEL = _("Exclusion Constraints") _COLLECTION_LABEL = _("Exclusion Constraints")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -92,7 +92,7 @@ class ExclusionConstraintModule(ConstraintTypeModule):
Returns: node type of the server module. Returns: node type of the server module.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -336,7 +336,7 @@ class ExclusionConstraintView(PGChildNodeView):
self.table = table self.table = table
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
did=did, did=did,
tid=tid) tid=tid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -365,7 +365,7 @@ class ExclusionConstraintView(PGChildNodeView):
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), self._NODES_SQL]),
tid=tid, tid=tid,
exid=exid) exid=exid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -403,7 +403,7 @@ class ExclusionConstraintView(PGChildNodeView):
""" """
res = [] res = []
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), self._NODES_SQL]),
tid=tid) tid=tid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -448,7 +448,7 @@ class ExclusionConstraintView(PGChildNodeView):
res = [] res = []
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), self._NODES_SQL]),
tid=tid) tid=tid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -520,7 +520,7 @@ class ExclusionConstraintView(PGChildNodeView):
# The below SQL will execute CREATE DDL only # The below SQL will execute CREATE DDL only
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
@ -545,7 +545,7 @@ class ExclusionConstraintView(PGChildNodeView):
else: else:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'get_oid.sql']), "/".join([self.template_path, self._OID_SQL]),
name=data['name'] name=data['name']
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -605,7 +605,7 @@ class ExclusionConstraintView(PGChildNodeView):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'get_oid.sql']), "/".join([self.template_path, self._OID_SQL]),
name=data['name'] name=data['name']
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -680,7 +680,7 @@ class ExclusionConstraintView(PGChildNodeView):
data['table'] = self.table data['table'] = self.table
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
data=data, data=data,
cascade=cascade) cascade=cascade)
status, res = self.conn.execute_scalar(sql) status, res = self.conn.execute_scalar(sql)
@ -761,7 +761,7 @@ class ExclusionConstraintView(PGChildNodeView):
""" """
try: try:
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
did=did, tid=tid, conn=self.conn, cid=exid) did=did, tid=tid, conn=self.conn, cid=exid)
status, result = self.conn.execute_dict(SQL) status, result = self.conn.execute_dict(SQL)
if not status: if not status:
@ -818,12 +818,12 @@ class ExclusionConstraintView(PGChildNodeView):
data['amname'] = 'btree' data['amname'] = 'btree'
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), data=data) "/".join([self.template_path, self._CREATE_SQL]), data=data)
sql_header = u"-- Constraint: {0}\n\n-- ".format(data['name']) sql_header = u"-- Constraint: {0}\n\n-- ".format(data['name'])
sql_header += render_template( sql_header += render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
data=data) data=data)
sql_header += "\n" sql_header += "\n"
@ -863,7 +863,7 @@ class ExclusionConstraintView(PGChildNodeView):
if is_pgstattuple: if is_pgstattuple:
# Fetch index details only if extended stats available # Fetch index details only if extended stats available
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
did=did, tid=tid, conn=self.conn, cid=exid) did=did, tid=tid, conn=self.conn, cid=exid)
status, result = self.conn.execute_dict(SQL) status, result = self.conn.execute_dict(SQL)
if not status: if not status:

View File

@ -52,8 +52,8 @@ class ForeignKeyConstraintModule(ConstraintTypeModule):
initialized. initialized.
""" """
NODE_TYPE = 'foreign_key' _NODE_TYPE = 'foreign_key'
COLLECTION_LABEL = gettext("Foreign Keys") _COLLECTION_LABEL = gettext("Foreign Keys")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -94,7 +94,7 @@ class ForeignKeyConstraintModule(ConstraintTypeModule):
Returns: node type of the server module. Returns: node type of the server module.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -346,7 +346,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
self.table = table self.table = table
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
tid=tid) tid=tid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -373,7 +373,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
""" """
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'nodes.sql']), tid=tid "/".join([self.template_path, self._NODES_SQL]), tid=tid
) )
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -418,7 +418,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), self._NODES_SQL]),
tid=tid) tid=tid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
res = [] res = []
@ -458,7 +458,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
res = [] res = []
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), self._NODES_SQL]),
tid=tid) tid=tid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -543,7 +543,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
# The below SQL will execute CREATE DDL only # The below SQL will execute CREATE DDL only
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
@ -568,7 +568,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
else: else:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'get_oid.sql']), "/".join([self.template_path, self._OID_SQL]),
name=data['name'] name=data['name']
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -647,7 +647,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'get_oid.sql']), "/".join([self.template_path, self._OID_SQL]),
tid=tid, tid=tid,
name=data['name'] name=data['name']
) )
@ -727,7 +727,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
data['table'] = self.table data['table'] = self.table
sql = render_template( sql = render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
data=data, cascade=cascade) data=data, cascade=cascade)
status, res = self.conn.execute_scalar(sql) status, res = self.conn.execute_scalar(sql)
if not status: if not status:
@ -806,7 +806,7 @@ class ForeignKeyConstraintView(PGChildNodeView):
""" """
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
tid=tid, conn=self.conn, cid=fkid) tid=tid, conn=self.conn, cid=fkid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -844,12 +844,12 @@ class ForeignKeyConstraintView(PGChildNodeView):
data['remote_table'] = table data['remote_table'] = table
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), data=data) "/".join([self.template_path, self._CREATE_SQL]), data=data)
sql_header = u"-- Constraint: {0}\n\n-- ".format(data['name']) sql_header = u"-- Constraint: {0}\n\n-- ".format(data['name'])
sql_header += render_template( sql_header += render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
data=data) data=data)
sql_header += "\n" sql_header += "\n"

View File

@ -50,8 +50,8 @@ class IndexConstraintModule(ConstraintTypeModule):
initialized. initialized.
""" """
NODE_TYPE = 'index_constraint' _NODE_TYPE = 'index_constraint'
COLLECTION_LABEL = _('Index constraint') _COLLECTION_LABEL = _('Index constraint')
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -92,7 +92,7 @@ class IndexConstraintModule(ConstraintTypeModule):
Returns: node type of the server module. Returns: node type of the server module.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -111,8 +111,8 @@ class PrimaryKeyConstraintModule(IndexConstraintModule):
IndexConstraintModule. IndexConstraintModule.
""" """
NODE_TYPE = 'primary_key' _NODE_TYPE = 'primary_key'
COLLECTION_LABEL = _("Primary Key") _COLLECTION_LABEL = _("Primary Key")
primary_key_blueprint = PrimaryKeyConstraintModule(__name__) primary_key_blueprint = PrimaryKeyConstraintModule(__name__)
@ -126,8 +126,8 @@ class UniqueConstraintModule(IndexConstraintModule):
IndexConstraintModule. IndexConstraintModule.
""" """
NODE_TYPE = 'unique_constraint' _NODE_TYPE = 'unique_constraint'
COLLECTION_LABEL = _("Unique Constraint") _COLLECTION_LABEL = _("Unique Constraint")
unique_constraint_blueprint = UniqueConstraintModule(__name__) unique_constraint_blueprint = UniqueConstraintModule(__name__)
@ -355,8 +355,8 @@ class IndexConstraintView(PGChildNodeView):
self.schema = schema self.schema = schema
self.table = table self.table = table
SQL = render_template("/".join([self.template_path, 'properties.sql']), SQL = render_template("/".join([self.template_path,
did=did, self._PROPERTIES_SQL]), did=did,
tid=tid, tid=tid,
constraint_type=self.constraint_type) constraint_type=self.constraint_type)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -382,7 +382,7 @@ class IndexConstraintView(PGChildNodeView):
Returns: Returns:
""" """
SQL = render_template("/".join([self.template_path, 'nodes.sql']), SQL = render_template("/".join([self.template_path, self._NODES_SQL]),
cid=cid, cid=cid,
tid=tid, tid=tid,
constraint_type=self.constraint_type) constraint_type=self.constraint_type)
@ -425,7 +425,7 @@ class IndexConstraintView(PGChildNodeView):
Returns: Returns:
""" """
SQL = render_template("/".join([self.template_path, 'nodes.sql']), SQL = render_template("/".join([self.template_path, self._NODES_SQL]),
tid=tid, tid=tid,
constraint_type=self.constraint_type) constraint_type=self.constraint_type)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -475,7 +475,7 @@ class IndexConstraintView(PGChildNodeView):
self.table = table self.table = table
res = [] res = []
SQL = render_template("/".join([self.template_path, 'nodes.sql']), SQL = render_template("/".join([self.template_path, self._NODES_SQL]),
tid=tid, tid=tid,
constraint_type=self.constraint_type) constraint_type=self.constraint_type)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -566,7 +566,7 @@ class IndexConstraintView(PGChildNodeView):
# The below SQL will execute CREATE DDL only # The below SQL will execute CREATE DDL only
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, conn=self.conn, data=data, conn=self.conn,
constraint_name=self.constraint_name constraint_name=self.constraint_name
) )
@ -594,7 +594,7 @@ class IndexConstraintView(PGChildNodeView):
else: else:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'get_oid.sql']), "/".join([self.template_path, self._OID_SQL]),
tid=tid, tid=tid,
constraint_type=self.constraint_type, constraint_type=self.constraint_type,
name=data['name'] name=data['name']
@ -656,7 +656,7 @@ class IndexConstraintView(PGChildNodeView):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'get_oid.sql']), "/".join([self.template_path, self._OID_SQL]),
tid=tid, tid=tid,
constraint_type=self.constraint_type, constraint_type=self.constraint_type,
name=data['name'] name=data['name']
@ -733,7 +733,7 @@ class IndexConstraintView(PGChildNodeView):
data['table'] = self.table data['table'] = self.table
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
data=data, data=data,
cascade=cascade) cascade=cascade)
status, res = self.conn.execute_scalar(sql) status, res = self.conn.execute_scalar(sql)
@ -820,7 +820,7 @@ class IndexConstraintView(PGChildNodeView):
""" """
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
did=did, did=did,
tid=tid, tid=tid,
conn=self.conn, conn=self.conn,
@ -867,14 +867,14 @@ class IndexConstraintView(PGChildNodeView):
data['include'] = [col['colname'] for col in res['rows']] data['include'] = [col['colname'] for col in res['rows']]
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, data=data,
constraint_name=self.constraint_name) constraint_name=self.constraint_name)
sql_header = u"-- Constraint: {0}\n\n-- ".format(data['name']) sql_header = u"-- Constraint: {0}\n\n-- ".format(data['name'])
sql_header += render_template( sql_header += render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
data=data) data=data)
sql_header += "\n" sql_header += "\n"
@ -911,7 +911,7 @@ class IndexConstraintView(PGChildNodeView):
if is_pgstattuple: if is_pgstattuple:
# Fetch index details only if extended stats available # Fetch index details only if extended stats available
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
did=did, did=did,
tid=tid, tid=tid,
cid=cid, cid=cid,

View File

@ -53,8 +53,8 @@ class IndexesModule(CollectionNodeModule):
initialized. initialized.
""" """
NODE_TYPE = 'index' _NODE_TYPE = 'index'
COLLECTION_LABEL = gettext("Indexes") _COLLECTION_LABEL = gettext("Indexes")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -113,7 +113,7 @@ class IndexesModule(CollectionNodeModule):
Load the module script for server, when any of the server-group node is Load the module script for server, when any of the server-group node is
initialized. initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def node_inode(self): def node_inode(self):
@ -388,7 +388,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'nodes.sql']), tid=tid "/".join([self.template_path, self._NODES_SQL]), tid=tid
) )
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -417,7 +417,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
JSON of available schema child nodes JSON of available schema child nodes
""" """
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
tid=tid, idx=idx tid=tid, idx=idx
) )
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -457,7 +457,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = [] res = []
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'nodes.sql']), tid=tid "/".join([self.template_path, self._NODES_SQL]), tid=tid
) )
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
@ -512,7 +512,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
:return: :return:
""" """
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
did=did, tid=tid, idx=idx, datlastsysoid=self.datlastsysoid did=did, tid=tid, idx=idx, datlastsysoid=self.datlastsysoid
) )
@ -608,7 +608,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
# Start transaction. # Start transaction.
self.conn.execute_scalar("BEGIN;") self.conn.execute_scalar("BEGIN;")
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, conn=self.conn, mode='create' data=data, conn=self.conn, mode='create'
) )
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
@ -633,7 +633,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
# we need oid to to add object in tree at browser # we need oid to to add object in tree at browser
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'get_oid.sql']), "/".join([self.template_path, self._OID_SQL]),
tid=tid, data=data tid=tid, data=data
) )
status, idx = self.conn.execute_scalar(SQL) status, idx = self.conn.execute_scalar(SQL)
@ -692,7 +692,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
# We will first fetch the index name for current request # We will first fetch the index name for current request
# so that we create template for dropping index # so that we create template for dropping index
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
did=did, tid=tid, idx=idx, datlastsysoid=self.datlastsysoid did=did, tid=tid, idx=idx, datlastsysoid=self.datlastsysoid
) )
@ -713,7 +713,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
data = dict(res['rows'][0]) data = dict(res['rows'][0])
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
data=data, conn=self.conn, cascade=cascade data=data, conn=self.conn, cascade=cascade
) )
@ -962,7 +962,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
if is_pgstattuple: if is_pgstattuple:
# Fetch index details only if extended stats available # Fetch index details only if extended stats available
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
did=did, tid=tid, idx=idx, did=did, tid=tid, idx=idx,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
) )
@ -1021,7 +1021,7 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
if not oid: if not oid:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), tid=tid) self._NODES_SQL]), tid=tid)
status, indexes = self.conn.execute_2darray(SQL) status, indexes = self.conn.execute_2darray(SQL)
if not status: if not status:
current_app.logger.error(indexes) current_app.logger.error(indexes)

View File

@ -72,8 +72,8 @@ class PartitionsModule(CollectionNodeModule):
initialized. initialized.
""" """
NODE_TYPE = 'partition' _NODE_TYPE = 'partition'
COLLECTION_LABEL = gettext("Partitions") _COLLECTION_LABEL = gettext("Partitions")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -101,7 +101,7 @@ class PartitionsModule(CollectionNodeModule):
Load the module script for server, when any of the server-group node is Load the module script for server, when any of the server-group node is
initialized. initialized.
""" """
return schema.SchemaModule.NODE_TYPE return schema.SchemaModule.node_type
@property @property
def node_inode(self): def node_inode(self):
@ -139,10 +139,10 @@ class PartitionsModule(CollectionNodeModule):
# Exclude 'partition' module for now to avoid cyclic import issue. # Exclude 'partition' module for now to avoid cyclic import issue.
modules_to_skip = ['partition', 'column'] modules_to_skip = ['partition', 'column']
for parent in self.parentmodules: for parent in self.parentmodules:
if parent.NODE_TYPE == 'table': if parent.node_type == 'table':
self.submodules += [ self.submodules += [
submodule for submodule in parent.submodules submodule for submodule in parent.submodules
if submodule.NODE_TYPE not in modules_to_skip if submodule.node_type not in modules_to_skip
] ]
@property @property
@ -267,7 +267,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
JSON of available table nodes JSON of available table nodes
""" """
SQL = render_template("/".join([self.partition_template_path, SQL = render_template("/".join([self.partition_template_path,
'properties.sql']), self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid) datlastsysoid=self.datlastsysoid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -297,7 +297,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
JSON of available table nodes JSON of available table nodes
""" """
SQL = render_template( SQL = render_template(
"/".join([self.partition_template_path, 'nodes.sql']), "/".join([self.partition_template_path, self._NODES_SQL]),
scid=scid, tid=tid, ptid=ptid scid=scid, tid=tid, ptid=ptid
) )
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -376,7 +376,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
""" """
try: try:
SQL = render_template("/".join([self.partition_template_path, SQL = render_template("/".join([self.partition_template_path,
'properties.sql']), self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
ptid=ptid, datlastsysoid=self.datlastsysoid) ptid=ptid, datlastsysoid=self.datlastsysoid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -412,7 +412,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
if ptid: if ptid:
SQL = render_template("/".join([self.partition_template_path, SQL = render_template("/".join([self.partition_template_path,
'properties.sql']), self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
ptid=ptid, datlastsysoid=self.datlastsysoid) ptid=ptid, datlastsysoid=self.datlastsysoid)
status, result = self.conn.execute_dict(SQL) status, result = self.conn.execute_dict(SQL)
@ -425,7 +425,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
else: else:
SQL = render_template( SQL = render_template(
"/".join([self.partition_template_path, 'nodes.sql']), "/".join([self.partition_template_path, self._NODES_SQL]),
scid=scid, tid=tid scid=scid, tid=tid
) )
status, partitions = self.conn.execute_2darray(SQL) status, partitions = self.conn.execute_2darray(SQL)
@ -435,7 +435,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
for row in partitions['rows']: for row in partitions['rows']:
SQL = render_template("/".join([self.partition_template_path, SQL = render_template("/".join([self.partition_template_path,
'properties.sql']), self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
ptid=row['oid'], ptid=row['oid'],
datlastsysoid=self.datlastsysoid) datlastsysoid=self.datlastsysoid)
@ -708,7 +708,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
try: try:
SQL = render_template("/".join([self.partition_template_path, SQL = render_template("/".join([self.partition_template_path,
'properties.sql']), self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, did=did, scid=scid, tid=tid,
ptid=ptid, datlastsysoid=self.datlastsysoid) ptid=ptid, datlastsysoid=self.datlastsysoid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -745,7 +745,8 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
try: try:
for ptid in data['ids']: for ptid in data['ids']:
SQL = render_template( SQL = render_template(
"/".join([self.partition_template_path, 'properties.sql']), "/".join([self.partition_template_path,
self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, ptid=ptid, did=did, scid=scid, tid=tid, ptid=ptid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
) )
@ -799,7 +800,7 @@ class PartitionsView(BaseTableView, DataTypeReader, VacuumSettings,
try: try:
SQL = render_template( SQL = render_template(
"/".join([self.partition_template_path, 'properties.sql']), "/".join([self.partition_template_path, self._PROPERTIES_SQL]),
did=did, scid=scid, tid=tid, ptid=ptid, did=did, scid=scid, tid=tid, ptid=ptid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
) )

View File

@ -52,8 +52,8 @@ class RowSecurityModule(CollectionNodeModule):
initialized. initialized.
""" """
NODE_TYPE = 'row_security_policy' _NODE_TYPE = 'row_security_policy'
COLLECTION_LABEL = gettext('RLS Policies') _COLLECTION_LABEL = gettext('RLS Policies')
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(RowSecurityModule, self).__init__(*args, **kwargs) super(RowSecurityModule, self).__init__(*args, **kwargs)
@ -84,7 +84,7 @@ class RowSecurityModule(CollectionNodeModule):
Load the module script for policy, when any of the database node is Load the module script for policy, when any of the database node is
initialized. initialized.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -226,7 +226,7 @@ class RowSecurityView(PGChildNodeView):
# fetch schema name by schema id # fetch schema name by schema id
sql = render_template("/".join( sql = render_template("/".join(
[self.template_path, 'properties.sql']), schema=self.schema, [self.template_path, self._PROPERTIES_SQL]), schema=self.schema,
tid=tid) tid=tid)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -243,7 +243,7 @@ class RowSecurityView(PGChildNodeView):
return single node return single node
""" """
sql = render_template("/".join( sql = render_template("/".join(
[self.template_path, 'nodes.sql']), plid=plid) [self.template_path, self._NODES_SQL]), plid=plid)
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
if not status: if not status:
@ -271,7 +271,7 @@ class RowSecurityView(PGChildNodeView):
""" """
res = [] res = []
sql = render_template("/".join( sql = render_template("/".join(
[self.template_path, 'nodes.sql']), tid=tid) [self.template_path, self._NODES_SQL]), tid=tid)
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
if not status: if not status:
@ -314,7 +314,7 @@ class RowSecurityView(PGChildNodeView):
:return: :return:
""" """
sql = render_template("/".join( sql = render_template("/".join(
[self.template_path, 'properties.sql'] [self.template_path, self._PROPERTIES_SQL]
), plid=plid, scid=scid, datlastsysoid=self.datlastsysoid) ), plid=plid, scid=scid, datlastsysoid=self.datlastsysoid)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -370,7 +370,8 @@ class RowSecurityView(PGChildNodeView):
).format(arg) ).format(arg)
) )
try: try:
sql = render_template("/".join([self.template_path, 'create.sql']), sql = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=data, data=data,
conn=self.conn, conn=self.conn,
) )
@ -493,7 +494,7 @@ class RowSecurityView(PGChildNodeView):
result['schema'] = self.schema result['schema'] = self.schema
result['table'] = self.table result['table'] = self.table
sql = render_template("/".join([self.template_path, sql = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
policy_name=result['name'], policy_name=result['name'],
cascade=cascade, cascade=cascade,
result=result result=result
@ -652,7 +653,7 @@ class RowSecurityView(PGChildNodeView):
if not oid: if not oid:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), tid=tid) self._NODES_SQL]), tid=tid)
status, policies = self.conn.execute_2darray(SQL) status, policies = self.conn.execute_2darray(SQL)
if not status: if not status:
current_app.logger.error(policies) current_app.logger.error(policies)

View File

@ -41,8 +41,8 @@ class RuleModule(CollectionNodeModule):
script_load - tells when to load js file. script_load - tells when to load js file.
csssnppets - add css to page csssnppets - add css to page
""" """
NODE_TYPE = 'rule' _NODE_TYPE = 'rule'
COLLECTION_LABEL = gettext("Rules") _COLLECTION_LABEL = gettext("Rules")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.min_ver = None self.min_ver = None
@ -97,7 +97,7 @@ class RuleModule(CollectionNodeModule):
Load the module script for rule, when any of the database nodes are Load the module script for rule, when any of the database nodes are
initialized. initialized.
""" """
return schemas.SchemaModule.NODE_TYPE return schemas.SchemaModule.node_type
@property @property
def csssnippets(self): def csssnippets(self):
@ -219,7 +219,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
# fetch schema name by schema id # fetch schema name by schema id
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'properties.sql']), tid=tid) [self.template_path, self._PROPERTIES_SQL]), tid=tid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -235,7 +235,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
return single node return single node
""" """
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'nodes.sql']), rid=rid) [self.template_path, self._NODES_SQL]), rid=rid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
@ -263,7 +263,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = [] res = []
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'nodes.sql']), tid=tid) [self.template_path, self._NODES_SQL]), tid=tid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
@ -305,7 +305,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
:return: :return:
""" """
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'properties.sql'] [self.template_path, self._PROPERTIES_SQL]
), rid=rid, datlastsysoid=self.datlastsysoid) ), rid=rid, datlastsysoid=self.datlastsysoid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -341,7 +341,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
) )
try: try:
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'create.sql']), data=data) [self.template_path, self._CREATE_SQL]), data=data)
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
@ -413,7 +413,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
for rid in data['ids']: for rid in data['ids']:
# Get name for rule from did # Get name for rule from did
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'delete.sql']), rid=rid) [self.template_path, self._DELETE_SQL]), rid=rid)
status, res_data = self.conn.execute_dict(SQL) status, res_data = self.conn.execute_dict(SQL)
if not status: if not status:
return internal_server_error(errormsg=res_data) return internal_server_error(errormsg=res_data)
@ -432,7 +432,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
# drop rule # drop rule
rset = res_data['rows'][0] rset = res_data['rows'][0]
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'delete.sql']), [self.template_path, self._DELETE_SQL]),
rulename=rset['rulename'], rulename=rset['rulename'],
relname=rset['relname'], relname=rset['relname'],
nspname=rset['nspname'], nspname=rset['nspname'],
@ -476,7 +476,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
This function will generate sql to render into the sql panel This function will generate sql to render into the sql panel
""" """
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'properties.sql']), rid=rid) [self.template_path, self._PROPERTIES_SQL]), rid=rid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
@ -485,7 +485,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
res_data = parse_rule_definition(res) res_data = parse_rule_definition(res)
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'create.sql']), [self.template_path, self._CREATE_SQL]),
data=res_data, display_comments=True) data=res_data, display_comments=True)
return ajax_response(response=SQL) return ajax_response(response=SQL)
@ -497,7 +497,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
if rid is not None: if rid is not None:
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'properties.sql']), rid=rid) [self.template_path, self._PROPERTIES_SQL]), rid=rid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
@ -509,12 +509,12 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
old_data = res_data old_data = res_data
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data data=data, o_data=old_data
) )
else: else:
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'create.sql']), data=data) [self.template_path, self._CREATE_SQL]), data=data)
return SQL, data['name'] if 'name' in data else old_data['name'] return SQL, data['name'] if 'name' in data else old_data['name']
@check_precondition @check_precondition
@ -541,7 +541,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
rid=oid, only_sql=True) rid=oid, only_sql=True)
else: else:
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'properties.sql']), rid=oid) [self.template_path, self._PROPERTIES_SQL]), rid=oid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
@ -560,7 +560,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
source_schema, diff_schema) source_schema, diff_schema)
old_data = res_data old_data = res_data
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data data=data, o_data=old_data
) )
else: else:
@ -573,7 +573,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
res_data['schema'] = diff_schema res_data['schema'] = diff_schema
SQL = render_template("/".join( SQL = render_template("/".join(
[self.template_path, 'create.sql']), [self.template_path, self._CREATE_SQL]),
data=res_data, display_comments=True) data=res_data, display_comments=True)
return SQL return SQL
@ -639,7 +639,7 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
res = data res = data
else: else:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), self._NODES_SQL]),
tid=tid) tid=tid)
status, rules = self.conn.execute_2darray(SQL) status, rules = self.conn.execute_2darray(SQL)
if not status: if not status:

View File

@ -71,7 +71,7 @@ class SchemaDiffTableCompare(SchemaDiffObjectCompare):
source_dict=source_tables, source_dict=source_tables,
target_dict=target_tables, target_dict=target_tables,
node=self.node_type, node=self.node_type,
node_label=self.blueprint.COLLECTION_LABEL, node_label=self.blueprint.collection_label,
ignore_whitespaces=ignore_whitespaces, ignore_whitespaces=ignore_whitespaces,
ignore_keys=self.keys_to_ignore) ignore_keys=self.keys_to_ignore)
@ -265,11 +265,11 @@ class SchemaDiffTableCompare(SchemaDiffObjectCompare):
# Iterate through all the sub modules of the table # Iterate through all the sub modules of the table
for module in self.blueprint.submodules: for module in self.blueprint.submodules:
if module.NODE_TYPE not in ignore_sub_modules: if module.node_type not in ignore_sub_modules:
module_view = \ module_view = \
SchemaDiffRegistry.get_node_view(module.NODE_TYPE) SchemaDiffRegistry.get_node_view(module.node_type)
if module.NODE_TYPE == 'partition' and \ if module.node_type == 'partition' and \
('is_partitioned' in source and source['is_partitioned'])\ ('is_partitioned' in source and source['is_partitioned'])\
and ('is_partitioned' in target and and ('is_partitioned' in target and
target['is_partitioned']): target['is_partitioned']):
@ -280,9 +280,9 @@ class SchemaDiffTableCompare(SchemaDiffObjectCompare):
) )
diff += '\n' + target_ddl diff += '\n' + target_ddl
elif module.NODE_TYPE != 'partition': elif module.node_type != 'partition':
dict1 = copy.deepcopy(source[module.NODE_TYPE]) dict1 = copy.deepcopy(source[module.node_type])
dict2 = copy.deepcopy(target[module.NODE_TYPE]) dict2 = copy.deepcopy(target[module.node_type])
# Find the duplicate keys in both the dictionaries # Find the duplicate keys in both the dictionaries
dict1_keys = set(dict1.keys()) dict1_keys = set(dict1.keys())

View File

@ -54,8 +54,8 @@ class TriggerModule(CollectionNodeModule):
initialized. initialized.
""" """
NODE_TYPE = 'trigger' _NODE_TYPE = 'trigger'
COLLECTION_LABEL = gettext("Triggers") _COLLECTION_LABEL = gettext("Triggers")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -114,7 +114,7 @@ class TriggerModule(CollectionNodeModule):
Load the module script for server, when any of the server-group node is Load the module script for server, when any of the server-group node is
initialized. initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def node_inode(self): def node_inode(self):
@ -349,7 +349,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), tid=tid) self._PROPERTIES_SQL]), tid=tid)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -379,7 +379,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = [] res = []
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), self._NODES_SQL]),
tid=tid, tid=tid,
trid=trid) trid=trid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -423,7 +423,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
""" """
res = [] res = []
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), tid=tid) self._NODES_SQL]), tid=tid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
@ -477,7 +477,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
:return: :return:
""" """
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
tid=tid, trid=trid, tid=tid, trid=trid,
datlastsysoid=self.datlastsysoid) datlastsysoid=self.datlastsysoid)
@ -549,7 +549,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
try: try:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=data, conn=self.conn) data=data, conn=self.conn)
status, res = self.conn.execute_scalar(SQL) status, res = self.conn.execute_scalar(SQL)
if not status: if not status:
@ -557,7 +557,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
# we need oid to to add object in tree at browser # we need oid to to add object in tree at browser
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'get_oid.sql']), self._OID_SQL]),
tid=tid, data=data) tid=tid, data=data)
status, trid = self.conn.execute_scalar(SQL) status, trid = self.conn.execute_scalar(SQL)
if not status: if not status:
@ -609,7 +609,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
# We will first fetch the trigger name for current request # We will first fetch the trigger name for current request
# so that we create template for dropping trigger # so that we create template for dropping trigger
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
tid=tid, trid=trid, tid=tid, trid=trid,
datlastsysoid=self.datlastsysoid) datlastsysoid=self.datlastsysoid)
@ -631,7 +631,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
data = dict(res['rows'][0]) data = dict(res['rows'][0])
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
data=data, data=data,
conn=self.conn, conn=self.conn,
cascade=cascade cascade=cascade
@ -687,7 +687,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
# update the trigger then new OID is getting generated # update the trigger then new OID is getting generated
# so we need to return new OID of trigger. # so we need to return new OID of trigger.
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'get_oid.sql']), "/".join([self.template_path, self._OID_SQL]),
tid=tid, data=data tid=tid, data=data
) )
status, new_trid = self.conn.execute_scalar(SQL) status, new_trid = self.conn.execute_scalar(SQL)
@ -695,7 +695,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
return internal_server_error(errormsg=new_trid) return internal_server_error(errormsg=new_trid)
# Fetch updated properties # Fetch updated properties
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
tid=tid, trid=new_trid, tid=tid, trid=new_trid,
datlastsysoid=self.datlastsysoid) datlastsysoid=self.datlastsysoid)
@ -859,7 +859,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
try: try:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
tid=tid, trid=trid, tid=tid, trid=trid,
datlastsysoid=self.datlastsysoid) datlastsysoid=self.datlastsysoid)
@ -972,7 +972,7 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
res = data res = data
else: else:
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), tid=tid) self._NODES_SQL]), tid=tid)
status, triggers = self.conn.execute_2darray(SQL) status, triggers = self.conn.execute_2darray(SQL)
if not status: if not status:
current_app.logger.error(triggers) current_app.logger.error(triggers)

View File

@ -170,7 +170,8 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
data['seclabels'] = seclabels data['seclabels'] = seclabels
# We need to parse & convert ACL coming from database to json format # We need to parse & convert ACL coming from database to json format
sql = render_template("/".join([self.table_template_path, 'acl.sql']), sql = render_template("/".join([self.table_template_path,
self._ACL_SQL]),
tid=tid, scid=scid) tid=tid, scid=scid)
status, acl = self.conn.execute_dict(sql) status, acl = self.conn.execute_dict(sql)
if not status: if not status:
@ -460,7 +461,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
data['schema'], data['name']) data['schema'], data['name'])
sql_header += render_template("/".join([self.table_template_path, sql_header += render_template("/".join([self.table_template_path,
'delete.sql']), self._DELETE_SQL]),
data=data, conn=self.conn) data=data, conn=self.conn)
sql_header = sql_header.strip('\n') sql_header = sql_header.strip('\n')
@ -476,11 +477,11 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
# if table is partitions then # if table is partitions then
if 'relispartition' in data and data['relispartition']: if 'relispartition' in data and data['relispartition']:
table_sql = render_template("/".join([self.partition_template_path, table_sql = render_template("/".join([self.partition_template_path,
'create.sql']), self._CREATE_SQL]),
data=data, conn=self.conn) data=data, conn=self.conn)
else: else:
table_sql = render_template("/".join([self.table_template_path, table_sql = render_template("/".join([self.table_template_path,
'create.sql']), self._CREATE_SQL]),
data=data, conn=self.conn, is_sql=True) data=data, conn=self.conn, is_sql=True)
# Add into main sql # Add into main sql
@ -496,7 +497,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
""" """
sql = render_template("/".join([self.index_template_path, sql = render_template("/".join([self.index_template_path,
'nodes.sql']), tid=tid) self._NODES_SQL]), tid=tid)
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
if not status: if not status:
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
@ -527,7 +528,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
sql = \ sql = \
render_template( render_template(
"/".join([self.row_security_policies_template_path, "/".join([self.row_security_policies_template_path,
'nodes.sql']), tid=tid) self._NODES_SQL]), tid=tid)
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
if not status: if not status:
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
@ -553,7 +554,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
######################################## ########################################
""" """
sql = render_template("/".join([self.trigger_template_path, sql = render_template("/".join([self.trigger_template_path,
'nodes.sql']), tid=tid) self._NODES_SQL]), tid=tid)
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
if not status: if not status:
return internal_server_error(errormsg=rset) return internal_server_error(errormsg=rset)
@ -580,7 +581,8 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
if self.manager.server_type == 'ppas' \ if self.manager.server_type == 'ppas' \
and self.manager.version >= 120000: and self.manager.version >= 120000:
sql = render_template("/".join( sql = render_template("/".join(
[self.compound_trigger_template_path, 'nodes.sql']), tid=tid) [self.compound_trigger_template_path, self._NODES_SQL]),
tid=tid)
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
if not status: if not status:
@ -606,7 +608,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
""" """
sql = render_template("/".join( sql = render_template("/".join(
[self.rules_template_path, 'nodes.sql']), tid=tid) [self.rules_template_path, self._NODES_SQL]), tid=tid)
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
if not status: if not status:
@ -615,7 +617,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
for row in rset['rows']: for row in rset['rows']:
rules_sql = '\n' rules_sql = '\n'
sql = render_template("/".join( sql = render_template("/".join(
[self.rules_template_path, 'properties.sql'] [self.rules_template_path, self._PROPERTIES_SQL]
), rid=row['oid'], datlastsysoid=self.datlastsysoid) ), rid=row['oid'], datlastsysoid=self.datlastsysoid)
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -631,7 +633,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
res_data['view'] = table res_data['view'] = table
rules_sql += render_template("/".join( rules_sql += render_template("/".join(
[self.rules_template_path, 'create.sql']), [self.rules_template_path, self._CREATE_SQL]),
data=res_data, display_comments=display_comments) data=res_data, display_comments=display_comments)
# Add into main sql # Add into main sql
@ -720,7 +722,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
copy.deepcopy(self.parse_vacuum_data( copy.deepcopy(self.parse_vacuum_data(
self.conn, row, 'toast')) self.conn, row, 'toast'))
partition_sql += render_template("/".join( partition_sql += render_template("/".join(
[self.partition_template_path, 'create.sql']), [self.partition_template_path, self._CREATE_SQL]),
data=part_data, conn=self.conn) + '\n' data=part_data, conn=self.conn) + '\n'
# Add into main sql # Add into main sql
@ -776,7 +778,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
partition_main_sql = "" partition_main_sql = ""
if is_partitioned: if is_partitioned:
sql = render_template("/".join([self.partition_template_path, sql = render_template("/".join([self.partition_template_path,
'nodes.sql']), self._NODES_SQL]),
scid=scid, tid=tid) scid=scid, tid=tid)
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
if not status: if not status:
@ -966,7 +968,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
# Sql for drop column # Sql for drop column
if 'inheritedfrom' not in c: if 'inheritedfrom' not in c:
column_sql += render_template("/".join( column_sql += render_template("/".join(
[self.column_template_path, 'delete.sql']), [self.column_template_path, self._DELETE_SQL]),
data=c, conn=self.conn).strip('\n') + '\n\n' data=c, conn=self.conn).strip('\n') + '\n\n'
return column_sql return column_sql
@ -980,7 +982,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
properties_sql = render_template( properties_sql = render_template(
"/".join([self.column_template_path, "/".join([self.column_template_path,
'properties.sql']), self._PROPERTIES_SQL]),
tid=tid, tid=tid,
clid=c['attnum'], clid=c['attnum'],
show_sys_objects=self.blueprint.show_system_objects show_sys_objects=self.blueprint.show_system_objects
@ -1008,7 +1010,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
if 'inheritedfrom' not in c and \ if 'inheritedfrom' not in c and \
'inheritedfromtable' not in c: 'inheritedfromtable' not in c:
column_sql += render_template("/".join( column_sql += render_template("/".join(
[self.column_template_path, 'update.sql']), [self.column_template_path, self._UPDATE_SQL]),
data=c, o_data=old_col_data, conn=self.conn data=c, o_data=old_col_data, conn=self.conn
).strip('\n') + '\n\n' ).strip('\n') + '\n\n'
return column_sql return column_sql
@ -1025,7 +1027,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
if 'inheritedfrom' not in c and \ if 'inheritedfrom' not in c and \
'inheritedfromtable' not in c: 'inheritedfromtable' not in c:
column_sql += render_template("/".join( column_sql += render_template("/".join(
[self.column_template_path, 'create.sql']), [self.column_template_path, self._CREATE_SQL]),
data=c, conn=self.conn).strip('\n') + '\n\n' data=c, conn=self.conn).strip('\n') + '\n\n'
return column_sql return column_sql
@ -1179,7 +1181,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
self.update_vacuum_settings('vacuum_toast', old_data, data) self.update_vacuum_settings('vacuum_toast', old_data, data)
sql = render_template( sql = render_template(
"/".join([self.table_template_path, 'update.sql']), "/".join([self.table_template_path, self._UPDATE_SQL]),
o_data=old_data, data=data, conn=self.conn o_data=old_data, data=data, conn=self.conn
) )
# Removes training new lines # Removes training new lines
@ -1248,7 +1250,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
self.update_vacuum_settings('vacuum_toast', data) self.update_vacuum_settings('vacuum_toast', data)
sql = render_template("/".join([self.table_template_path, sql = render_template("/".join([self.table_template_path,
'create.sql']), self._CREATE_SQL]),
data=data, conn=self.conn) data=data, conn=self.conn)
# Append SQL for partitions # Append SQL for partitions
@ -1392,7 +1394,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
tmp_data['name'] = row['partition_name'] tmp_data['name'] = row['partition_name']
sql = render_template( sql = render_template(
"/".join([ "/".join([
self.table_template_path, 'get_oid.sql' self.table_template_path, self._OID_SQL
]), ]),
scid=scid, data=tmp_data scid=scid, data=tmp_data
) )
@ -1454,7 +1456,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
partitions = [] partitions = []
sql = render_template("/".join([self.partition_template_path, sql = render_template("/".join([self.partition_template_path,
'nodes.sql']), self._NODES_SQL]),
scid=scid, tid=tid) scid=scid, tid=tid)
status, rset = self.conn.execute_2darray(sql) status, rset = self.conn.execute_2darray(sql)
if not status: if not status:
@ -1628,7 +1630,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
part_data['name'] = row['temp_partition_name'] part_data['name'] = row['temp_partition_name']
partition_sql = render_template( partition_sql = render_template(
"/".join([self.partition_template_path, 'create.sql']), "/".join([self.partition_template_path, self._CREATE_SQL]),
data=part_data, conn=self.conn data=part_data, conn=self.conn
) )
@ -1681,7 +1683,7 @@ class BaseTableView(PGChildNodeView, BasePartitionTable):
data = res['rows'][0] data = res['rows'][0]
return render_template( return render_template(
"/".join([self.table_template_path, 'delete.sql']), "/".join([self.table_template_path, self._DELETE_SQL]),
data=data, cascade=cascade, data=data, cascade=cascade,
conn=self.conn conn=self.conn
) )

View File

@ -51,8 +51,8 @@ class TypeModule(SchemaChildModule):
initialized. initialized.
""" """
NODE_TYPE = 'type' _NODE_TYPE = 'type'
COLLECTION_LABEL = gettext("Types") _COLLECTION_LABEL = gettext("Types")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -78,7 +78,7 @@ class TypeModule(SchemaChildModule):
Load the module script for database, when any of the database node is Load the module script for database, when any of the database node is
initialized. initialized.
""" """
return database.DatabaseModule.NODE_TYPE return database.DatabaseModule.node_type
@property @property
def node_inode(self): def node_inode(self):
@ -275,7 +275,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
""" """
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
scid=scid, scid=scid,
datlastsysoid=self.datlastsysoid, datlastsysoid=self.datlastsysoid,
show_system_objects=self.blueprint.show_system_objects) show_system_objects=self.blueprint.show_system_objects)
@ -309,7 +309,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
SQL = render_template( SQL = render_template(
"/".join([self.template_path, "/".join([self.template_path,
'nodes.sql']), self._NODES_SQL]),
scid=scid, scid=scid,
tid=tid, tid=tid,
show_system_objects=self.blueprint.show_system_objects) show_system_objects=self.blueprint.show_system_objects)
@ -354,7 +354,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
res = [] res = []
SQL = render_template( SQL = render_template(
"/".join([self.template_path, "/".join([self.template_path,
'nodes.sql']), scid=scid, self._NODES_SQL]), scid=scid,
show_system_objects=self.blueprint.show_system_objects) show_system_objects=self.blueprint.show_system_objects)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:
@ -582,7 +582,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
SQL = render_template( SQL = render_template(
"/".join([self.template_path, "/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, tid=tid, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid, datlastsysoid=self.datlastsysoid,
show_system_objects=self.blueprint.show_system_objects show_system_objects=self.blueprint.show_system_objects
@ -599,7 +599,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
copy_dict = dict(res['rows'][0]) copy_dict = dict(res['rows'][0])
# We need to parse & convert ACL coming from database to json format # We need to parse & convert ACL coming from database to json format
SQL = render_template("/".join([self.template_path, 'acl.sql']), SQL = render_template("/".join([self.template_path, self._ACL_SQL]),
scid=scid, tid=tid) scid=scid, tid=tid)
status, acl = self.conn.execute_dict(SQL) status, acl = self.conn.execute_dict(SQL)
if not status: if not status:
@ -986,7 +986,8 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
each_type['type']) each_type['type'])
each_type['hasSqrBracket'] = self.hasSqrBracket each_type['hasSqrBracket'] = self.hasSqrBracket
SQL = render_template("/".join([self.template_path, 'create.sql']), SQL = render_template("/".join([self.template_path,
self._CREATE_SQL]),
data=data, conn=self.conn) data=data, conn=self.conn)
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
if not status: if not status:
@ -1003,7 +1004,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
# we need oid to to add object in tree at browser # we need oid to to add object in tree at browser
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'get_oid.sql']), self._OID_SQL]),
scid=scid, data=data) scid=scid, data=data)
status, tid = self.conn.execute_scalar(SQL) status, tid = self.conn.execute_scalar(SQL)
if not status: if not status:
@ -1096,7 +1097,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
for tid in data['ids']: for tid in data['ids']:
SQL = render_template( SQL = render_template(
"/".join([self.template_path, "/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, tid=tid, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid, datlastsysoid=self.datlastsysoid,
show_system_objects=self.blueprint.show_system_objects show_system_objects=self.blueprint.show_system_objects
@ -1120,7 +1121,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
data = dict(res['rows'][0]) data = dict(res['rows'][0])
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
data=data, data=data,
cascade=cascade, cascade=cascade,
conn=self.conn) conn=self.conn)
@ -1243,7 +1244,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
SQL = render_template( SQL = render_template(
"/".join([self.template_path, "/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, tid=tid, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid, datlastsysoid=self.datlastsysoid,
show_system_objects=self.blueprint.show_system_objects show_system_objects=self.blueprint.show_system_objects
@ -1259,7 +1260,8 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
# Making copy of output for future use # Making copy of output for future use
old_data = dict(res['rows'][0]) old_data = dict(res['rows'][0])
SQL = render_template("/".join([self.template_path, 'acl.sql']), SQL = render_template("/".join([self.template_path,
self._ACL_SQL]),
scid=scid, tid=tid) scid=scid, tid=tid)
status, acl = self.conn.execute_dict(SQL) status, acl = self.conn.execute_dict(SQL)
if not status: if not status:
@ -1290,7 +1292,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
) )
else: else:
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data, conn=self.conn data=data, o_data=old_data, conn=self.conn
) )
else: else:
@ -1333,7 +1335,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
each_type['hasSqrBracket'] = self.hasSqrBracket each_type['hasSqrBracket'] = self.hasSqrBracket
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'create.sql']), self._CREATE_SQL]),
data=data, conn=self.conn, is_sql=is_sql) data=data, conn=self.conn, is_sql=is_sql)
return SQL, data['name'] if 'name' in data else old_data['name'] return SQL, data['name'] if 'name' in data else old_data['name']
@ -1357,7 +1359,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
SQL = render_template( SQL = render_template(
"/".join([self.template_path, "/".join([self.template_path,
'properties.sql']), self._PROPERTIES_SQL]),
scid=scid, tid=tid, scid=scid, tid=tid,
datlastsysoid=self.datlastsysoid, datlastsysoid=self.datlastsysoid,
show_system_objects=self.blueprint.show_system_objects show_system_objects=self.blueprint.show_system_objects
@ -1375,7 +1377,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
if diff_schema: if diff_schema:
data['schema'] = diff_schema data['schema'] = diff_schema
SQL = render_template("/".join([self.template_path, 'acl.sql']), SQL = render_template("/".join([self.template_path, self._ACL_SQL]),
scid=scid, tid=tid) scid=scid, tid=tid)
status, acl = self.conn.execute_dict(SQL) status, acl = self.conn.execute_dict(SQL)
if not status: if not status:
@ -1413,7 +1415,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
sql_header = u"-- Type: {0}\n\n-- ".format(data['name']) sql_header = u"-- Type: {0}\n\n-- ".format(data['name'])
sql_header += render_template("/".join([self.template_path, sql_header += render_template("/".join([self.template_path,
'delete.sql']), self._DELETE_SQL]),
data=data, conn=self.conn) data=data, conn=self.conn)
SQL = sql_header + '\n\n' + SQL SQL = sql_header + '\n\n' + SQL
@ -1479,7 +1481,7 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
""" """
res = dict() res = dict()
SQL = render_template("/".join([self.template_path, SQL = render_template("/".join([self.template_path,
'nodes.sql']), self._NODES_SQL]),
scid=scid, datlastsysoid=self.datlastsysoid) scid=scid, datlastsysoid=self.datlastsysoid)
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
if not status: if not status:

View File

@ -72,8 +72,8 @@ class ViewModule(SchemaChildModule):
- Load the module script for View, when any of the server node is - Load the module script for View, when any of the server node is
initialized. initialized.
""" """
NODE_TYPE = 'view' _NODE_TYPE = 'view'
COLLECTION_LABEL = gettext("Views") _COLLECTION_LABEL = gettext("Views")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -100,7 +100,7 @@ class ViewModule(SchemaChildModule):
initialized, The reason is views are also listed under catalogs initialized, The reason is views are also listed under catalogs
which are loaded under database node. which are loaded under database node.
""" """
return databases.DatabaseModule.NODE_TYPE return databases.DatabaseModule.node_type
@property @property
def csssnippets(self): def csssnippets(self):
@ -184,8 +184,8 @@ class MViewModule(ViewModule):
A module class for the materialized view node derived from ViewModule. A module class for the materialized view node derived from ViewModule.
""" """
NODE_TYPE = 'mview' _NODE_TYPE = 'mview'
COLLECTION_LABEL = gettext("Materialized Views") _COLLECTION_LABEL = gettext("Materialized Views")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -1397,7 +1397,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
SQL = render_template( SQL = render_template(
"/".join([ "/".join([
self.column_template_path, 'properties.sql' self.column_template_path, self._PROPERTIES_SQL
]), ]),
scid=scid, tid=vid, scid=scid, tid=vid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid
@ -1459,7 +1459,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
SQL = render_template( SQL = render_template(
"/".join([ "/".join([
self.column_template_path, 'properties.sql' self.column_template_path, self._PROPERTIES_SQL
]), ]),
scid=scid, tid=vid, scid=scid, tid=vid,
datlastsysoid=self.datlastsysoid datlastsysoid=self.datlastsysoid

View File

@ -29,8 +29,8 @@ from pgadmin.browser.server_groups.servers.pgagent.utils \
class JobModule(CollectionNodeModule): class JobModule(CollectionNodeModule):
NODE_TYPE = 'pga_job' _NODE_TYPE = 'pga_job'
COLLECTION_LABEL = _("pgAgent Jobs") _COLLECTION_LABEL = _("pgAgent Jobs")
def get_nodes(self, gid, sid): def get_nodes(self, gid, sid):
""" """
@ -45,7 +45,7 @@ class JobModule(CollectionNodeModule):
Load the module script for server, when any of the server-group node is Load the module script for server, when any of the server-group node is
initialized. initialized.
""" """
return servers.ServerModule.NODE_TYPE return servers.ServerModule.node_type
def backend_supported(self, manager, **kwargs): def backend_supported(self, manager, **kwargs):
if hasattr(self, 'show_node') and not self.show_node: if hasattr(self, 'show_node') and not self.show_node:
@ -180,7 +180,7 @@ SELECT EXISTS(
@check_precondition @check_precondition
def nodes(self, gid, sid, jid=None): def nodes(self, gid, sid, jid=None):
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
jid=jid, conn=self.conn jid=jid, conn=self.conn
) )
status, rset = self.conn.execute_dict(SQL) status, rset = self.conn.execute_dict(SQL)
@ -224,7 +224,7 @@ SELECT EXISTS(
@check_precondition @check_precondition
def properties(self, gid, sid, jid=None): def properties(self, gid, sid, jid=None):
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
jid=jid, conn=self.conn jid=jid, conn=self.conn
) )
status, rset = self.conn.execute_dict(SQL) status, rset = self.conn.execute_dict(SQL)
@ -294,7 +294,7 @@ SELECT EXISTS(
status, res = self.conn.execute_scalar( status, res = self.conn.execute_scalar(
render_template( render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, conn=self.conn, fetch_id=True, data=data, conn=self.conn, fetch_id=True,
has_connstr=self.manager.db_info['pgAgent']['has_connstr'] has_connstr=self.manager.db_info['pgAgent']['has_connstr']
) )
@ -307,7 +307,7 @@ SELECT EXISTS(
# We need oid of newly created database # We need oid of newly created database
status, res = self.conn.execute_dict( status, res = self.conn.execute_dict(
render_template( render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
jid=res, conn=self.conn jid=res, conn=self.conn
) )
) )
@ -341,7 +341,7 @@ SELECT EXISTS(
status, res = self.conn.execute_void( status, res = self.conn.execute_void(
render_template( render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, conn=self.conn, jid=jid, data=data, conn=self.conn, jid=jid,
has_connstr=self.manager.db_info['pgAgent']['has_connstr'] has_connstr=self.manager.db_info['pgAgent']['has_connstr']
) )
@ -353,7 +353,7 @@ SELECT EXISTS(
# We need oid of newly created database # We need oid of newly created database
status, res = self.conn.execute_dict( status, res = self.conn.execute_dict(
render_template( render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
jid=jid, conn=self.conn jid=jid, conn=self.conn
) )
) )
@ -387,7 +387,7 @@ SELECT EXISTS(
for jid in data['ids']: for jid in data['ids']:
status, res = self.conn.execute_void( status, res = self.conn.execute_void(
render_template( render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
jid=jid, conn=self.conn jid=jid, conn=self.conn
) )
) )
@ -417,7 +417,7 @@ SELECT EXISTS(
data=render_template( data=render_template(
"/".join([ "/".join([
self.template_path, self.template_path,
'create.sql' if jid is None else 'update.sql' self._CREATE_SQL if jid is None else self._UPDATE_SQL
]), ]),
jid=jid, data=data, conn=self.conn, fetch_id=False, jid=jid, data=data, conn=self.conn, fetch_id=False,
has_connstr=self.manager.db_info['pgAgent']['has_connstr'] has_connstr=self.manager.db_info['pgAgent']['has_connstr']
@ -460,7 +460,7 @@ SELECT EXISTS(
This function will generate sql for sql panel This function will generate sql for sql panel
""" """
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
jid=jid, conn=self.conn, last_system_oid=0 jid=jid, conn=self.conn, last_system_oid=0
) )
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -517,7 +517,7 @@ SELECT EXISTS(
return ajax_response( return ajax_response(
response=render_template( response=render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
jid=jid, data=row, conn=self.conn, fetch_id=False, jid=jid, data=row, conn=self.conn, fetch_id=False,
has_connstr=self.manager.db_info['pgAgent']['has_connstr'] has_connstr=self.manager.db_info['pgAgent']['has_connstr']
) )

View File

@ -40,8 +40,8 @@ class JobScheduleModule(CollectionNodeModule):
- Method is overridden from its base class to make the node as leaf node. - Method is overridden from its base class to make the node as leaf node.
""" """
NODE_TYPE = 'pga_schedule' _NODE_TYPE = 'pga_schedule'
COLLECTION_LABEL = gettext("Schedules") _COLLECTION_LABEL = gettext("Schedules")
def get_nodes(self, gid, sid, jid): def get_nodes(self, gid, sid, jid):
""" """
@ -214,7 +214,7 @@ class JobScheduleView(PGChildNodeView):
jid: Job ID jid: Job ID
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
jid=jid jid=jid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -240,7 +240,7 @@ class JobScheduleView(PGChildNodeView):
""" """
res = [] res = []
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
jscid=jscid, jscid=jscid,
jid=jid jid=jid
) )
@ -297,7 +297,7 @@ class JobScheduleView(PGChildNodeView):
jscid: JobSchedule ID jscid: JobSchedule ID
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
jscid=jscid, jid=jid jscid=jscid, jid=jid
) )
status, res = self.conn.execute_dict(sql) status, res = self.conn.execute_dict(sql)
@ -340,7 +340,7 @@ class JobScheduleView(PGChildNodeView):
format_schedule_data(data) format_schedule_data(data)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
jid=jid, jid=jid,
data=data, data=data,
fetch_id=True fetch_id=True
@ -358,7 +358,7 @@ class JobScheduleView(PGChildNodeView):
self.conn.execute_void('END') self.conn.execute_void('END')
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
jscid=res, jscid=res,
jid=jid jid=jid
) )
@ -410,7 +410,7 @@ class JobScheduleView(PGChildNodeView):
format_schedule_data(data) format_schedule_data(data)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
jid=jid, jid=jid,
jscid=jscid, jscid=jscid,
data=data data=data
@ -422,7 +422,7 @@ class JobScheduleView(PGChildNodeView):
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
jscid=jscid, jscid=jscid,
jid=jid jid=jid
) )
@ -462,7 +462,7 @@ class JobScheduleView(PGChildNodeView):
for jscid in data['ids']: for jscid in data['ids']:
status, res = self.conn.execute_void( status, res = self.conn.execute_void(
render_template( render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
jid=jid, jscid=jscid, conn=self.conn jid=jid, jscid=jscid, conn=self.conn
) )
) )
@ -495,14 +495,14 @@ class JobScheduleView(PGChildNodeView):
if jscid is None: if jscid is None:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
jid=jid, jid=jid,
data=data, data=data,
fetch_id=False fetch_id=False
) )
else: else:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
jid=jid, jid=jid,
jscid=jscid, jscid=jscid,
data=data data=data

View File

@ -39,8 +39,8 @@ class JobStepModule(CollectionNodeModule):
- Method is overridden from its base class to make the node as leaf node. - Method is overridden from its base class to make the node as leaf node.
""" """
NODE_TYPE = 'pga_jobstep' _NODE_TYPE = 'pga_jobstep'
COLLECTION_LABEL = gettext("Steps") _COLLECTION_LABEL = gettext("Steps")
def get_nodes(self, gid, sid, jid): def get_nodes(self, gid, sid, jid):
""" """
@ -226,7 +226,7 @@ SELECT EXISTS(
jid: Job ID jid: Job ID
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
jid=jid, jid=jid,
has_connstr=self.manager.db_info['pgAgent']['has_connstr'] has_connstr=self.manager.db_info['pgAgent']['has_connstr']
) )
@ -254,7 +254,7 @@ SELECT EXISTS(
""" """
res = [] res = []
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
jstid=jstid, jstid=jstid,
jid=jid jid=jid
) )
@ -311,7 +311,7 @@ SELECT EXISTS(
jstid: JobStep ID jstid: JobStep ID
""" """
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
jstid=jstid, jstid=jstid,
jid=jid, jid=jid,
has_connstr=self.manager.db_info['pgAgent']['has_connstr'] has_connstr=self.manager.db_info['pgAgent']['has_connstr']
@ -352,7 +352,7 @@ SELECT EXISTS(
data = json.loads(request.data.decode()) data = json.loads(request.data.decode())
sql = render_template( sql = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
jid=jid, jid=jid,
data=data, data=data,
has_connstr=self.manager.db_info['pgAgent']['has_connstr'] has_connstr=self.manager.db_info['pgAgent']['has_connstr']
@ -364,7 +364,7 @@ SELECT EXISTS(
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
jstid=res, jstid=res,
jid=jid jid=jid
) )
@ -411,7 +411,7 @@ SELECT EXISTS(
('jstdbname' in data or 'jstconnstr' in data) ('jstdbname' in data or 'jstconnstr' in data)
): ):
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
jstid=jstid, jstid=jstid,
jid=jid, jid=jid,
has_connstr=self.manager.db_info['pgAgent']['has_connstr'] has_connstr=self.manager.db_info['pgAgent']['has_connstr']
@ -438,7 +438,7 @@ SELECT EXISTS(
data['jstconnstr'] = row['jstconnstr'] data['jstconnstr'] = row['jstconnstr']
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
jid=jid, jid=jid,
jstid=jstid, jstid=jstid,
data=data, data=data,
@ -451,7 +451,7 @@ SELECT EXISTS(
return internal_server_error(errormsg=res) return internal_server_error(errormsg=res)
sql = render_template( sql = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
jstid=jstid, jstid=jstid,
jid=jid jid=jid
) )
@ -491,7 +491,7 @@ SELECT EXISTS(
for jstid in data['ids']: for jstid in data['ids']:
status, res = self.conn.execute_void( status, res = self.conn.execute_void(
render_template( render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
jid=jid, jstid=jstid, conn=self.conn jid=jid, jstid=jstid, conn=self.conn
) )
) )
@ -524,7 +524,7 @@ SELECT EXISTS(
if jstid is None: if jstid is None:
sql = render_template( sql = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
jid=jid, jid=jid,
data=data, data=data,
has_connstr=self.manager.db_info['pgAgent']['has_connstr'] has_connstr=self.manager.db_info['pgAgent']['has_connstr']
@ -536,7 +536,7 @@ SELECT EXISTS(
('jstdbname' in data or 'jstconnstr' in data) ('jstdbname' in data or 'jstconnstr' in data)
): ):
sql = render_template( sql = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
jstid=jstid, jstid=jstid,
jid=jid, jid=jid,
has_connstr=self.manager.db_info['pgAgent']['has_connstr'] has_connstr=self.manager.db_info['pgAgent']['has_connstr']
@ -563,7 +563,7 @@ SELECT EXISTS(
data['jstconnstr'] = row['jstconnstr'] data['jstconnstr'] = row['jstconnstr']
sql = render_template( sql = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
jid=jid, jid=jid,
jstid=jstid, jstid=jstid,
data=data, data=data,

View File

@ -52,8 +52,8 @@ class ResourceGroupModule(CollectionNodeModule):
node is initialized. node is initialized.
""" """
NODE_TYPE = 'resource_group' _NODE_TYPE = 'resource_group'
COLLECTION_LABEL = gettext("Resource Groups") _COLLECTION_LABEL = gettext("Resource Groups")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """

View File

@ -25,8 +25,8 @@ from config import PG_DEFAULT_DRIVER
class RoleModule(CollectionNodeModule): class RoleModule(CollectionNodeModule):
NODE_TYPE = 'role' _NODE_TYPE = 'role'
COLLECTION_LABEL = _("Login/Group Roles") _COLLECTION_LABEL = _("Login/Group Roles")
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.min_ver = None self.min_ver = None
@ -54,7 +54,7 @@ class RoleModule(CollectionNodeModule):
Load the module script for server, when any of the server-group node is Load the module script for server, when any of the server-group node is
initialized. initialized.
""" """
return sg.ServerGroupModule.NODE_TYPE return sg.ServerGroupModule.node_type
@property @property
def csssnippets(self): def csssnippets(self):
@ -565,7 +565,7 @@ rolmembership:{
def list(self, gid, sid): def list(self, gid, sid):
status, res = self.conn.execute_dict( status, res = self.conn.execute_dict(
render_template( render_template(
self.sql_path + 'properties.sql' self.sql_path + self._PROPERTIES_SQL
) )
) )
@ -587,7 +587,7 @@ rolmembership:{
def nodes(self, gid, sid): def nodes(self, gid, sid):
status, rset = self.conn.execute_2darray( status, rset = self.conn.execute_2darray(
render_template(self.sql_path + 'nodes.sql') render_template(self.sql_path + self._NODES_SQL)
) )
if not status: if not status:
@ -620,7 +620,7 @@ rolmembership:{
status, rset = self.conn.execute_2darray( status, rset = self.conn.execute_2darray(
render_template( render_template(
self.sql_path + 'nodes.sql', self.sql_path + self._NODES_SQL,
rid=rid rid=rid
) )
) )
@ -674,7 +674,7 @@ rolmembership:{
status, res = self.conn.execute_dict( status, res = self.conn.execute_dict(
render_template( render_template(
self.sql_path + 'properties.sql', self.sql_path + self._PROPERTIES_SQL,
rid=rid rid=rid
) )
) )
@ -773,7 +773,7 @@ rolmembership:{
def create(self, gid, sid): def create(self, gid, sid):
sql = render_template( sql = render_template(
self.sql_path + 'create.sql', self.sql_path + self._CREATE_SQL,
data=self.request, data=self.request,
dummy=False, dummy=False,
conn=self.conn conn=self.conn
@ -797,7 +797,7 @@ rolmembership:{
) )
status, rset = self.conn.execute_dict( status, rset = self.conn.execute_dict(
render_template(self.sql_path + 'nodes.sql', render_template(self.sql_path + self._NODES_SQL,
rid=rid rid=rid
) )
) )
@ -826,7 +826,7 @@ rolmembership:{
def update(self, gid, sid, rid): def update(self, gid, sid, rid):
sql = render_template( sql = render_template(
self.sql_path + 'update.sql', self.sql_path + self._UPDATE_SQL,
data=self.request, data=self.request,
dummy=False, dummy=False,
conn=self.conn, conn=self.conn,
@ -845,7 +845,7 @@ rolmembership:{
) )
status, rset = self.conn.execute_dict( status, rset = self.conn.execute_dict(
render_template(self.sql_path + 'nodes.sql', render_template(self.sql_path + self._NODES_SQL,
rid=rid rid=rid
) )
) )
@ -877,7 +877,7 @@ rolmembership:{
if rid is None: if rid is None:
return make_json_response( return make_json_response(
data=render_template( data=render_template(
self.sql_path + 'create.sql', self.sql_path + self._CREATE_SQL,
data=self.request, data=self.request,
dummy=True, dummy=True,
conn=self.conn conn=self.conn
@ -886,7 +886,7 @@ rolmembership:{
else: else:
return make_json_response( return make_json_response(
data=render_template( data=render_template(
self.sql_path + 'update.sql', self.sql_path + self._UPDATE_SQL,
data=self.request, data=self.request,
dummy=True, dummy=True,
conn=self.conn, conn=self.conn,

View File

@ -25,8 +25,8 @@ from config import PG_DEFAULT_DRIVER
class TablespaceModule(CollectionNodeModule): class TablespaceModule(CollectionNodeModule):
NODE_TYPE = 'tablespace' _NODE_TYPE = 'tablespace'
COLLECTION_LABEL = gettext("Tablespaces") _COLLECTION_LABEL = gettext("Tablespaces")
def __init__(self, import_name, **kwargs): def __init__(self, import_name, **kwargs):
super(TablespaceModule, self).__init__(import_name, **kwargs) super(TablespaceModule, self).__init__(import_name, **kwargs)
@ -44,7 +44,7 @@ class TablespaceModule(CollectionNodeModule):
Load the module script for server, when any of the server-group node is Load the module script for server, when any of the server-group node is
initialized. initialized.
""" """
return servers.ServerModule.NODE_TYPE return servers.ServerModule.node_type
@property @property
def module_use_template_javascript(self): def module_use_template_javascript(self):
@ -139,7 +139,7 @@ class TablespaceView(PGChildNodeView):
@check_precondition @check_precondition
def list(self, gid, sid): def list(self, gid, sid):
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
conn=self.conn conn=self.conn
) )
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -154,7 +154,7 @@ class TablespaceView(PGChildNodeView):
@check_precondition @check_precondition
def node(self, gid, sid, tsid): def node(self, gid, sid, tsid):
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
tsid=tsid, conn=self.conn tsid=tsid, conn=self.conn
) )
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -180,7 +180,7 @@ class TablespaceView(PGChildNodeView):
def nodes(self, gid, sid, tsid=None): def nodes(self, gid, sid, tsid=None):
res = [] res = []
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
tsid=tsid, conn=self.conn tsid=tsid, conn=self.conn
) )
status, rset = self.conn.execute_2darray(SQL) status, rset = self.conn.execute_2darray(SQL)
@ -230,7 +230,7 @@ class TablespaceView(PGChildNodeView):
# We need to parse & convert ACL coming from database to json format # We need to parse & convert ACL coming from database to json format
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'acl.sql']), "/".join([self.template_path, self._ACL_SQL]),
tsid=tsid, conn=self.conn tsid=tsid, conn=self.conn
) )
status, acl = self.conn.execute_dict(SQL) status, acl = self.conn.execute_dict(SQL)
@ -253,7 +253,7 @@ class TablespaceView(PGChildNodeView):
@check_precondition @check_precondition
def properties(self, gid, sid, tsid): def properties(self, gid, sid, tsid):
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
tsid=tsid, conn=self.conn tsid=tsid, conn=self.conn
) )
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -307,7 +307,7 @@ class TablespaceView(PGChildNodeView):
try: try:
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data, conn=self.conn data=data, conn=self.conn
) )
@ -398,7 +398,7 @@ class TablespaceView(PGChildNodeView):
# Get name for tablespace from tsid # Get name for tablespace from tsid
status, rset = self.conn.execute_dict( status, rset = self.conn.execute_dict(
render_template( render_template(
"/".join([self.template_path, 'nodes.sql']), "/".join([self.template_path, self._NODES_SQL]),
tsid=tsid, conn=self.conn tsid=tsid, conn=self.conn
) )
) )
@ -419,7 +419,7 @@ class TablespaceView(PGChildNodeView):
# drop tablespace # drop tablespace
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'delete.sql']), "/".join([self.template_path, self._DELETE_SQL]),
tsname=(rset['rows'][0])['name'], conn=self.conn tsname=(rset['rows'][0])['name'], conn=self.conn
) )
@ -477,7 +477,7 @@ class TablespaceView(PGChildNodeView):
if tsid is not None: if tsid is not None:
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
tsid=tsid, conn=self.conn tsid=tsid, conn=self.conn
) )
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -516,7 +516,7 @@ class TablespaceView(PGChildNodeView):
data[arg] = old_data[arg] data[arg] = old_data[arg]
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'update.sql']), "/".join([self.template_path, self._UPDATE_SQL]),
data=data, o_data=old_data data=data, o_data=old_data
) )
else: else:
@ -525,7 +525,7 @@ class TablespaceView(PGChildNodeView):
data['spcacl'] = parse_priv_to_db(data['spcacl'], self.acl) data['spcacl'] = parse_priv_to_db(data['spcacl'], self.acl)
# If the request for new object which do not have tsid # If the request for new object which do not have tsid
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=data data=data
) )
SQL += "\n" SQL += "\n"
@ -542,7 +542,7 @@ class TablespaceView(PGChildNodeView):
This function will generate sql for sql panel This function will generate sql for sql panel
""" """
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'properties.sql']), "/".join([self.template_path, self._PROPERTIES_SQL]),
tsid=tsid, conn=self.conn tsid=tsid, conn=self.conn
) )
status, res = self.conn.execute_dict(SQL) status, res = self.conn.execute_dict(SQL)
@ -566,7 +566,7 @@ class TablespaceView(PGChildNodeView):
# We are not showing create sql for system tablespace # We are not showing create sql for system tablespace
if not old_data['name'].startswith('pg_'): if not old_data['name'].startswith('pg_'):
SQL = render_template( SQL = render_template(
"/".join([self.template_path, 'create.sql']), "/".join([self.template_path, self._CREATE_SQL]),
data=old_data data=old_data
) )
SQL += "\n" SQL += "\n"

View File

@ -371,6 +371,17 @@ class NodeView(with_metaclass(MethodViewType, View)):
class PGChildNodeView(NodeView): class PGChildNodeView(NodeView):
_NODE_SQL = 'node.sql'
_NODES_SQL = 'nodes.sql'
_CREATE_SQL = 'create.sql'
_UPDATE_SQL = 'update.sql'
_PROPERTIES_SQL = 'properties.sql'
_DELETE_SQL = 'delete.sql'
_GRANT_SQL = 'grant.sql'
_SCHEMA_SQL = 'schema.sql'
_ACL_SQL = 'acl.sql'
_OID_SQL = 'get_oid.sql'
def get_children_nodes(self, manager, **kwargs): def get_children_nodes(self, manager, **kwargs):
""" """
Returns the list of children nodes for the current nodes. Returns the list of children nodes for the current nodes.

View File

@ -471,7 +471,7 @@ def compare(trans_id, source_sid, source_did, source_scid,
view = SchemaDiffRegistry.get_node_view(node_name) view = SchemaDiffRegistry.get_node_view(node_name)
if hasattr(view, 'compare'): if hasattr(view, 'compare'):
msg = gettext('Comparing {0}').\ msg = gettext('Comparing {0}').\
format(gettext(view.blueprint.COLLECTION_LABEL)) format(gettext(view.blueprint.collection_label))
diff_model_obj.set_comparison_info(msg, total_percent) diff_model_obj.set_comparison_info(msg, total_percent)
# Update the message and total percentage in session object # Update the message and total percentage in session object
update_session_diff_transaction(trans_id, session_obj, update_session_diff_transaction(trans_id, session_obj,

View File

@ -92,7 +92,7 @@ class SchemaDiffObjectCompare:
source_dict=source, source_dict=source,
target_dict=target, target_dict=target,
node=self.node_type, node=self.node_type,
node_label=self.blueprint.COLLECTION_LABEL, node_label=self.blueprint.collection_label,
ignore_whitespaces=ignore_whitespaces, ignore_whitespaces=ignore_whitespaces,
ignore_keys=self.keys_to_ignore) ignore_keys=self.keys_to_ignore)