Skip to content

Commit cb06ea2

Browse files
refactor: skip improperly configured issue when apps are not fully config
1 parent 0af187b commit cb06ea2

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

openedx_authz/apps.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"""
44

55
from django.apps import AppConfig
6-
from django.conf import settings
7-
6+
from django.core.exceptions import ImproperlyConfigured
87

98

109
class OpenedxAuthzConfig(AppConfig):
@@ -45,5 +44,10 @@ class OpenedxAuthzConfig(AppConfig):
4544
def ready(self):
4645
"""Initialization layer for the openedx_authz app."""
4746
# Initialize the enforcer to ensure it's ready when the app starts
48-
from openedx_authz.engine.enforcer import AuthzEnforcer
49-
AuthzEnforcer()
47+
try:
48+
from openedx_authz.engine.enforcer import AuthzEnforcer
49+
AuthzEnforcer()
50+
except ImproperlyConfigured:
51+
# The app might not be fully configured yet (e.g., during migrations).
52+
# In such cases, we skip the enforcer initialization.
53+
pass

openedx_authz/settings/common.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ def plugin_settings(settings):
2121
if casbin_adapter_app not in settings.INSTALLED_APPS:
2222
settings.INSTALLED_APPS.append(casbin_adapter_app)
2323
# Add Casbin configuration
24-
settings.CASBIN_MODEL = os.path.join(ROOT_DIRECTORY, "engine", "config", "model.conf")
25-
settings.CASBIN_WATCHER_ENABLED = True
24+
settings.CASBIN_MODEL = os.path.join(
25+
ROOT_DIRECTORY, "engine", "config", "model.conf"
26+
)
27+
settings.CASBIN_WATCHER_ENABLED = False
2628
# TODO: Replace with a more dynamic configuration
2729
# Redis host and port are temporarily loaded here for the MVP
2830
settings.REDIS_HOST = "redis"

0 commit comments

Comments
 (0)