[Kimchi-devel] [PATCH v2][Wok] Change plugins get_list to return only loaded plugins

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Sat Dec 26 01:10:52 UTC 2015


When using multiple plugins, it is possible that some plugin has a
problem and is not loaded (like when there is a missing module).
In this cases, Wok is not going to load the plugin in cherrypy
configuration, but plugins API return the missing plugin name.
When this occours, UI becomes broken and it is not possible to use any
other plugin, because Wok UI is blank.
This patch fix this problem, returning only plugins names that were
loaded by Wok.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 src/wok/model/plugins.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/wok/model/plugins.py b/src/wok/model/plugins.py
index 3a5a89e..85d60b6 100644
--- a/src/wok/model/plugins.py
+++ b/src/wok/model/plugins.py
@@ -19,6 +19,8 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 
+import cherrypy
+
 from wok.utils import get_enabled_plugins
 
 
@@ -27,4 +29,7 @@ class PluginsModel(object):
         pass
 
     def get_list(self):
-        return [plugin for (plugin, config) in get_enabled_plugins()]
+        # Will only return plugins that were loaded correctly by WOK and are
+        # properly configured in cherrypy
+        return [plugin for (plugin, config) in get_enabled_plugins()
+                if config.get('wok').get('uri') in cherrypy.tree.apps.keys()]
-- 
2.1.0




More information about the Kimchi-devel mailing list