From 26e9ceaf48a1fb66c1e62882a9f8c1482f0dc7c8 Mon Sep 17 00:00:00 2001 From: Ashesh Vashi Date: Mon, 25 Apr 2016 15:33:48 +0530 Subject: [PATCH] Do not reset the driver registry when the 'load_driver' method of DriverRegistry is executed second time. Also, initialize the driver before registering different blueprints, which uses those driver inside them. Thanks Khushboo for reporting the issue. --- web/pgadmin/__init__.py | 6 +++--- web/pgadmin/utils/driver/registry.py | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py index 7706a4e3a..ece79f788 100644 --- a/web/pgadmin/__init__.py +++ b/web/pgadmin/__init__.py @@ -201,6 +201,9 @@ def create_app(app_name=config.APP_NAME): from setup import do_upgrade do_upgrade(app, user_datastore, security, version) + # Load all available serve drivers + driver.init_app(app) + ########################################################################## # Load plugin modules ########################################################################## @@ -252,9 +255,6 @@ def create_app(app_name=config.APP_NAME): 'current_blueprint': current_blueprint } - # Load all available serve drivers - driver.init_app(app) - ########################################################################## # All done! ########################################################################## diff --git a/web/pgadmin/utils/driver/registry.py b/web/pgadmin/utils/driver/registry.py index 659aa76a0..466f9c6ee 100644 --- a/web/pgadmin/utils/driver/registry.py +++ b/web/pgadmin/utils/driver/registry.py @@ -46,7 +46,7 @@ class DriverRegistry(ABCMeta): - Use this function from init_app(...) to load all available drivers in the registry. """ - registry = dict() + registry = None drivers = dict() def __init__(cls, name, bases, d): @@ -76,7 +76,9 @@ class DriverRegistry(ABCMeta): @classmethod def load_drivers(cls): - DriverRegistry.registry = dict() + # Initialize the registry only if it has not yet been initialized + if DriverRegistry.registry is None: + DriverRegistry.registry = dict() from importlib import import_module from werkzeug.utils import find_modules