Moving children function within the PGChildNodeView itself, instead of

putting it in separate class PGChildNode, because - it has not been used
anywhere else.
pull/3/head
Ashesh Vashi 2015-12-26 11:29:08 +05:30
parent d55b02aeab
commit 15daf44e19
1 changed files with 14 additions and 14 deletions

View File

@ -62,7 +62,7 @@ class PGChildModule:
super(PGChildModule, self).__init__(*args, **kwargs) super(PGChildModule, self).__init__(*args, **kwargs)
def BackendSupported(self, mangaer): def BackendSupported(self, mangaer, **kwargs):
sversion = getattr(mangaer, 'sversion', None) sversion = getattr(mangaer, 'sversion', None)
if (sversion is None or not isinstance(sversion, int)): if (sversion is None or not isinstance(sversion, int)):
return False return False
@ -328,14 +328,19 @@ class NodeView(with_metaclass(MethodViewType, View)):
return make_json_response(data=children) return make_json_response(data=children)
class PGChildNode(object): class PGChildNodeView(NodeView):
def children(self, sid, **kwargs): def children(self, **kwargs):
"""Build a list of treeview nodes from the child nodes.""" """Build a list of treeview nodes from the child nodes."""
if 'sid' not in kwargs:
return precondition_required(
gettext('Required properties are missing!')
)
from pgadmin.utils.driver import get_driver from pgadmin.utils.driver import get_driver
manager = get_driver(PG_DEFAULT_DRIVER).connection_manager( manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(
sid=sid sid=kwargs['sid']
) )
did = None did = None
@ -347,22 +352,17 @@ class PGChildNode(object):
if not conn.connected(): if not conn.connected():
return precondition_required( return precondition_required(
gettext( gettext(
"Please make a connection to the server first!" "Connection has been lost with the server!"
) )
) )
nodes = [] nodes = []
for module in self.blueprint.submodules: for module in self.blueprint.submodules:
if isinstance(module, PGChildModule): if isinstance(module, PGChildModule):
if sid is not None and manager is not None and \ if manager is not None and \
module.BackendSupported(manager): module.BackendSupported(manager, **kwargs):
nodes.extend(module.get_nodes(sid=sid, **kwargs)) nodes.extend(module.get_nodes(**kwargs))
else: else:
nodes.extend(module.get_nodes(sid=sid, **kwargs)) nodes.extend(module.get_nodes(**kwargs))
return make_json_response(data=nodes) return make_json_response(data=nodes)
class PGChildNodeView(NodeView, PGChildNode):
pass