mirror of
https://github.com/peeringdb/peeringdb.git
synced 2024-05-11 05:55:09 +00:00
* stub in poetry for pipenv * re-add tester image * add pre-commit / formatting * fix ghactions * revert test data whitespace, exclude tests/data * revert ws * decruft, rm tox/pipenv * install dev packages for base image * add lgtm config to force to py3
30 lines
848 B
Python
30 lines
848 B
Python
from django_peeringdb.client_adaptor.load import DJANGO_DB_FIELDS, database_settings
|
|
|
|
__backend = None
|
|
|
|
|
|
def load_backend(**orm_config):
|
|
"""
|
|
Load the client adaptor module of django_peeringdb
|
|
Assumes config is valid.
|
|
"""
|
|
settings = {}
|
|
settings["SECRET_KEY"] = orm_config.get("secret_key", "")
|
|
|
|
db_config = orm_config["database"]
|
|
if db_config:
|
|
settings["DATABASES"] = {"default": database_settings(db_config)}
|
|
|
|
from peeringdb_server.client_adaptor.setup import configure
|
|
|
|
# Override defaults
|
|
configure(**settings)
|
|
# Must import implementation module after configure
|
|
from peeringdb_server.client_adaptor import backend
|
|
|
|
migrate = orm_config.get("migrate")
|
|
if migrate and not backend.Backend().is_database_migrated():
|
|
backend.Backend().migrate_database()
|
|
|
|
return backend
|