Skip to content

Commit

Permalink
feat: restructure wsgi to make to more modular
Browse files Browse the repository at this point in the history
  • Loading branch information
MagneticNeedle committed Apr 21, 2023
1 parent 2ae1cee commit ebb12a8
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions bfportal/bfportal/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,31 @@
import os
import warnings

from django.core.wsgi import get_wsgi_application
from dotenv import load_dotenv

load_dotenv()
from loguru import logger


def init_project():
"""Initialize the project
"""Initialize the project"""
logger.info("project loaded")


def init_wsgi():
"""Initialize the WSGI
Used to load .env file and set project specific settings
"""
from loguru import logger

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bfportal.settings.production")
logger.info(".env loaded")
global application
with warnings.catch_warnings():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bfportal.settings.production")
from django.core.wsgi import get_wsgi_application
from wagtail.utils.deprecation import RemovedInWagtail50Warning

warnings.filterwarnings(
"ignore", category=RemovedInWagtail50Warning
) # supress only wagtail warnings
application = get_wsgi_application()

with warnings.catch_warnings():
from wagtail.utils.deprecation import RemovedInWagtail50Warning

warnings.filterwarnings(
"ignore", category=RemovedInWagtail50Warning
) # supress only wagtail warnings
init_project()
application = get_wsgi_application()
application = None
init_project()
init_wsgi()

0 comments on commit ebb12a8

Please sign in to comment.