From: Christopher Allan Webber Date: Fri, 25 Nov 2011 17:41:24 +0000 (-0600) Subject: Load multiple media types based on the media_types section of the config file X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cfa96da734e633856282fcefb04e1fb231d85053;p=mediagoblin.git Load multiple media types based on the media_types section of the config file --- diff --git a/mediagoblin.ini b/mediagoblin.ini index 728ab2f2..dbde6e51 100644 --- a/mediagoblin.ini +++ b/mediagoblin.ini @@ -11,6 +11,9 @@ email_debug_mode = true # Set to false to disable registrations allow_registration = true +## Uncomment this to turn on video or enable other media types +# media_types = mediagoblin.media_types.image, mediagoblin.media_types.video + ## Uncomment this to put some user-overriding templates here #local_templates = %(here)s/user_dev/templates/ diff --git a/mediagoblin/config_spec.ini b/mediagoblin/config_spec.ini index e5e059c9..a17e30f0 100644 --- a/mediagoblin/config_spec.ini +++ b/mediagoblin/config_spec.ini @@ -2,16 +2,17 @@ # HTML title of the pages html_title = string(default="GNU MediaGoblin") +# Enabled media types +media_types = string_list(default=list("mediagoblin.media_types.image")) + # database stuff db_host = string() db_name = string(default="mediagoblin") db_port = integer() - # Where temporary files used in processing and etc are kept workbench_path = string(default="%(here)s/user_dev/media/workbench") - # Where mediagoblin-builtin static assets are kept direct_remote_path = string(default="/mgoblin_static/") diff --git a/mediagoblin/media_types/__init__.py b/mediagoblin/media_types/__init__.py index f56fd942..61786562 100644 --- a/mediagoblin/media_types/__init__.py +++ b/mediagoblin/media_types/__init__.py @@ -27,20 +27,12 @@ class FileTypeNotSupported(Exception): class InvalidFileType(Exception): pass -# This should be more dynamic in the future. Perhaps put it in the .ini? -# -- Joar -MEDIA_TYPES = [ - 'mediagoblin.media_types.image'] - -if mg_globals.app_config['enable_video']: - MEDIA_TYPES.append('mediagoblin.media_types.video') - def get_media_types(): - ''' + """ Generator that returns the available media types - ''' - for media_type in MEDIA_TYPES: + """ + for media_type in mg_globals.app_config['media_types']: yield media_type