|
11 | 11 | """ |
12 | 12 |
|
13 | 13 | import configparser |
| 14 | +import importlib |
14 | 15 | import importlib_metadata |
15 | 16 | import importlib.util |
16 | 17 | import os |
17 | 18 | import sys |
| 19 | +from collections import OrderedDict |
18 | 20 | from importlib.metadata import entry_points |
19 | 21 | from pathlib import Path |
20 | 22 | from urllib.parse import urlparse |
@@ -186,27 +188,51 @@ def instance_name(request): |
186 | 188 | ) |
187 | 189 | ) |
188 | 190 |
|
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()] |
196 | 193 |
|
197 | | -entry_points = importlib_metadata.entry_points() |
| 194 | +eps = importlib_metadata.entry_points() |
198 | 195 |
|
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 | +] |
200 | 209 |
|
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}") |
210 | 236 |
|
211 | 237 | _LIBRARY_MIDDLEWARES = ( |
212 | 238 | 'corsheaders.middleware.CorsMiddleware', |
|
0 commit comments