[Kimchi-devel] [PATCH] bug fix: Only redirects POST requests when new resource is created

Aline Manera alinefm at linux.vnet.ibm.com
Wed Feb 26 02:19:23 UTC 2014


From: Aline Manera <alinefm at br.ibm.com>

generate_action_handler handles the POST requests and it may create a
new resource (example, clone template).
In this case, the user should be redirected to the new resource to be
aware about it. But only in this case.
When POST request does not create a new resource it should continue to
raise an internal redirection.
So verify POST function returns a new ident in order to redirect user to
new resource or not.
Otherwise, the request: POST /host/reboot will be interpreted as GET
/host

Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
 src/kimchi/control/base.py |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/control/base.py b/src/kimchi/control/base.py
index 5d1f380..eea278e 100644
--- a/src/kimchi/control/base.py
+++ b/src/kimchi/control/base.py
@@ -74,7 +74,8 @@ class Resource(object):
                                       for key in action_args)
                 fn = getattr(self.model, model_fn(self, action_name))
                 ident = fn(*model_args)
-                self._redirect(ident)
+                if ident:
+                    self._redirect(ident)
                 uri_params = []
                 for arg in self.model_args:
                     if arg is None:
-- 
1.7.10.4




More information about the Kimchi-devel mailing list