aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Kahn-Greene <willg@bluesock.org>2012-07-17 21:14:45 -0400
committerWill Kahn-Greene <willg@bluesock.org>2012-07-17 21:14:45 -0400
commit05d8f314c639f30a699c63e3d4f8feae9a5ba60b (patch)
tree6a8b4a62d7dbdee27da88d6cde6ed054e7258dd0
parent05e007c1dbe7b5b8a092f1a99ed361c4e6b71f26 (diff)
downloadmediagoblin-05d8f314c639f30a699c63e3d4f8feae9a5ba60b.tar.lz
mediagoblin-05d8f314c639f30a699c63e3d4f8feae9a5ba60b.tar.xz
mediagoblin-05d8f314c639f30a699c63e3d4f8feae9a5ba60b.zip
[Issue 466] Implement e-z plugin disabling
-rw-r--r--docs/source/siteadmin/plugins.rst32
-rw-r--r--mediagoblin/init/plugins/__init__.py7
-rw-r--r--mediagoblin/tests/test_pluginapi.py20
3 files changed, 59 insertions, 0 deletions
diff --git a/docs/source/siteadmin/plugins.rst b/docs/source/siteadmin/plugins.rst
index 41f2970f..f5a78da7 100644
--- a/docs/source/siteadmin/plugins.rst
+++ b/docs/source/siteadmin/plugins.rst
@@ -135,3 +135,35 @@ For plugins that you install with pip, you can upgrade them with pip::
pip install -U <plugin-name>
The ``-U`` tells pip to upgrade the package.
+
+
+Troubleshooting plugins
+=======================
+
+Sometimes plugins just don't work right. When you're having problems
+with plugins, think about the following:
+
+1. Check the log files.
+
+ Some plugins will log errors to the log files and you can use that
+ to diagnose the problem.
+
+2. Try running MediaGoblin without that plugin.
+
+ It's easy to disable a plugin from MediaGoblin. Add a ``-`` to the
+ name in your config file.
+
+ For example, change::
+
+ [[mediagoblin.plugins.flatpages]]
+
+ to::
+
+ [[-mediagoblin.plugins.flatpages]]
+
+ That'll prevent the ``mediagoblin.plugins.flatpages`` plugin from
+ loading.
+
+3. If it's a core plugin that comes with MediaGoblin, ask us for help!
+
+ If it's a plugin you got from somewhere else, ask them for help!
diff --git a/mediagoblin/init/plugins/__init__.py b/mediagoblin/init/plugins/__init__.py
index 4ac7a140..cdf9b5ad 100644
--- a/mediagoblin/init/plugins/__init__.py
+++ b/mediagoblin/init/plugins/__init__.py
@@ -42,6 +42,13 @@ def setup_plugins():
# Go through and import all the modules that are subsections of
# the [plugins] section and read in the hooks.
for plugin_module, config in plugin_section.items():
+ # Skip any modules that start with -. This makes it easier for
+ # someone to tweak their configuration so as to not load a
+ # plugin without having to remove swaths of plugin
+ # configuration.
+ if plugin_module.startswith('-'):
+ continue
+
_log.info("Importing plugin module: %s" % plugin_module)
pman.register_plugin(plugin_module)
# If this throws errors, that's ok--it'll halt mediagoblin
diff --git a/mediagoblin/tests/test_pluginapi.py b/mediagoblin/tests/test_pluginapi.py
index 8c9c6a04..315a95da 100644
--- a/mediagoblin/tests/test_pluginapi.py
+++ b/mediagoblin/tests/test_pluginapi.py
@@ -153,3 +153,23 @@ def test_same_plugin_twice():
# Make sure _setup_plugin_called was called once
import mediagoblin.plugins.sampleplugin
eq_(mediagoblin.plugins.sampleplugin._setup_plugin_called, 1)
+
+
+@with_cleanup()
+def test_disabled_plugin():
+ """Run setup_plugins with a single working plugin twice"""
+ cfg = build_config([
+ ('mediagoblin', {}, []),
+ ('plugins', {}, [
+ ('-mediagoblin.plugins.sampleplugin', {}, []),
+ ])
+ ])
+
+ mg_globals.app_config = cfg['mediagoblin']
+ mg_globals.global_config = cfg
+
+ pman = pluginapi.PluginManager()
+ setup_plugins()
+
+ # Make sure we didn't load the plugin
+ eq_(len(pman.plugins), 0)