Removing dynamic module loading and replacing it with static loading. Fixes #7492

Gets rid of all occurrences and usage of get_own_javascripts since it is no longer used.
This commit is contained in:
Aditya Toshniwal
2022-06-30 11:06:50 +05:30
committed by Akshay Joshi
parent e46468321d
commit cb635f6706
51 changed files with 490 additions and 550 deletions

View File

@@ -123,6 +123,15 @@ class ServerGroupModule(BrowserPluginModule):
"""
pass
def register(self, app, options):
"""
Override the default register function to automagically register
sub-modules at once.
"""
from .servers import blueprint as module
self.submodules.append(module)
super(BrowserPluginModule, self).register(app, options)
class ServerGroupMenuItem(MenuItem):
def __init__(self, **kwargs):

View File

@@ -283,30 +283,6 @@ class ServerModule(sg.ServerGroupPluginModule):
return snippets
def get_own_javascripts(self):
scripts = []
scripts.extend([{
'name': 'pgadmin.browser.server.privilege',
'path': url_for('%s.static' % self.name, filename='js/privilege'),
'when': self.node_type,
'is_template': False,
'deps': ['pgadmin.browser.node.ui']
}, {
'name': 'pgadmin.browser.server.variable',
'path': url_for('%s.static' % self.name, filename='js/variable'),
'when': self.node_type,
'is_template': False
}, {
'name': 'pgadmin.server.supported_servers',
'path': url_for('browser.index') + 'server/supported_servers',
'is_template': True,
'when': self.node_type
}])
scripts.extend(sg.ServerGroupPluginModule.get_own_javascripts(self))
return scripts
def register(self, app, options):
"""
Override the default register function to automagically register
@@ -318,6 +294,23 @@ class ServerModule(sg.ServerGroupPluginModule):
app.jinja_env.filters['qtTypeIdent'] = driver.qtTypeIdent
app.jinja_env.filters['hasAny'] = has_any
from .ppas import PPAS
from .databases import blueprint as module
self.submodules.append(module)
from .pgagent import blueprint as module
self.submodules.append(module)
from .resource_groups import blueprint as module
self.submodules.append(module)
from .roles import blueprint as module
self.submodules.append(module)
from .tablespaces import blueprint as module
self.submodules.append(module)
super(ServerModule, self).register(app, options)
# We do not have any preferences for server node.

View File

@@ -95,6 +95,40 @@ class DatabaseModule(CollectionNodeModule):
"""
return False
def register(self, app, options):
"""
Override the default register function to automagically register
sub-modules at once.
"""
from .casts import blueprint as module
self.submodules.append(module)
from .event_triggers import blueprint as module
self.submodules.append(module)
from .extensions import blueprint as module
self.submodules.append(module)
from .foreign_data_wrappers import blueprint as module
self.submodules.append(module)
from .languages import blueprint as module
self.submodules.append(module)
from .publications import blueprint as module
self.submodules.append(module)
from .schemas import schema_blueprint as module
self.submodules.append(module)
from .schemas import catalog_blueprint as module
self.submodules.append(module)
from .subscriptions import blueprint as module
self.submodules.append(module)
super(DatabaseModule, self).register(app, options)
blueprint = DatabaseModule(__name__)

View File

@@ -95,6 +95,15 @@ class ForeignDataWrapperModule(CollectionNodeModule):
"""
return False
def register(self, app, options):
"""
Override the default register function to automagically register
sub-modules at once.
"""
from .foreign_servers import blueprint as module
self.submodules.append(module)
super(ForeignDataWrapperModule, self).register(app, options)
blueprint = ForeignDataWrapperModule(__name__)

View File

@@ -96,6 +96,15 @@ class ForeignServerModule(CollectionNodeModule):
"""
return False
def register(self, app, options):
"""
Override the default register function to automagically register
sub-modules at once.
"""
from .user_mappings import blueprint as module
self.submodules.append(module)
super(ForeignServerModule, self).register(app, options)
blueprint = ForeignServerModule(__name__)

View File

@@ -103,6 +103,73 @@ class SchemaModule(CollectionNodeModule):
"""
return False
def register(self, app, options):
"""
Override the default register function to automagically register
sub-modules at once.
"""
from .aggregates import blueprint as module
self.submodules.append(module)
from .catalog_objects import blueprint as module
self.submodules.append(module)
from .collations import blueprint as module
self.submodules.append(module)
from .domains import blueprint as module
self.submodules.append(module)
from .foreign_tables import blueprint as module
self.submodules.append(module)
from .fts_configurations import blueprint as module
self.submodules.append(module)
from .fts_dictionaries import blueprint as module
self.submodules.append(module)
from .fts_parsers import blueprint as module
self.submodules.append(module)
from .fts_templates import blueprint as module
self.submodules.append(module)
from .functions import blueprint as module
self.submodules.append(module)
from .functions import trigger_function_blueprint as module
self.submodules.append(module)
from .functions import procedure_blueprint as module
self.submodules.append(module)
from .operators import blueprint as module
self.submodules.append(module)
from .packages import blueprint as module
self.submodules.append(module)
from .sequences import blueprint as module
self.submodules.append(module)
from .synonyms import blueprint as module
self.submodules.append(module)
from .tables import blueprint as module
self.submodules.append(module)
from .types import blueprint as module
self.submodules.append(module)
from .views import view_blueprint as module
self.submodules.append(module)
from .views import mview_blueprint as module
self.submodules.append(module)
super(SchemaModule, self).register(app, options)
class CatalogModule(SchemaModule):
"""
@@ -114,6 +181,13 @@ class CatalogModule(SchemaModule):
_NODE_TYPE = 'catalog'
_COLLECTION_LABEL = gettext("Catalogs")
def register(self, app, options):
"""
Override the default register function to automagically register
sub-modules at once.
"""
super(SchemaModule, self).register(app, options)
schema_blueprint = SchemaModule(__name__)
catalog_blueprint = CatalogModule(__name__)

View File

@@ -80,6 +80,16 @@ class CatalogObjectModule(SchemaChildModule):
"""
return database.DatabaseModule.node_type
def register(self, app, options):
"""
Override the default register function to automagically register
sub-modules at once.
"""
super(CatalogObjectModule, self).register(app, options)
from .columns import blueprint as module
app.register_blueprint(module)
blueprint = CatalogObjectModule(__name__)

View File

@@ -71,6 +71,15 @@ class DomainModule(SchemaChildModule):
"""
return databases.DatabaseModule.node_type
def register(self, app, options):
"""
Override the default register function to automagically register
sub-modules at once.
"""
from .domain_constraints import blueprint as module
self.submodules.append(module)
super(DomainModule, self).register(app, options)
blueprint = DomainModule(__name__)

View File

@@ -76,6 +76,18 @@ class PackageModule(SchemaChildModule):
"""
return database.DatabaseModule.node_type
def register(self, app, options):
"""
Override the default register function to automagically register
sub-modules at once.
"""
from .edbfuncs import blueprint as module
self.submodules.append(module)
from .edbvars import blueprint as module
self.submodules.append(module)
super(PackageModule, self).register(app, options)
blueprint = PackageModule(__name__)

View File

@@ -118,17 +118,36 @@ class TableModule(SchemaChildModule):
return snippets
def get_own_javascripts(self):
scripts = SchemaChildModule.get_own_javascripts(self)
def register(self, app, options):
"""
Override the default register function to automagically register
sub-modules at once.
"""
from .columns import blueprint as module
self.submodules.append(module)
scripts.append({
'name': 'pgadmin.browser.table.partition.utils',
'path': url_for('browser.index') +
'table/static/js/partition.utils',
'when': 'database', 'is_template': False
})
from .compound_triggers import blueprint as module
self.submodules.append(module)
return scripts
from .constraints import blueprint as module
self.submodules.append(module)
from .indexes import blueprint as module
self.submodules.append(module)
from .partitions import blueprint as module
self.submodules.append(module)
from .row_security_policies import blueprint as module
self.submodules.append(module)
from .rules import blueprint as module
self.submodules.append(module)
from .triggers import blueprint as module
self.submodules.append(module)
super(TableModule, self).register(app, options)
blueprint = TableModule(__name__)

View File

@@ -83,6 +83,28 @@ class ConstraintsModule(CollectionNodeModule):
"""
return False
def register(self, app, options):
"""
Override the default register function to automagically register
sub-modules at once.
"""
from .check_constraint import blueprint as module
self.submodules.append(module)
from .exclusion_constraint import blueprint as module
self.submodules.append(module)
from .foreign_key import blueprint as module
self.submodules.append(module)
from .index_constraint import primary_key_blueprint as module
self.submodules.append(module)
from .index_constraint import unique_constraint_blueprint as module
self.submodules.append(module)
super(ConstraintsModule, self).register(app, options)
blueprint = ConstraintsModule(__name__)

View File

@@ -122,13 +122,9 @@ class PartitionsModule(CollectionNodeModule):
sub-modules of table node under partition table node.
"""
self.submodules = list(app.find_submodules(self.import_name))
self.submodules = []
super(CollectionNodeModule, self).register(app, options)
for module in self.submodules:
module.parentmodules.append(self)
app.register_blueprint(module)
# Now add sub modules of table node to partition table node.
# Exclude 'partition' module for now to avoid cyclic import issue.
modules_to_skip = ['partition', 'column']

View File

@@ -130,6 +130,25 @@ class ViewModule(SchemaChildModule):
return snippets
def register(self, app, options):
from pgadmin.browser.server_groups.servers.databases.schemas.\
tables.columns import blueprint as module
self.submodules.append(module)
from pgadmin.browser.server_groups.servers.databases.schemas.\
tables.indexes import blueprint as module
self.submodules.append(module)
from pgadmin.browser.server_groups.servers.databases.schemas.\
tables.triggers import blueprint as module
self.submodules.append(module)
from pgadmin.browser.server_groups.servers.databases.schemas.\
tables.rules import blueprint as module
self.submodules.append(module)
from pgadmin.browser.server_groups.servers.databases.schemas.\
tables.compound_triggers import blueprint as module
self.submodules.append(module)
super(ViewModule, self).register(app, options)
class Message(IProcessDesc):
def __init__(self, _sid, _data, _query):

View File

@@ -111,6 +111,19 @@ SELECT EXISTS(
"""
return False
def register(self, app, options):
"""
Override the default register function to automagically register
sub-modules at once.
"""
from .schedules import blueprint as module
self.submodules.append(module)
from .steps import blueprint as module
self.submodules.append(module)
super(JobModule, self).register(app, options)
blueprint = JobModule(__name__)