From 1607da034dcfc8aec528c6cac0f8a16653e50a55 Mon Sep 17 00:00:00 2001 From: Sergio Oliveira Date: Mon, 9 Feb 2015 11:19:32 -0200 Subject: [PATCH] Added support to install apps arbitrary apps --- colab/plugins/__init__.py | 0 colab/plugins/urls.py | 21 +++++++++++++++++++++ colab/settings.py | 19 +++++-------------- colab/urls.py | 7 +++---- colab/utils/conf.py | 5 ++++- 5 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 colab/plugins/__init__.py create mode 100644 colab/plugins/urls.py diff --git a/colab/plugins/__init__.py b/colab/plugins/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/colab/plugins/__init__.py diff --git a/colab/plugins/urls.py b/colab/plugins/urls.py new file mode 100644 index 0000000..b84ebaf --- /dev/null +++ b/colab/plugins/urls.py @@ -0,0 +1,21 @@ + +from django.conf import settings +from django.conf.urls import patterns, url, include +from django.core.exceptions import ImproperlyConfigured + +undef_url_include_msg = (u'COLAB_APP with urls must define ' + 'the `include` attribute') + +urlpatterns = patterns('') + +for app_name, app in settings.COLAB_APPS.items(): + if not app or 'urls' not in app: + continue + + urls = app.get('urls') + if not urls.get('include'): + raise ImproperlyConfigured(undef_url_include_msg) + urlpatterns += patterns('', + url(urls.get('prefix', r''), include(urls['include'], + namespace=urls.get('namespace'))), + ) diff --git a/colab/settings.py b/colab/settings.py index 17b964e..625603f 100644 --- a/colab/settings.py +++ b/colab/settings.py @@ -50,7 +50,6 @@ INSTALLED_APPS = ( 'hitcounter', 'i18n_model', 'mptt', - 'dpaste', 'taggit', # Own apps @@ -292,19 +291,6 @@ CONVERSEJS_SHOW_ONLY_ONLINE_USERS = True # Tastypie settings TASTYPIE_DEFAULT_FORMATS = ['json', ] -# Dpaste settings -DPASTE_EXPIRE_CHOICES = ( - ('onetime', _(u'One Time Snippet')), - (3600, _(u'In one hour')), - (3600 * 24 * 7, _(u'In one week')), - (3600 * 24 * 30, _(u'In one month')), - ('never', _(u'Never')), -) -DPASTE_EXPIRE_DEFAULT = DPASTE_EXPIRE_CHOICES[4][0] -DPASTE_DEFAULT_GIST_DESCRIPTION = 'Gist created from Colab DPaste' -DPASTE_DEFAULT_GIST_NAME = 'colab_paste' -DPASTE_LEXER_DEFAULT = 'text' - from .utils.conf import load_yaml_settings locals().update(load_yaml_settings()) @@ -328,3 +314,8 @@ PROXIED_APPS = locals().get('PROXIED_APPS') or {} for app_label in PROXIED_APPS.keys(): INSTALLED_APPS += ('colab.proxy.{}'.format(app_label),) + +COLAB_APPS = locals().get('COLAB_APPS') or {} + +for app in COLAB_APPS: + INSTALLED_APPS += (app,) diff --git a/colab/urls.py b/colab/urls.py index 78e1958..09d32f5 100644 --- a/colab/urls.py +++ b/colab/urls.py @@ -7,8 +7,7 @@ from django.views.generic import RedirectView admin.autodiscover() -urlpatterns = patterns( - '', +urlpatterns = patterns('', url(r'^robots.txt$', 'colab.home.views.robots', name='robots'), url(r'^dashboard$', 'colab.home.views.dashboard', name='dashboard'), url(r'^$', RedirectView.as_view(url=settings.COLAB_HOME_URL), name='home'), @@ -35,8 +34,6 @@ urlpatterns = patterns( url(r'^planet/', include('feedzilla.urls')), - url(r'paste/', include('dpaste.urls.dpaste')), - # Uncomment the next line to enable the admin: url(r'^colab/admin/', include(admin.site.urls)), @@ -44,6 +41,8 @@ urlpatterns = patterns( url(r'^gitlab/', include('colab.proxy.gitlab.urls')), url(r'^social/', include('colab.proxy.noosfero.urls')), url(r'^ci/', include('colab.proxy.jenkins.urls')), + + url(r'', include('colab.plugins.urls')), ) if settings.DEBUG: diff --git a/colab/utils/conf.py b/colab/utils/conf.py index f87b8d9..b0dc80b 100644 --- a/colab/utils/conf.py +++ b/colab/utils/conf.py @@ -2,6 +2,8 @@ import os import yaml +import yamlordereddictloader + from django.core.exceptions import ImproperlyConfigured @@ -14,7 +16,8 @@ class InaccessibleYAMLSettings(ImproperlyConfigured): def _load_yaml_file(yaml_path): try: with open(yaml_path) as yaml_file: - yaml_settings = yaml.load(yaml_file.read()) + yaml_settings = yaml.load(yaml_file.read(), + yamlordereddictloader.Loader) except IOError: msg = ('Could not open settings file {}. Please ' 'check if the file exists and if user ' -- libgit2 0.21.2