Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import Admin module based on runtime configuration (#1469) #1485

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pygeoapi/django_/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
from django.conf import settings
from django.http import HttpRequest, HttpResponse

from pygeoapi.admin import Admin
from pygeoapi.api import API


Expand Down Expand Up @@ -544,10 +543,11 @@ def _feed_response(request: HttpRequest, api_definition: str,
*args, **kwargs) -> Tuple[Dict, int, str]:
"""Use pygeoapi api to process the input request"""

if 'admin' not in api_definition:
api_ = API(settings.PYGEOAPI_CONFIG)
else:
if 'admin' in api_definition and settings.PYGEOAPI_CONFIG['server'].get('admin'): # noqa
from pygeoapi.admin import Admin
api_ = Admin(settings.PYGEOAPI_CONFIG)
else:
api_ = API(settings.PYGEOAPI_CONFIG)

api = getattr(api_, api_definition)

Expand Down
4 changes: 3 additions & 1 deletion pygeoapi/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

from flask import Flask, Blueprint, make_response, request, send_from_directory

from pygeoapi.admin import Admin
from pygeoapi.api import API
from pygeoapi.openapi import load_openapi_document
from pygeoapi.config import get_config
Expand All @@ -48,6 +47,9 @@

API_RULES = get_api_rules(CONFIG)

if CONFIG['server'].get('admin'):
from pygeoapi.admin import Admin

STATIC_FOLDER = 'static'
if 'templates' in CONFIG['server']:
STATIC_FOLDER = CONFIG['server']['templates'].get('static', 'static')
Expand Down
4 changes: 3 additions & 1 deletion pygeoapi/starlette_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import uvicorn

from pygeoapi.api import API
from pygeoapi.admin import Admin
from pygeoapi.openapi import load_openapi_document
from pygeoapi.config import get_config
from pygeoapi.util import get_api_rules
Expand All @@ -62,6 +61,9 @@

OPENAPI = load_openapi_document()

if CONFIG['server'].get('admin'):
from pygeoapi.admin import Admin

p = Path(__file__)

APP = Starlette(debug=True)
Expand Down
Loading