mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Initialize (executing the constructor) for the PGNodeModule needs to be
called while initialing the CollectionNodeModule, as super(..).__init__(..) does not call __init__ function of all parent classes. Please refer to method resolution order (MRO) in python for more information. This patch also includes some typo resolution in PGNdoeModule. Also, removed the AddAttr(..) at the moment, because - it is not going anywhere at the moment.
This commit is contained in:
parent
2233583dbd
commit
3d134a3d07
@ -11,9 +11,9 @@ import six
|
|||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
from flask import url_for, render_template
|
from flask import url_for, render_template
|
||||||
from flask.ext.babel import gettext
|
from flask.ext.babel import gettext
|
||||||
from pgadmin.browser.utils import PgAdminModule, PGChildModule
|
from pgadmin.utils import PgAdminModule
|
||||||
|
from pgadmin.browser.utils import PGChildModule
|
||||||
from pgadmin.browser import BrowserPluginModule
|
from pgadmin.browser import BrowserPluginModule
|
||||||
from pgadmin.browser.utils import PGChildNodeView
|
|
||||||
|
|
||||||
@six.add_metaclass(ABCMeta)
|
@six.add_metaclass(ABCMeta)
|
||||||
class CollectionNodeModule(PgAdminModule, PGChildModule):
|
class CollectionNodeModule(PgAdminModule, PGChildModule):
|
||||||
@ -25,11 +25,14 @@ class CollectionNodeModule(PgAdminModule, PGChildModule):
|
|||||||
def __init__(self, import_name, **kwargs):
|
def __init__(self, import_name, **kwargs):
|
||||||
kwargs.setdefault("url_prefix", self.node_path)
|
kwargs.setdefault("url_prefix", self.node_path)
|
||||||
kwargs.setdefault("static_url_path", '/static')
|
kwargs.setdefault("static_url_path", '/static')
|
||||||
super(CollectionNodeModule, self).__init__(
|
|
||||||
|
PgAdminModule.__init__(
|
||||||
|
self,
|
||||||
"NODE-%s" % self.node_type,
|
"NODE-%s" % self.node_type,
|
||||||
import_name,
|
import_name,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
PGChildModule.__init__(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def jssnippets(self):
|
def jssnippets(self):
|
||||||
|
@ -9,16 +9,14 @@
|
|||||||
|
|
||||||
"""Browser helper utilities"""
|
"""Browser helper utilities"""
|
||||||
|
|
||||||
from abc import ABCMeta, abstractmethod, abstractproperty
|
from abc import ABCMeta, abstractmethod
|
||||||
from collections import OrderedDict
|
|
||||||
import flask
|
import flask
|
||||||
from flask.views import View, MethodViewType, with_metaclass
|
from flask.views import View, MethodViewType, with_metaclass
|
||||||
from flask.ext.babel import gettext
|
from flask.ext.babel import gettext
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from config import PG_DEFAULT_DRIVER
|
from config import PG_DEFAULT_DRIVER
|
||||||
from pgadmin.browser import PgAdminModule
|
from pgadmin.utils.ajax import make_json_response, precondition_required
|
||||||
from pgadmin.utils.ajax import make_json_response
|
|
||||||
|
|
||||||
@six.add_metaclass(ABCMeta)
|
@six.add_metaclass(ABCMeta)
|
||||||
class NodeAttr(object):
|
class NodeAttr(object):
|
||||||
@ -34,7 +32,7 @@ class NodeAttr(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PGChildModule:
|
class PGChildModule(object):
|
||||||
"""
|
"""
|
||||||
class PGChildModule
|
class PGChildModule
|
||||||
|
|
||||||
@ -55,15 +53,14 @@ class PGChildModule:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.min_ver = 1000000000
|
self.min_ver = 0
|
||||||
self.max_ver = 0
|
self.max_ver = 1000000000
|
||||||
self.server_type = None
|
self.server_type = None
|
||||||
self.attributes = {}
|
|
||||||
|
|
||||||
super(PGChildModule, self).__init__(*args, **kwargs)
|
super(PGChildModule, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def BackendSupported(self, mangaer, **kwargs):
|
def BackendSupported(self, manager, **kwargs):
|
||||||
sversion = getattr(mangaer, 'sversion', None)
|
sversion = getattr(manager, 'sversion', None)
|
||||||
if (sversion is None or not isinstance(sversion, int)):
|
if (sversion is None or not isinstance(sversion, int)):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -85,33 +82,6 @@ class PGChildModule:
|
|||||||
def get_nodes(self, sid=None, **kwargs):
|
def get_nodes(self, sid=None, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def AddAttr(self, attr):
|
|
||||||
assert(isinstance(attr, PGNodeAttr))
|
|
||||||
|
|
||||||
name = getattr(attr, 'name', None)
|
|
||||||
assert(name is not None and isinstance(name, str))
|
|
||||||
assert(name not in self.attributes)
|
|
||||||
# TODO:: Check for naming convention
|
|
||||||
|
|
||||||
min_ver = getattr(attr, 'min_ver', None)
|
|
||||||
assert(min_ver is None or isinstance(min_ver, int))
|
|
||||||
|
|
||||||
max_ver = getattr(attr, 'max_ver', None)
|
|
||||||
assert(max_ver is None or isinstance(max_ver, int))
|
|
||||||
|
|
||||||
self.attributes[name] = attr
|
|
||||||
|
|
||||||
if max_ver is None:
|
|
||||||
self.max_ver = None
|
|
||||||
elif self.max_var is not None and self.max_ver < max_ver:
|
|
||||||
self.max_ver < max_ver
|
|
||||||
|
|
||||||
if min_ver is None:
|
|
||||||
self.min_ver = None
|
|
||||||
elif self.min_ver is not None and self.min_ver > min_ver:
|
|
||||||
self.min_ver = min_ver
|
|
||||||
|
|
||||||
|
|
||||||
class NodeView(with_metaclass(MethodViewType, View)):
|
class NodeView(with_metaclass(MethodViewType, View)):
|
||||||
"""
|
"""
|
||||||
A PostgreSQL Object has so many operaions/functions apart from CRUD
|
A PostgreSQL Object has so many operaions/functions apart from CRUD
|
||||||
|
Loading…
Reference in New Issue
Block a user