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 5
5
from django .conf import settings
6
6
from idom .core .proto import ComponentConstructor
7
7
8
+ from .app_settings import IDOM_IGNORED_DJANGO_APPS
9
+
8
10
9
11
logger = logging .getLogger (__name__ )
10
12
_LOADED_COMPONENTS : Dict [str , ComponentConstructor ] = {}
@@ -19,6 +21,10 @@ def has_component(name: str) -> bool:
19
21
20
22
21
23
for 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
+
22
28
idom_mod_name = f"{ app_mod_name } .idom"
23
29
24
30
try :
@@ -36,17 +42,23 @@ def has_component(name: str) -> bool:
36
42
37
43
for component_constructor in idom_mod .components :
38
44
if not callable (component_constructor ):
39
- logger . warning (
45
+ raise ValueError (
40
46
f"{ component_constructor } is not a callable component constructor"
41
47
)
42
- continue
43
48
44
49
try :
45
50
component_name = getattr (component_constructor , "__name__" )
46
51
except AttributeError :
47
- logger . warning (
52
+ raise ValueError (
48
53
f"Component constructor { component_constructor } has not attribute '__name__'"
49
54
)
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
+ )
51
63
52
64
_LOADED_COMPONENTS [f"{ app_mod_name } .{ component_name } " ] = component_constructor
Original file line number Diff line number Diff line change 10
10
for file in (APP_DIR / "templates" / "idom" ).iterdir ()
11
11
}
12
12
13
+ IDOM_IGNORED_DJANGO_APPS = set (getattr (settings , "IDOM_IGNORED_DJANGO_APPS" , []))
14
+
13
15
IDOM_BASE_URL = getattr (settings , "IDOM_BASE_URL" , "_idom/" )
14
16
IDOM_WEBSOCKET_URL = IDOM_BASE_URL + "websocket/"
15
17
IDOM_WEB_MODULES_URL = IDOM_BASE_URL + "web_module/"
You can’t perform that action at this time.
0 commit comments