added plugin architecture

This commit is contained in:
vabene1111
2023-04-06 17:22:02 +02:00
parent 0ba2fa296a
commit 2552d27f6f
4 changed files with 58 additions and 2 deletions

View File

@@ -14,6 +14,8 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
import traceback
from django.conf import settings
from django.contrib import admin
from django.urls import include, path, re_path
@@ -42,3 +44,15 @@ if settings.ENABLE_METRICS:
if settings.GUNICORN_MEDIA or settings.DEBUG:
urlpatterns += re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
urlpatterns += re_path(r'^jsreverse.json$', reverse_views.urls_js, name='js_reverse'),
for p in settings.PLUGINS:
try:
urlpatterns += path(p['base_url'], include(f'{p["module"]}.urls')),
except ModuleNotFoundError as e:
if settings.DEBUG:
print(e.msg)
print(f'ERROR failed loading plugin <{p["name"]}> urls, did you forget creating urls.py in your plugin?')
except Exception as e:
if settings.DEBUG:
print(f'ERROR failed loading urls for plugin <{p["name"]}>')
traceback.format_exc()