[Kimchi-devel] [PATCH] [Wok] Make sure to use absolute path when doing a server redirection

Aline Manera alinefm at linux.vnet.ibm.com
Tue Feb 9 17:55:53 UTC 2016


When supporting plugins, the format URI does not correspond to the full
URI path. So fix it to avoid problems when doing server redirection.

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 src/wok/control/base.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/wok/control/base.py b/src/wok/control/base.py
index e1591b5..327e494 100644
--- a/src/wok/control/base.py
+++ b/src/wok/control/base.py
@@ -60,18 +60,20 @@ class Resource(object):
         self.admin_methods = []
 
     def _redirect(self, action_result, code=303):
+        uri_params = []
         if isinstance(action_result, list):
-            uri_params = []
             for arg in action_result:
                 if arg is None:
                     arg = ''
                 uri_params.append(urllib2.quote(arg.encode('utf-8'), safe=""))
-            raise cherrypy.HTTPRedirect(self.uri_fmt % tuple(uri_params), code)
         elif action_result is not None and action_result != self.ident:
             uri_params = list(self.model_args[:-1])
             uri_params += [urllib2.quote(action_result.encode('utf-8'),
                            safe="")]
-            raise cherrypy.HTTPRedirect(self.uri_fmt % tuple(uri_params), code)
+
+        if uri_params:
+            base_uri = cherrypy.request.app.script_name + self.uri_fmt
+            raise cherrypy.HTTPRedirect(base_uri % tuple(uri_params), code)
 
     def generate_action_handler(self, action_name, action_args=None,
                                 destructive=False):
-- 
2.5.0




More information about the Kimchi-devel mailing list