Skip to content

Commit cc05ab2

Browse files
committed
fix plugins discovery
1 parent dba1b85 commit cc05ab2

File tree

1 file changed

+44
-18
lines changed

1 file changed

+44
-18
lines changed

app/eventyay/config/settings.py

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
"""
1212

1313
import configparser
14+
import importlib
1415
import importlib_metadata
1516
import importlib.util
1617
import os
1718
import sys
19+
from collections import OrderedDict
1820
from importlib.metadata import entry_points
1921
from pathlib import Path
2022
from urllib.parse import urlparse
@@ -186,27 +188,51 @@ def instance_name(request):
186188
)
187189
)
188190

189-
PLUGINS = []
190-
for entry_point in entry_points(group='pretalx.plugin'):
191-
PLUGINS.append(entry_point.module)
192-
# TODO:
193-
# pretalx_venueless , pretalx_downstream and pretalx_pages module's import statement must be changed w.r.t. enext.
194-
# Then you can uncomment the below code safely.
195-
# INSTALLED_APPS += (entry_point.module, )
191+
raw_exclude = config.get('eventyay', 'plugins_exclude', fallback='')
192+
PLUGINS_EXCLUDE = [m.strip() for m in raw_exclude.split(',') if m.strip()]
196193

197-
entry_points = importlib_metadata.entry_points()
194+
eps = importlib_metadata.entry_points()
198195

199-
PRETIX_PLUGINS_EXCLUDE = config.get('eventyay', 'plugins_exclude', fallback='').split(',')
196+
# Pretix plugins
197+
pretix_plugins = [
198+
ep.module
199+
for ep in eps.select(group='pretix.plugin')
200+
if ep.module not in PLUGINS_EXCLUDE
201+
]
202+
203+
# Pretalx plugins
204+
pretalx_plugins = [
205+
ep.module
206+
for ep in eps.select(group='pretalx.plugin')
207+
if ep.module not in PLUGINS_EXCLUDE
208+
]
200209

201-
for entry_point in entry_points.select(group='pretix.plugin'):
202-
if entry_point.module not in PRETIX_PLUGINS_EXCLUDE:
203-
PLUGINS.append(entry_point.module)
204-
# TODO:
205-
# pretix_venueless and pretix_pages module's import statement must be changed w.r.t. enext.
206-
# Then you can remove the below check safely.
207-
if entry_point.module == 'pretix_venueless' or entry_point.module == 'pretix_pages':
208-
continue
209-
INSTALLED_APPS += (entry_point.module,)
210+
ALL_PLUGINS = sorted(pretix_plugins + pretalx_plugins)
211+
212+
213+
# ---------------------------
214+
# TODO: Adjust import paths for pretix_venueless, pretix_downstream, pretalx_pages
215+
# Once ready, remove below 2 lines of code and just add Pretix plugins to INSTALLED_APPS like:
216+
# INSTALLED_APPS += tuple(pretix_plugins)
217+
SAFE_PRETIX_PLUGINS = [
218+
m for m in pretix_plugins if m not in {'pretix_venueless', 'pretix_pages'}
219+
]
220+
INSTALLED_APPS += tuple(SAFE_PRETIX_PLUGINS)
221+
222+
# ---------------------------
223+
# TODO: Adjust import paths for pretalx_venueless, pretalx_downstream, pretalx_pages
224+
# Once ready, uncomment the following line to add Pretalx plugins to INSTALLED_APPS
225+
# INSTALLED_APPS += tuple(pretalx_plugins)
226+
227+
# Optional: Dynamic Import
228+
LOADED_PLUGINS = OrderedDict()
229+
for module_name in ALL_PLUGINS:
230+
try:
231+
module = importlib.import_module(module_name)
232+
LOADED_PLUGINS[module_name] = module
233+
except Exception as e:
234+
# Log errors but continue
235+
print(f"Failed to load plugin {module_name}: {e}")
210236

211237
_LIBRARY_MIDDLEWARES = (
212238
'corsheaders.middleware.CorsMiddleware',

0 commit comments

Comments
 (0)