Skip to content

Commit b3a6876

Browse files
Update djangocms_frontend/cms_plugins.py
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
1 parent cf4c4ef commit b3a6876

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

djangocms_frontend/cms_plugins.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,17 @@ def update_plugin_pool():
2222
# Loop through the slot plugins associated with the current plugin
2323
for slot_plugin in slot_plugins:
2424
# Add the slot plugin to the global namespace
25-
globals()[slot_plugin.__name__] = slot_plugin
26-
# Register the slot plugin with the plugin pool
27-
plugin_pool.register_plugin(slot_plugin)
25+
# Register slot plugins, checking for name conflicts
26+
for slot_plugin in slot_plugins:
27+
if slot_plugin.__name__ not in plugin_pool.plugins:
28+
globals()[slot_plugin.__name__] = slot_plugin
29+
plugin_pool.register_plugin(slot_plugin)
30+
else:
31+
raise ImproperlyConfigured(
32+
f"Cannot register slot plugin {slot_plugin.__name__} "
33+
f"since a plugin {slot_plugin.__name__} is already registered "
34+
f"by {plugin_pool.plugins[slot_plugin.__name__].__module__}."
35+
)
2836
else:
2937
raise ImproperlyConfigured(
3038
f"Cannot register frontend component {key} since a plugin {plugin.__name__} "

0 commit comments

Comments
 (0)