[Kimchi-devel] [PATCH 1/6] Force a HTTP redirection when a resource has its ID changed after a PUT request

Aline Manera alinefm at linux.vnet.ibm.com
Wed Oct 21 23:40:45 UTC 2015


The correct exception to raise when a resource has its ID changed is
cherrypy.HTTPRedirect to inform user about the new resource URI.

cherrypy.InternalRedirect is for automatic redirection (without
informing the client about that).

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

diff --git a/src/wok/control/base.py b/src/wok/control/base.py
index e9ed3c8..638e196 100644
--- a/src/wok/control/base.py
+++ b/src/wok/control/base.py
@@ -66,12 +66,12 @@ class Resource(object):
                 if arg is None:
                     arg = ''
                 uri_params.append(urllib2.quote(arg.encode('utf-8'), safe=""))
-            raise internal_redirect(self.uri_fmt % tuple(uri_params))
+            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 internal_redirect(self.uri_fmt % tuple(uri_params))
+            raise cherrypy.HTTPRedirect(self.uri_fmt % tuple(uri_params), code)
 
     def generate_action_handler(self, action_name, action_args=None,
                                 destructive=False):
-- 
2.1.0




More information about the Kimchi-devel mailing list