Add documentation on changing data dir and Fix stylistic changes
authorJessica Tallon <jessica@megworld.co.uk>
Fri, 19 Sep 2014 13:15:11 +0000 (14:15 +0100)
committerJessica Tallon <jessica@megworld.co.uk>
Mon, 29 Sep 2014 08:04:04 +0000 (09:04 +0100)
docs/source/siteadmin/configuration.rst
mediagoblin.ini
mediagoblin/init/config.py

index 3da5cdd9a7dafe3508275a4a7aa5153235d45f45..dd0d6cd9747f144cdd339c871f351e9598e85232 100644 (file)
@@ -109,6 +109,34 @@ they sound like.
 - email_smtp_user
 - email_smtp_pass
 
+Changing data directory
+-----------------------
+
+MediaGoblin by default stores your data in wherever ``data_basedir``.
+This can be changed by changing the value in your ``mediagoblin.ini`` file
+for example::
+
+    [DEFAULT]
+    data_basedir = "/var/mediagoblin/user_data"
+
+For efficiency reasons MediaGoblin doesn't serve these files itself and
+instead leaves that to the webserver. You will have to alter the location
+to match the path in ``data_basedir``.
+
+If you use ``lazyserver.sh`` you need to change the ``paste.ini`` file::
+
+    [app:mediagoblin]
+    /mgoblin_media = /var/mediagoblin/user_data
+
+If you use nginx you need to change the config::
+
+     # Instance specific media:
+     location /mgoblin_media/ {
+         alias /var/mediagoblin/user_data;
+     }
+
+Once you have done this you will need to move any existing media you had in the
+old directory to the new directory so existing media still can be displayed.
 
 All other configuration changes
 -------------------------------
index de4d2c8521a6def432d712ae141d654a4b32309a..7899d7ca428850df7508aa7c7d9fdd9cbc598e75 100644 (file)
@@ -5,6 +5,11 @@
 # It defines types and defaults so it’s a good place to look for documentation
 # or to find hidden options that we didn’t tell you about. :)
 
+# To chnange the directory you should make sure you change the
+# directory in paste.ini and/or your webserver configuration.
+#[DEFAULT]
+# data_basedir = "/path/to/data/directory"
+
 [mediagoblin]
 direct_remote_path = /mgoblin_static/
 email_sender_address = "notice@mediagoblin.example.org"
index 8d5577acffac2864b349e6d37b32a1a6581e5843..a9189e8d31e6160334186ee6415f49b6f7454a59 100644 (file)
@@ -39,12 +39,12 @@ def _setup_defaults(config, config_path, extra_defaults=None):
     config.setdefault('DEFAULT', {})
     config['DEFAULT']['here'] = os.path.dirname(config_path)
     config['DEFAULT']['__file__'] = config_path
-    
+
     for key, value in extra_defaults.items():
         config['DEFAULT'].setdefault(key, value)
 
 
-def read_mediagoblin_config(config_path, config_spec=CONFIG_SPEC_PATH):
+def read_mediagoblin_config(config_path, config_spec_path=CONFIG_SPEC_PATH):
     """
     Read a config object from config_path.
 
@@ -60,7 +60,7 @@ def read_mediagoblin_config(config_path, config_spec=CONFIG_SPEC_PATH):
 
     Args:
      - config_path: path to the config file
-     - config_spec: config file that provides defaults and value types
+     - config_spec_path: config file that provides defaults and value types
        for validation / conversion.  Defaults to mediagoblin/config_spec.ini
 
     Returns:
@@ -74,23 +74,23 @@ def read_mediagoblin_config(config_path, config_spec=CONFIG_SPEC_PATH):
     # we can add their plugin specs to the general config_spec.
     config = ConfigObj(
         config_path,
-        interpolation='ConfigParser')
+        interpolation="ConfigParser")
 
-    plugins = config.get("plugins", {}).keys()
-    plugin_configs = {}
+    # temporary bootstrap, just setup here and __file__... we'll do this again
+    _setup_defaults(config, config_path)
 
     # Now load the main config spec
     config_spec = ConfigObj(
-        config_spec,
-        encoding='UTF8', list_values=False, _inspec=True)
-
-    # temporary bootstrap, just setup here and __file__... we'll do this again
-    _setup_defaults(config, config_path)
+        config_spec_path,
+        encoding="UTF8", list_values=False, _inspec=True)
 
     # Set up extra defaults that will be pushed into the rest of the
-    # configs.  This is a combined extrapolation of defaults based on 
-    mainconfig_defaults = copy.copy(config_spec.get('DEFAULT', {}))
-    mainconfig_defaults.update(config.get('DEFAULT', {}))
+    # configs.  This is a combined extrapolation of defaults based on
+    mainconfig_defaults = copy.copy(config_spec.get("DEFAULT", {}))
+    mainconfig_defaults.update(config["DEFAULT"])
+
+    plugins = config.get("plugins", {}).keys()
+    plugin_configs = {}
 
     for plugin in plugins:
         try:
@@ -98,10 +98,10 @@ def read_mediagoblin_config(config_path, config_spec=CONFIG_SPEC_PATH):
                 plugin, "config_spec.ini")
             if not os.path.exists(plugin_config_spec_path):
                 continue
-            
+
             plugin_config_spec = ConfigObj(
                 plugin_config_spec_path,
-                encoding='UTF8', list_values=False, _inspec=True)
+                encoding="UTF8", list_values=False, _inspec=True)
             _setup_defaults(
                 plugin_config_spec, config_path, mainconfig_defaults)
 
@@ -114,16 +114,16 @@ def read_mediagoblin_config(config_path, config_spec=CONFIG_SPEC_PATH):
             _log.warning(
                 "When setting up config section, could not import '%s'" %
                 plugin)
-    
+
     # append the plugin specific sections of the config spec
-    config_spec['plugins'] = plugin_configs
+    config_spec["plugins"] = plugin_configs
 
     _setup_defaults(config_spec, config_path, mainconfig_defaults)
 
     config = ConfigObj(
         config_path,
         configspec=config_spec,
-        interpolation='ConfigParser')
+        interpolation="ConfigParser")
 
     _setup_defaults(config, config_path, mainconfig_defaults)