Skip to content

Commit d69b761

Browse files
committed
Fix __module__ for component plugins
1 parent 0160a9d commit d69b761

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

djangocms_frontend/cms_plugins.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from cms.plugin_pool import plugin_pool
2+
from django.core.exceptions import ImproperlyConfigured
23

34
from .ui_plugin_base import CMSUIPluginBase
45

@@ -11,7 +12,7 @@ def update_plugin_pool():
1112
from .component_pool import components
1213

1314
# Loop through the values in the components' registry
14-
for _, plugin, slot_plugins in components._registry.values():
15+
for key, (_, plugin, slot_plugins) in components._registry.items():
1516
if plugin.__name__ not in plugin_pool.plugins:
1617
# Add the plugin to the global namespace
1718
globals()[plugin.__name__] = plugin
@@ -24,3 +25,8 @@ def update_plugin_pool():
2425
globals()[slot_plugin.__name__] = slot_plugin
2526
# Register the slot plugin with the plugin pool
2627
plugin_pool.register_plugin(slot_plugin)
28+
else:
29+
raise ImproperlyConfigured(
30+
f"Cannot register frontend component {key} since a plugin {plugin.__name__} "
31+
f"is already registered by {plugin_pool.plugins[plugin.__name__].__module__}."
32+
)

djangocms_frontend/component_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def plugin_factory(cls) -> type:
174174
if hasattr(cls, "get_render_template")
175175
else {}
176176
),
177-
"__module__": cls.__module__,
177+
"__module__": "djangocms_frontend.cms_plugins",
178178
},
179179
)
180180
return cls._plugin

djangocms_frontend/plugin_tag.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def get_plugin_class(settings_string: str | type) -> type:
6565
if isinstance(settings_string, str):
6666
if "." in settings_string:
6767
# import the class if a dotted oath is given
68-
return importlib.import_module(*settings_string.rsplit(".", 1))
68+
module_name, class_name = settings_string.rsplit(".", 1)
69+
return getattr(importlib.import_module(module_name), class_name, None)
6970
# Get the plugin class from the plugin pool by its name
7071
return plugin_pool.get_plugin(settings_string)
7172
return settings_string

0 commit comments

Comments
 (0)