File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 55from django .conf import settings
66from idom .core .proto import ComponentConstructor
77
8+ from .app_settings import IDOM_IGNORED_DJANGO_APPS
9+
810
911logger = logging .getLogger (__name__ )
1012_LOADED_COMPONENTS : Dict [str , ComponentConstructor ] = {}
@@ -19,6 +21,10 @@ def has_component(name: str) -> bool:
1921
2022
2123for app_mod_name in settings .INSTALLED_APPS :
24+ if app_mod_name in IDOM_IGNORED_DJANGO_APPS :
25+ logger .debug (f"{ idom_mod_name !r} skipped by IDOM_IGNORED_DJANGO_APPS" )
26+ continue
27+
2228 idom_mod_name = f"{ app_mod_name } .idom"
2329
2430 try :
@@ -36,17 +42,23 @@ def has_component(name: str) -> bool:
3642
3743 for component_constructor in idom_mod .components :
3844 if not callable (component_constructor ):
39- logger . warning (
45+ raise ValueError (
4046 f"{ component_constructor } is not a callable component constructor"
4147 )
42- continue
4348
4449 try :
4550 component_name = getattr (component_constructor , "__name__" )
4651 except AttributeError :
47- logger . warning (
52+ raise ValueError (
4853 f"Component constructor { component_constructor } has not attribute '__name__'"
4954 )
50- continue
55+
56+ full_component_name = f"{ app_mod_name } .{ component_name } "
57+
58+ if full_component_name in _LOADED_COMPONENTS :
59+ raise ValueError (
60+ f"Component constructor named { component_name !r} has already been "
61+ f"declared by the app { app_mod_name !r} "
62+ )
5163
5264 _LOADED_COMPONENTS [f"{ app_mod_name } .{ component_name } " ] = component_constructor
Original file line number Diff line number Diff line change 1010 for file in (APP_DIR / "templates" / "idom" ).iterdir ()
1111}
1212
13+ IDOM_IGNORED_DJANGO_APPS = set (getattr (settings , "IDOM_IGNORED_DJANGO_APPS" , []))
14+
1315IDOM_BASE_URL = getattr (settings , "IDOM_BASE_URL" , "_idom/" )
1416IDOM_WEBSOCKET_URL = IDOM_BASE_URL + "websocket/"
1517IDOM_WEB_MODULES_URL = IDOM_BASE_URL + "web_module/"
You can’t perform that action at this time.
0 commit comments