[Kimchi-devel] [PATCH] [Wok 1/7] Add get_plugin_from_uri() method to wok utils

Lucio Correia luciojhc at linux.vnet.ibm.com
Fri Aug 19 19:37:36 UTC 2016


Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
---
 src/wok/utils.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/wok/utils.py b/src/wok/utils.py
index 4c132a1..3d61e66 100644
--- a/src/wok/utils.py
+++ b/src/wok/utils.py
@@ -137,6 +137,17 @@ def get_plugin_from_request():
     return 'wok'
 
 
+def get_plugin_from_uri(uri):
+    """
+    Tries to deduce plugin name from URI. If no success, returns 'wok'.
+    """
+    split = uri.split('/')
+    if len(split) > 2 and split[1] == 'plugins':
+        return split[2]
+
+    return 'wok'
+
+
 def import_class(class_path):
     module_name, class_name = class_path.rsplit('.', 1)
     try:
-- 
1.9.1




More information about the Kimchi-devel mailing list